aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpukkandan <pukkandan.ytdlp@gmail.com>2021-05-15 19:12:26 +0530
committerpukkandan <pukkandan.ytdlp@gmail.com>2021-05-15 19:26:01 +0530
commitfe346461ffe6b664f48d1d3335e34445695d6ed4 (patch)
tree9c815dbcb284892ff1135788ed36630261793ad7
parentd2a1fad9689cf866309c9de9c5b06adb73a8a943 (diff)
downloadhypervideo-pre-fe346461ffe6b664f48d1d3335e34445695d6ed4.tar.lz
hypervideo-pre-fe346461ffe6b664f48d1d3335e34445695d6ed4.tar.xz
hypervideo-pre-fe346461ffe6b664f48d1d3335e34445695d6ed4.zip
Fix `--check-formats` when there is network error
-rw-r--r--yt_dlp/YoutubeDL.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py
index 9fe591f75..80e017c96 100644
--- a/yt_dlp/YoutubeDL.py
+++ b/yt_dlp/YoutubeDL.py
@@ -1726,9 +1726,13 @@ class YoutubeDL(object):
expand_path(paths.get('home', '').strip()),
expand_path(paths.get('temp', '').strip()),
'ytdl.%s.f%s.check-format' % (random_uuidv4(), f['format_id']))
- dl, _ = self.dl(temp_file, f, test=True)
- if os.path.exists(temp_file):
- os.remove(temp_file)
+ try:
+ dl, _ = self.dl(temp_file, f, test=True)
+ except (ExtractorError, IOError, OSError, ValueError) + network_exceptions:
+ dl = False
+ finally:
+ if os.path.exists(temp_file):
+ os.remove(temp_file)
if dl:
yield f
else:
@@ -2395,7 +2399,7 @@ class YoutubeDL(object):
self.dl(sub_filename, sub_info.copy(), subtitle=True)
sub_info['filepath'] = sub_filename
files_to_move[sub_filename] = sub_filename_final
- except tuple([ExtractorError, IOError, OSError, ValueError] + network_exceptions) as err:
+ except (ExtractorError, IOError, OSError, ValueError) + network_exceptions as err:
self.report_warning('Unable to download subtitle for "%s": %s' %
(sub_lang, error_to_compat_str(err)))
continue