mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-01-07 17:16:08 +00:00
[condenast] Allow multiple formats, and sort centralized
This commit is contained in:
parent
6e249060cf
commit
d0da491e1e
|
@ -79,19 +79,21 @@ class CondeNastIE(InfoExtractor):
|
||||||
video_info = self._search_regex(r'var video = ({.+?});', info_page, 'video info')
|
video_info = self._search_regex(r'var video = ({.+?});', info_page, 'video info')
|
||||||
video_info = json.loads(video_info)
|
video_info = json.loads(video_info)
|
||||||
|
|
||||||
def _formats_sort_key(f):
|
formats = [{
|
||||||
type_ord = 1 if f['type'] == 'video/mp4' else 0
|
'format_id': '%s-%s' % (fdata['type'].split('/')[-1], fdata['quality']),
|
||||||
quality_ord = 1 if f['quality'] == 'high' else 0
|
'url': fdata['src'],
|
||||||
return (quality_ord, type_ord)
|
'ext': fdata['type'].split('/')[-1],
|
||||||
best_format = sorted(video_info['sources'][0], key=_formats_sort_key)[-1]
|
'quality': 1 if fdata['quality'] == 'high' else 0,
|
||||||
|
} for fdata in video_info['sources'][0]]
|
||||||
|
self._sort_formats(formats)
|
||||||
|
|
||||||
return {'id': video_id,
|
return {
|
||||||
'url': best_format['src'],
|
'id': video_id,
|
||||||
'ext': best_format['type'].split('/')[-1],
|
'formats': formats,
|
||||||
'title': video_info['title'],
|
'title': video_info['title'],
|
||||||
'thumbnail': video_info['poster_frame'],
|
'thumbnail': video_info['poster_frame'],
|
||||||
'description': description,
|
'description': description,
|
||||||
}
|
}
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
mobj = re.match(self._VALID_URL, url)
|
mobj = re.match(self._VALID_URL, url)
|
||||||
|
|
Loading…
Reference in a new issue