From 27784991430daa17b4bf0f20203815aec5c99c9e Mon Sep 17 00:00:00 2001 From: ClosedPort22 <44864697+ClosedPort22@users.noreply.github.com> Date: Thu, 21 Sep 2023 17:05:49 +0900 Subject: [PATCH] Retry thumbnail download on network errors --- yt_dlp/YoutubeDL.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py index 1feed3052..9a5cbd5fd 100644 --- a/yt_dlp/YoutubeDL.py +++ b/yt_dlp/YoutubeDL.py @@ -4260,13 +4260,12 @@ class YoutubeDL: else: self.to_screen(f'[info] Downloading {thumb_display_id} ...') 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}') - with open(encodeFilename(thumb_filename), 'wb') as thumbf: - shutil.copyfileobj(uf, thumbf) + self.dl(thumb_filename, thumb_copy) ret.append((thumb_filename, thumb_filename_final)) 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: self.to_screen(f'[info] {thumb_display_id.title()} does not exist') else: