Skip to content

Commit

Permalink
[core] Avoid processing empty format list after removing bad formats
Browse files Browse the repository at this point in the history
* also ensure compat encoding of error strings
  • Loading branch information
dirkf committed Aug 20, 2022
1 parent 556862b commit 66e58dc
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions youtube_dl/YoutubeDL.py
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ def prepare_filename(self, info_dict):
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):
Expand Down Expand Up @@ -1570,9 +1570,6 @@ def sanitize_numeric_fields(info):
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:
Expand All @@ -1585,7 +1582,10 @@ def is_wellformed(f):
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 = {}

Expand Down Expand Up @@ -2058,7 +2058,7 @@ def compatible_formats(formats):
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)
Expand Down

0 comments on commit 66e58dc

Please sign in to comment.