Skip to content

Commit

Permalink
Bugfix for 39f32f1
Browse files Browse the repository at this point in the history
  • Loading branch information
pukkandan committed Feb 12, 2023
1 parent 5712943 commit c154302
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions yt_dlp/YoutubeDL.py
Original file line number Diff line number Diff line change
Expand Up @@ -2466,15 +2466,8 @@ def _raise_pending_errors(self, info):

def sort_formats(self, info_dict):
formats = self._get_formats(info_dict)
if not formats:
return
# Backward compatibility with InfoExtractor._sort_formats
field_preference = formats[0].pop('__sort_fields', None)
if field_preference:
info_dict['_format_sort_fields'] = field_preference

formats.sort(key=FormatSorter(
self, info_dict.get('_format_sort_fields', [])).calculate_preference)
self, info_dict.get('_format_sort_fields') or []).calculate_preference)

def process_video_result(self, info_dict, download=True):
assert info_dict.get('_type', 'video') == 'video'
Expand Down Expand Up @@ -2563,6 +2556,11 @@ def sanitize_numeric_fields(info):

formats = self._get_formats(info_dict)

# Backward compatibility with InfoExtractor._sort_formats
field_preference = formats[0].pop('__sort_fields', None)
if field_preference:
info_dict['_format_sort_fields'] = field_preference

# or None ensures --clean-infojson removes it
info_dict['_has_drm'] = any(f.get('has_drm') for f in formats) or None
if not self.params.get('allow_unplayable_formats'):
Expand Down Expand Up @@ -2623,7 +2621,10 @@ def is_wellformed(f):
if '__x_forwarded_for_ip' in info_dict:
del info_dict['__x_forwarded_for_ip']

self.sort_formats({'formats': formats})
self.sort_formats({
'formats': formats,
'_format_sort_fields': info_dict.get('_format_sort_fields')
})

# Sanitize and group by format_id
formats_dict = {}
Expand Down

0 comments on commit c154302

Please sign in to comment.