diff options
author | dirkf <[email protected]> | 2022-08-21 00:21:02 +0100 |
---|---|---|
committer | dirkf <[email protected]> | 2022-08-21 00:45:06 +0100 |
commit | 66e58dccc29de65cc95ee97915987d785b2b4b31 (patch) | |
tree | 042b6e76a087dffaa367582e400170228e6127c0 | |
parent | 556862bc911bb54435b7b0b01451789b884b0390 (diff) | |
download | youtube-dl-66e58dccc29de65cc95ee97915987d785b2b4b31.tar.gz youtube-dl-66e58dccc29de65cc95ee97915987d785b2b4b31.zip |
[core] Avoid processing empty format list after removing bad formats
* also ensure compat encoding of error strings
-rwxr-xr-x | youtube_dl/YoutubeDL.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py index e77b8d50c..8e8546596 100755 --- a/youtube_dl/YoutubeDL.py +++ b/youtube_dl/YoutubeDL.py @@ -721,7 +721,7 @@ class YoutubeDL(object): filename = encodeFilename(filename, True).decode(preferredencoding()) return sanitize_path(filename) except ValueError as err: - self.report_error('Error in output template: ' + str(err) + ' (encoding: ' + repr(preferredencoding()) + ')') + self.report_error('Error in output template: ' + error_to_compat_str(err) + ' (encoding: ' + repr(preferredencoding()) + ')') return None def _match_entry(self, info_dict, incomplete): @@ -1570,9 +1570,6 @@ class YoutubeDL(object): else: formats = info_dict['formats'] - if not formats: - raise ExtractorError('No video formats found!') - def is_wellformed(f): url = f.get('url') if not url: @@ -1585,7 +1582,10 @@ class YoutubeDL(object): return True # Filter out malformed formats for better extraction robustness - formats = list(filter(is_wellformed, formats)) + formats = list(filter(is_wellformed, formats or [])) + + if not formats: + raise ExtractorError('No video formats found!') formats_dict = {} @@ -2058,7 +2058,7 @@ class YoutubeDL(object): try: self.post_process(filename, info_dict) except (PostProcessingError) as err: - self.report_error('postprocessing: %s' % str(err)) + self.report_error('postprocessing: %s' % error_to_compat_str(err)) return self.record_download_archive(info_dict) # avoid possible nugatory search for further items (PR #26638) |