mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-16 13:23:20 +00:00
[mit] Add support for multiple formats
This commit is contained in:
parent
55e663a8d7
commit
719d3927d7
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
|
compat_str,
|
||||||
clean_html,
|
clean_html,
|
||||||
get_element_by_id,
|
get_element_by_id,
|
||||||
)
|
)
|
||||||
|
@ -33,8 +34,18 @@ def _real_extract(self, url):
|
||||||
raw_page, u'base url')
|
raw_page, u'base url')
|
||||||
formats_json = self._search_regex(r'bitrates: (\[.+?\])', raw_page,
|
formats_json = self._search_regex(r'bitrates: (\[.+?\])', raw_page,
|
||||||
u'video formats')
|
u'video formats')
|
||||||
formats = json.loads(formats_json)
|
formats_mit = json.loads(formats_json)
|
||||||
formats = sorted(formats, key=lambda f: f['bitrate'])
|
formats = [
|
||||||
|
{
|
||||||
|
'format_id': f['label'],
|
||||||
|
'url': base_url + f['url'].partition(':')[2],
|
||||||
|
'ext': f['url'].partition(':')[0],
|
||||||
|
'format': f['label'],
|
||||||
|
'width': f['width'],
|
||||||
|
'vbr': f['bitrate'],
|
||||||
|
}
|
||||||
|
for f in formats_mit
|
||||||
|
]
|
||||||
|
|
||||||
title = get_element_by_id('edit-title', clean_page)
|
title = get_element_by_id('edit-title', clean_page)
|
||||||
description = clean_html(get_element_by_id('edit-description', clean_page))
|
description = clean_html(get_element_by_id('edit-description', clean_page))
|
||||||
|
@ -43,8 +54,7 @@ def _real_extract(self, url):
|
||||||
|
|
||||||
return {'id': video_id,
|
return {'id': video_id,
|
||||||
'title': title,
|
'title': title,
|
||||||
'url': base_url + formats[-1]['url'].replace('mp4:', ''),
|
'formats': formats,
|
||||||
'ext': 'mp4',
|
|
||||||
'description': description,
|
'description': description,
|
||||||
'thumbnail': thumbnail,
|
'thumbnail': thumbnail,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue