mirror of
https://codeberg.org/polarisfm/youtube-dl.git
synced 2024-12-27 10:06:45 +00:00
[extractor/common] Add ability to specify custom field preference for _sort_formats
This commit is contained in:
parent
b524a001d6
commit
3ded7bac16
1 changed files with 4 additions and 1 deletions
|
@ -708,7 +708,7 @@ class InfoExtractor(object):
|
||||||
return self._html_search_meta('twitter:player', html,
|
return self._html_search_meta('twitter:player', html,
|
||||||
'twitter card player')
|
'twitter card player')
|
||||||
|
|
||||||
def _sort_formats(self, formats):
|
def _sort_formats(self, formats, field_preference=None):
|
||||||
if not formats:
|
if not formats:
|
||||||
raise ExtractorError('No video formats found')
|
raise ExtractorError('No video formats found')
|
||||||
|
|
||||||
|
@ -718,6 +718,9 @@ class InfoExtractor(object):
|
||||||
if not f.get('ext') and 'url' in f:
|
if not f.get('ext') and 'url' in f:
|
||||||
f['ext'] = determine_ext(f['url'])
|
f['ext'] = determine_ext(f['url'])
|
||||||
|
|
||||||
|
if isinstance(field_preference, (list, tuple)):
|
||||||
|
return tuple(f.get(field) if f.get(field) is not None else -1 for field in field_preference)
|
||||||
|
|
||||||
preference = f.get('preference')
|
preference = f.get('preference')
|
||||||
if preference is None:
|
if preference is None:
|
||||||
proto = f.get('protocol')
|
proto = f.get('protocol')
|
||||||
|
|
Loading…
Reference in a new issue