mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-06-18 15:55:30 +02:00
parent
a8bf0011bd
commit
97ddfefeb4
@ -1,59 +1,57 @@
|
|||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
determine_ext,
|
UnsupportedError,
|
||||||
get_element_by_attribute,
|
clean_html,
|
||||||
int_or_none,
|
int_or_none,
|
||||||
js_to_json,
|
parse_duration,
|
||||||
mimetype2ext,
|
parse_qs,
|
||||||
update_url_query,
|
str_or_none,
|
||||||
|
update_url,
|
||||||
)
|
)
|
||||||
|
from ..utils.traversal import find_element, traverse_obj
|
||||||
|
|
||||||
|
|
||||||
class NobelPrizeIE(InfoExtractor):
|
class NobelPrizeIE(InfoExtractor):
|
||||||
_WORKING = False
|
_VALID_URL = r'https?://(?:(?:mediaplayer|www)\.)?nobelprize\.org/mediaplayer/'
|
||||||
_VALID_URL = r'https?://(?:www\.)?nobelprize\.org/mediaplayer.*?\bid=(?P<id>\d+)'
|
_TESTS = [{
|
||||||
_TEST = {
|
'url': 'https://www.nobelprize.org/mediaplayer/?id=2636',
|
||||||
'url': 'http://www.nobelprize.org/mediaplayer/?id=2636',
|
|
||||||
'md5': '04c81e5714bb36cc4e2232fee1d8157f',
|
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '2636',
|
'id': '2636',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': 'Announcement of the 2016 Nobel Prize in Physics',
|
'title': 'Announcement of the 2016 Nobel Prize in Physics',
|
||||||
'description': 'md5:05beba57f4f5a4bbd4cf2ef28fcff739',
|
'description': 'md5:1a2d8a6ca80c88fb3b9a326e0b0e8e43',
|
||||||
|
'duration': 1560.0,
|
||||||
|
'thumbnail': r're:https?://www\.nobelprize\.org/images/.+\.jpg',
|
||||||
|
'timestamp': 1504883793,
|
||||||
|
'upload_date': '20170908',
|
||||||
},
|
},
|
||||||
}
|
}, {
|
||||||
|
'url': 'https://mediaplayer.nobelprize.org/mediaplayer/?qid=12693',
|
||||||
|
'info_dict': {
|
||||||
|
'id': '12693',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'title': 'Nobel Lecture by Peter Higgs',
|
||||||
|
'description': 'md5:9b12e275dbe3a8138484e70e00673a05',
|
||||||
|
'duration': 1800.0,
|
||||||
|
'thumbnail': r're:https?://www\.nobelprize\.org/images/.+\.jpg',
|
||||||
|
'timestamp': 1504883793,
|
||||||
|
'upload_date': '20170908',
|
||||||
|
},
|
||||||
|
}]
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
video_id = traverse_obj(parse_qs(url), (
|
||||||
webpage = self._download_webpage(url, video_id)
|
('id', 'qid'), -1, {int_or_none}, {str_or_none}, any))
|
||||||
media = self._parse_json(self._search_regex(
|
if not video_id:
|
||||||
r'(?s)var\s*config\s*=\s*({.+?});', webpage,
|
raise UnsupportedError(url)
|
||||||
'config'), video_id, js_to_json)['media']
|
webpage = self._download_webpage(
|
||||||
title = media['title']
|
update_url(url, netloc='mediaplayer.nobelprize.org'), video_id)
|
||||||
|
|
||||||
formats = []
|
|
||||||
for source in media.get('source', []):
|
|
||||||
source_src = source.get('src')
|
|
||||||
if not source_src:
|
|
||||||
continue
|
|
||||||
ext = mimetype2ext(source.get('type')) or determine_ext(source_src)
|
|
||||||
if ext == 'm3u8':
|
|
||||||
formats.extend(self._extract_m3u8_formats(
|
|
||||||
source_src, video_id, 'mp4', 'm3u8_native',
|
|
||||||
m3u8_id='hls', fatal=False))
|
|
||||||
elif ext == 'f4m':
|
|
||||||
formats.extend(self._extract_f4m_formats(
|
|
||||||
update_url_query(source_src, {'hdcore': '3.7.0'}),
|
|
||||||
video_id, f4m_id='hds', fatal=False))
|
|
||||||
else:
|
|
||||||
formats.append({
|
|
||||||
'url': source_src,
|
|
||||||
})
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
**self._search_json_ld(webpage, video_id),
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'title': title,
|
'title': self._html_search_meta('caption', webpage),
|
||||||
'description': get_element_by_attribute('itemprop', 'description', webpage),
|
'description': traverse_obj(webpage, (
|
||||||
'duration': int_or_none(media.get('duration')),
|
{find_element(tag='span', attr='itemprop', value='description')}, {clean_html})),
|
||||||
'formats': formats,
|
'duration': parse_duration(self._html_search_meta('duration', webpage)),
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user