Skip to content

Commit

Permalink
[core] Ensure thumbnail output directory exists (#7985)
Browse files Browse the repository at this point in the history
Closes #8203
Authored by: Riteo
  • Loading branch information
Riteo committed Oct 13, 2023
1 parent b286ec6 commit 2acd1d5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion yt_dlp/YoutubeDL.py
Expand Up @@ -4221,7 +4221,7 @@ def _write_subtitles(self, info_dict, filename):
return ret

def _write_thumbnails(self, label, info_dict, filename, thumb_filename_base=None):
''' Write thumbnails to file and return list of (thumb_filename, final_thumb_filename) '''
''' Write thumbnails to file and return list of (thumb_filename, final_thumb_filename); or None if error '''
write_all = self.params.get('write_all_thumbnails', False)
thumbnails, ret = [], []
if write_all or self.params.get('writethumbnail', False):
Expand All @@ -4237,6 +4237,9 @@ def _write_thumbnails(self, label, info_dict, filename, thumb_filename_base=None
self.write_debug(f'Skipping writing {label} thumbnail')
return ret

if not self._ensure_dir_exists(filename):
return None

for idx, t in list(enumerate(thumbnails))[::-1]:
thumb_ext = (f'{t["id"]}.' if multiple else '') + determine_ext(t['url'], 'jpg')
thumb_display_id = f'{label} thumbnail {t["id"]}'
Expand Down

0 comments on commit 2acd1d5

Please sign in to comment.