Skip to content

Commit

Permalink
Remove useless 'format' setting when download thumbnails and subtitles
Browse files Browse the repository at this point in the history
  • Loading branch information
benoit74 committed Oct 7, 2024
1 parent b0015c9 commit e4a27a9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions scraper/src/youtube2zim/scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -830,8 +830,11 @@ def download_thumbnail(self, video_id, options):
"writeautomaticsub": False,
}
)
# drop 'format' setting to avoid format issues when downloading thumbnail
options_copy.pop("format")

Check warning on line 834 in scraper/src/youtube2zim/scraper.py

View check run for this annotation

Codecov / codecov/patch

scraper/src/youtube2zim/scraper.py#L834

Added line #L834 was not covered by tests
with yt_dlp.YoutubeDL(options_copy) as ydl:
ydl.download([video_id])
logger.debug(f"Thumbnail downloaded successfully for {video_id}")

Check warning on line 837 in scraper/src/youtube2zim/scraper.py

View check run for this annotation

Codecov / codecov/patch

scraper/src/youtube2zim/scraper.py#L837

Added line #L837 was not covered by tests
process_thumbnail(thumbnail_path, preset)
self.add_file_to_zim(
zim_path, thumbnail_path, callback=(delete_callback, thumbnail_path)
Expand Down Expand Up @@ -902,8 +905,11 @@ def download_subtitles(self, video_id, options):
options_copy = options.copy()
options_copy.update({"skip_download": True, "writethumbnail": False})
try:
# drop 'format' setting to avoid format issues when downloading subtitles
options_copy.pop("format")

Check warning on line 909 in scraper/src/youtube2zim/scraper.py

View check run for this annotation

Codecov / codecov/patch

scraper/src/youtube2zim/scraper.py#L909

Added line #L909 was not covered by tests
with yt_dlp.YoutubeDL(options_copy) as ydl:
ydl.download([video_id])
logger.debug(f"Subtitles downloaded successfully for {video_id}")

Check warning on line 912 in scraper/src/youtube2zim/scraper.py

View check run for this annotation

Codecov / codecov/patch

scraper/src/youtube2zim/scraper.py#L912

Added line #L912 was not covered by tests
subtitles_list = self.fetch_video_subtitles_list(video_id)
# save subtitles to cache for generating JSON files later
save_json(
Expand Down

0 comments on commit e4a27a9

Please sign in to comment.