mirror of
https://github.com/ytdl-org/youtube-dl
synced 2025-06-02 02:52:40 +09:00
Compare commits
6 Commits
f2f29732fd
...
b599342a67
Author | SHA1 | Date | |
---|---|---|---|
![]() |
b599342a67 | ||
![]() |
3eb8d22ddb | ||
![]() |
4e714f9df1 | ||
![]() |
c1ea7f5a24 | ||
![]() |
97c1053ba8 | ||
![]() |
13d2684263 |
@ -25,6 +25,7 @@ from ..utils import (
|
||||
get_element_by_class,
|
||||
int_or_none,
|
||||
js_to_json,
|
||||
parse_bitrate,
|
||||
parse_duration,
|
||||
parse_iso8601,
|
||||
strip_or_none,
|
||||
@ -647,9 +648,7 @@ class BBCIE(BBCCoUkIE):
|
||||
'skip_download': True,
|
||||
}
|
||||
}, {
|
||||
# article with single video embedded with data-playable containing XML playlist
|
||||
# with direct video links as progressiveDownloadUrl (for now these are extracted)
|
||||
# and playlist with f4m and m3u8 as streamingUrl
|
||||
# article with single video (formerly) embedded, now using SIMORGH_DATA JSON
|
||||
'url': 'http://www.bbc.com/turkce/haberler/2015/06/150615_telabyad_kentin_cogu',
|
||||
'info_dict': {
|
||||
'id': '150615_telabyad_kentin_cogu',
|
||||
@ -661,12 +660,13 @@ class BBCIE(BBCCoUkIE):
|
||||
},
|
||||
'params': {
|
||||
'skip_download': True,
|
||||
}
|
||||
},
|
||||
'skip': 'Video no longer embedded, 2021',
|
||||
}, {
|
||||
# single video embedded with data-playable containing XML playlists (regional section)
|
||||
# single video embedded, legacy media, in promo object of SIMORGH_DATA JSON
|
||||
'url': 'http://www.bbc.com/mundo/video_fotos/2015/06/150619_video_honduras_militares_hospitales_corrupcion_aw',
|
||||
'info_dict': {
|
||||
'id': '150619_video_honduras_militares_hospitales_corrupcion_aw',
|
||||
'id': '39275083',
|
||||
'ext': 'mp4',
|
||||
'title': 'Honduras militariza sus hospitales por nuevo escándalo de corrupción',
|
||||
'description': 'md5:1525f17448c4ee262b64b8f0c9ce66c8',
|
||||
@ -845,6 +845,18 @@ class BBCIE(BBCCoUkIE):
|
||||
'upload_date': '20190604',
|
||||
'categories': ['Psychology'],
|
||||
},
|
||||
}, {
|
||||
# BBC World Service etc: media nested in content object of SIMORGH_DATA JSON
|
||||
'url': 'http://www.bbc.co.uk/scotland/articles/cm49v4x1r9lo',
|
||||
'info_dict': {
|
||||
'id': 'p06p040v',
|
||||
'ext': 'mp4',
|
||||
'title': 'Five things ants can teach us about management',
|
||||
'description': 'They may be tiny, but us humans could learn a thing or two from ants.',
|
||||
'duration': 191,
|
||||
'thumbnail': r're:https?://.+/p06p0qzv.jpg',
|
||||
'upload_date': '20181016',
|
||||
},
|
||||
}]
|
||||
|
||||
@classmethod
|
||||
@ -1107,6 +1119,99 @@ class BBCIE(BBCCoUkIE):
|
||||
'subtitles': subtitles,
|
||||
}
|
||||
|
||||
# simorgh-based playlist (see https://github.com/bbc/simorgh)
|
||||
# JSON assigned to window.SIMORGH_DATA in a <script> element
|
||||
simorgh_data = self._parse_json(
|
||||
self._search_regex(
|
||||
r'window\.SIMORGH_DATA\s*=\s*(\{[^<]+})\s*</',
|
||||
webpage, 'simorgh playlist', default='{}'),
|
||||
playlist_id, fatal=False)
|
||||
# legacy media, video in promo object (eg, http://www.bbc.com/mundo/video_fotos/2015/06/150619_video_honduras_militares_hospitales_corrupcion_aw)
|
||||
playlist = try_get(simorgh_data, lambda x: x['pageData']['promo']['media']['playlist']) or []
|
||||
if playlist:
|
||||
media = simorgh_data['pageData']['promo']
|
||||
if media['media'].get('format') == 'video':
|
||||
media.update(media['media'])
|
||||
title = (dict_get(media.get('headlines') or {},
|
||||
('shortHeadline', 'headline'))
|
||||
or playlist_title),
|
||||
programme_id = media.get('id')
|
||||
if programme_id and title:
|
||||
formats = []
|
||||
keys = {'url', 'format', 'format_id', 'language', 'quality', 'tbr', 'resolution'}
|
||||
for format in playlist:
|
||||
if not (format.get('url') and format.get('format')):
|
||||
continue
|
||||
bitrate = format.pop('bitrate')
|
||||
format['tbr'] = int_or_none(bitrate, scale=1000) or parse_bitrate(bitrate)
|
||||
format['language'] = media.get('language')
|
||||
# format id: penultimate item from the url split on _ and .
|
||||
(fmt,) = re.split('[_.]', format['url'])[-2:][:1]
|
||||
format['format_id'] = '%s_%s' % (format['format'], fmt)
|
||||
# try to set resolution using any available data
|
||||
aspect_ratio = re.split(r'[xX:]', media.get('aspectRatio') or '')
|
||||
if len(aspect_ratio) != 2:
|
||||
aspect_ratio = None
|
||||
else:
|
||||
aspect_ratio = float_or_none(aspect_ratio[0], scale=aspect_ratio[1])
|
||||
# these may not be present, but try anyway
|
||||
width = int_or_none(format.get('width'))
|
||||
height = int_or_none(format.get('height'))
|
||||
if (not height) and aspect_ratio:
|
||||
height = int(width / aspect_ratio)
|
||||
elif (not width) and aspect_ratio:
|
||||
width = int(height * aspect_ratio)
|
||||
format['resolution'] = ('%dx%d' % (width, height) if width and height
|
||||
else dict_get(format, ('resolution', 'res'), default=fmt))
|
||||
format['quality'] = -1
|
||||
formats.append(dict((k, format[k]) for k in keys))
|
||||
self._sort_formats(formats)
|
||||
return {
|
||||
'id': programme_id,
|
||||
'title': title,
|
||||
'description': media.get('summary') or playlist_description,
|
||||
'formats': formats,
|
||||
'subtitles': None,
|
||||
'thumbnail': try_get(media, lambda x: x['image']['href']),
|
||||
'timestamp': int_or_none(media.get('timestamp'), scale=1000)
|
||||
}
|
||||
|
||||
# general case: media nested in content object
|
||||
# test: https://www.bbc.co.uk/scotland/articles/cm49v4x1r9lo
|
||||
if simorgh_data:
|
||||
|
||||
def extract_media_from_simorgh(model):
|
||||
if not isinstance(model, dict):
|
||||
return
|
||||
for block in model.get('blocks') or {}:
|
||||
if block.get('type') == 'aresMediaMetadata':
|
||||
vpid = try_get(block, lambda x: x['model']['versions'][0]['versionId'])
|
||||
if vpid:
|
||||
formats, subtitles = self._download_media_selector(vpid)
|
||||
self._sort_formats(formats)
|
||||
model = block['model']
|
||||
version = model['versions'][0]
|
||||
thumbnail = model.get('imageUrl')
|
||||
return {
|
||||
'id': vpid,
|
||||
'title': model.get('title') or 'unnamed clip',
|
||||
'description': dict_get(model.get('synopses') or {}, ('long', 'medium', 'short')),
|
||||
'duration': (int_or_none(version.get('duration'))
|
||||
or parse_duration(version.get('durationISO8601'))),
|
||||
'timestamp': version.get('availableFrom'),
|
||||
'thumbnail': urljoin(url, thumbnail.replace('$recipe', 'raw')) if thumbnail else None,
|
||||
'formats': formats,
|
||||
'subtitles': subtitles,
|
||||
}
|
||||
else:
|
||||
entry = extract_media_from_simorgh(block.get('model'))
|
||||
if entry:
|
||||
return entry
|
||||
|
||||
playlist = extract_media_from_simorgh(try_get(simorgh_data, lambda x: x['pageData']['content']['model']))
|
||||
if playlist:
|
||||
return playlist
|
||||
|
||||
preload_state = self._parse_json(self._search_regex(
|
||||
r'window\.__PRELOADED_STATE__\s*=\s*({.+?});', webpage,
|
||||
'preload state', default='{}'), playlist_id, fatal=False)
|
||||
|
@ -32,7 +32,7 @@ class BokeCCBaseIE(InfoExtractor):
|
||||
|
||||
|
||||
class BokeCCIE(BokeCCBaseIE):
|
||||
_IE_DESC = 'CC视频'
|
||||
IE_DESC = 'CC视频'
|
||||
_VALID_URL = r'https?://union\.bokecc\.com/playvideo\.bo\?(?P<query>.*)'
|
||||
|
||||
_TESTS = [{
|
||||
|
@ -9,7 +9,7 @@ from ..utils import (
|
||||
|
||||
|
||||
class CloudyIE(InfoExtractor):
|
||||
_IE_DESC = 'cloudy.ec'
|
||||
IE_DESC = 'cloudy.ec'
|
||||
_VALID_URL = r'https?://(?:www\.)?cloudy\.ec/(?:v/|embed\.php\?.*?\bid=)(?P<id>[A-Za-z0-9]+)'
|
||||
_TESTS = [{
|
||||
'url': 'https://www.cloudy.ec/v/af511e2527aac',
|
||||
|
@ -422,6 +422,8 @@ class InfoExtractor(object):
|
||||
_GEO_COUNTRIES = None
|
||||
_GEO_IP_BLOCKS = None
|
||||
_WORKING = True
|
||||
# supply this in public subclasses: used in supported sites list, etc
|
||||
# IE_DESC = 'short description of IE'
|
||||
|
||||
def __init__(self, downloader=None):
|
||||
"""Constructor. Receives an optional downloader."""
|
||||
|
@ -35,15 +35,6 @@ from ..utils import (
|
||||
|
||||
class ITVBaseIE(InfoExtractor):
|
||||
|
||||
def _search_nextjs_data(self, webpage, video_id, **kw):
|
||||
transform_source = kw.pop('transform_source', None)
|
||||
fatal = kw.pop('fatal', True)
|
||||
return self._parse_json(
|
||||
self._search_regex(
|
||||
r'''<script\b[^>]+\bid=('|")__NEXT_DATA__\1[^>]*>(?P<js>[^<]+)</script>''',
|
||||
webpage, 'next.js data', group='js', fatal=fatal, **kw),
|
||||
video_id, transform_source=transform_source, fatal=fatal)
|
||||
|
||||
def __handle_request_webpage_error(self, err, video_id=None, errnote=None, fatal=True):
|
||||
if errnote is False:
|
||||
return False
|
||||
@ -109,7 +100,9 @@ class ITVBaseIE(InfoExtractor):
|
||||
|
||||
class ITVIE(ITVBaseIE):
|
||||
_VALID_URL = r'https?://(?:www\.)?itv\.com/(?:(?P<w>watch)|hub)/[^/]+/(?(w)[\w-]+/)(?P<id>\w+)'
|
||||
_IE_DESC = 'ITVX'
|
||||
IE_DESC = 'ITVX'
|
||||
_WORKING = False
|
||||
|
||||
_TESTS = [{
|
||||
'note': 'Hub URLs redirect to ITVX',
|
||||
'url': 'https://www.itv.com/hub/liar/2a4547a0012',
|
||||
@ -270,7 +263,7 @@ class ITVIE(ITVBaseIE):
|
||||
'ext': determine_ext(href, 'vtt'),
|
||||
})
|
||||
|
||||
next_data = self._search_nextjs_data(webpage, video_id, fatal=False, default='{}')
|
||||
next_data = self._search_nextjs_data(webpage, video_id, fatal=False, default={})
|
||||
video_data.update(traverse_obj(next_data, ('props', 'pageProps', ('title', 'episode')), expected_type=dict)[0] or {})
|
||||
title = traverse_obj(video_data, 'headerTitle', 'episodeTitle')
|
||||
info = self._og_extract(webpage, require_title=not title)
|
||||
@ -323,7 +316,7 @@ class ITVIE(ITVBaseIE):
|
||||
|
||||
class ITVBTCCIE(ITVBaseIE):
|
||||
_VALID_URL = r'https?://(?:www\.)?itv\.com/(?!(?:watch|hub)/)(?:[^/]+/)+(?P<id>[^/?#&]+)'
|
||||
_IE_DESC = 'ITV articles: News, British Touring Car Championship'
|
||||
IE_DESC = 'ITV articles: News, British Touring Car Championship'
|
||||
_TESTS = [{
|
||||
'note': 'British Touring Car Championship',
|
||||
'url': 'https://www.itv.com/btcc/articles/btcc-2018-all-the-action-from-brands-hatch',
|
||||
|
@ -47,7 +47,7 @@ class SenateISVPIE(InfoExtractor):
|
||||
['vetaff', '76462', 'http://vetaff-f.akamaihd.net'],
|
||||
['arch', '', 'http://ussenate-f.akamaihd.net/']
|
||||
]
|
||||
_IE_NAME = 'senate.gov'
|
||||
IE_NAME = 'senate.gov'
|
||||
_VALID_URL = r'https?://(?:www\.)?senate\.gov/isvp/?\?(?P<qs>.+)'
|
||||
_TESTS = [{
|
||||
'url': 'http://www.senate.gov/isvp/?comm=judiciary&type=live&stt=&filename=judiciary031715&auto_play=false&wmode=transparent&poster=http%3A%2F%2Fwww.judiciary.senate.gov%2Fthemes%2Fjudiciary%2Fimages%2Fvideo-poster-flash-fit.png',
|
||||
|
@ -686,6 +686,8 @@ class JSInterpreter(object):
|
||||
raise self.Exception('Cannot get index {idx!r:.100}'.format(**locals()), expr=repr(obj), cause=e)
|
||||
|
||||
def _dump(self, obj, namespace):
|
||||
if obj is JS_Undefined:
|
||||
return 'undefined'
|
||||
try:
|
||||
return json.dumps(obj)
|
||||
except TypeError:
|
||||
|
Loading…
x
Reference in New Issue
Block a user