mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-20 05:47:24 +01:00
Retry thumbnail download on network errors
This commit is contained in:
parent
9d6254069c
commit
2778499143
@ -4260,13 +4260,12 @@ def _write_thumbnails(self, label, info_dict, filename, thumb_filename_base=None
|
|||||||
else:
|
else:
|
||||||
self.to_screen(f'[info] Downloading {thumb_display_id} ...')
|
self.to_screen(f'[info] Downloading {thumb_display_id} ...')
|
||||||
try:
|
try:
|
||||||
uf = self.urlopen(Request(t['url'], headers=t.get('http_headers', {})))
|
thumb_copy = t.copy()
|
||||||
self.to_screen(f'[info] Writing {thumb_display_id} to: {thumb_filename}')
|
self.to_screen(f'[info] Writing {thumb_display_id} to: {thumb_filename}')
|
||||||
with open(encodeFilename(thumb_filename), 'wb') as thumbf:
|
self.dl(thumb_filename, thumb_copy)
|
||||||
shutil.copyfileobj(uf, thumbf)
|
|
||||||
ret.append((thumb_filename, thumb_filename_final))
|
ret.append((thumb_filename, thumb_filename_final))
|
||||||
t['filepath'] = thumb_filename
|
t['filepath'] = thumb_filename
|
||||||
except network_exceptions as err:
|
except (DownloadError, ExtractorError, IOError, OSError, ValueError) + network_exceptions as err:
|
||||||
if isinstance(err, HTTPError) and err.status == 404:
|
if isinstance(err, HTTPError) and err.status == 404:
|
||||||
self.to_screen(f'[info] {thumb_display_id.title()} does not exist')
|
self.to_screen(f'[info] {thumb_display_id.title()} does not exist')
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user