Skip to content

Handle extractor crashes when fetching a playlist - #144

Open
jay23606 wants to merge 1 commit into
woefe:masterfrom
jay23606:fix/update-playlist-download-error
Open

jay23606 wants to merge 1 commit into
woefe:masterfrom
jay23606:fix/update-playlist-download-error

Conversation

@jay23606

Copy link
Copy Markdown

Fixes #143

Problem

When yt-dlp fails to download a playlist page, some extractors crash with a non-DownloadError exception instead of reporting a clean error. The peertube extractor, for example, calls .get() on a bool response and raises AttributeError. Fetcher.get_unprocessed_entries only caught youtube_dl.DownloadError, so the exception escaped and aborted ytcc update.

Change

  • ytcc/updater.py: catch any exception raised while fetching a playlist, log it with the same message used for DownloadError, and continue with the other playlists.
  • tests/test_updater.py: regression test that replaces YoutubeDL with a stand-in whose extract_info raises AttributeError, and asserts that no entries are returned instead of an exception.

Validation

  • New test fails on master (AttributeError propagates) and passes with this change.
  • hatch test / pytest on this branch: 32 passed, 2 failed. The 2 failures (test_cli.py::test_download, test_cli.py::test_play_video) also fail on master in my Windows environment, and I did not touch them. They look like they need mpv/ffmpeg.
  • ruff check on the changed files reports only ICN001 (datetime import alias) on the existing line in updater.py, which is also reported on master.

yt-dlp can fail to download a playlist page and then crash inside an
extractor (for example the peertube extractor calls .get() on a bool)
instead of raising DownloadError. Only DownloadError was caught in
Fetcher.get_unprocessed_entries, so the AttributeError aborted
`ytcc update` for every playlist.

Catch any exception from the playlist fetch, log it the same way as a
DownloadError, and continue with the remaining playlists.

Adds a regression test that mocks YoutubeDL.extract_info to raise an
AttributeError.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crash when a playlist download fails

1 participant