projects
/
youtube-dl
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
b524a00
)
[extractor/common] Add ability to specify custom field preference for `_sort_formats`
author
Sergey M․
<dstftw@gmail.com>
Mon, 20 Apr 2015 15:13:31 +0000
(21:13 +0600)
committer
Sergey M․
<dstftw@gmail.com>
Mon, 20 Apr 2015 15:13:31 +0000
(21:13 +0600)
youtube_dl/extractor/common.py
patch
|
blob
|
history
diff --git
a/youtube_dl/extractor/common.py
b/youtube_dl/extractor/common.py
index 7757bf9502169b79e498a7f26ba0b227b44efe91..71230323cda11cdcd4200c849db3ce56cd5e2f5e 100644
(file)
--- a/
youtube_dl/extractor/common.py
+++ b/
youtube_dl/extractor/common.py
@@
-708,7
+708,7
@@
class InfoExtractor(object):
return self._html_search_meta('twitter:player', html,
'twitter card player')
return self._html_search_meta('twitter:player', html,
'twitter card player')
- def _sort_formats(self, formats):
+ def _sort_formats(self, formats
, field_preference=None
):
if not formats:
raise ExtractorError('No video formats found')
if not formats:
raise ExtractorError('No video formats found')
@@
-718,6
+718,9
@@
class InfoExtractor(object):
if not f.get('ext') and 'url' in f:
f['ext'] = determine_ext(f['url'])
if not f.get('ext') and 'url' in f:
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')
if preference is None:
proto = f.get('protocol')
preference = f.get('preference')
if preference is None:
proto = f.get('protocol')