mirror of
https://github.com/yt-dlp/yt-dlp
synced 2024-11-26 11:31:07 +01:00
parent
61882afdc5
commit
b5f94e4fa1
@ -472,32 +472,22 @@ class BrightcoveNewIE(AdobePassIE):
|
||||
def _parse_brightcove_metadata(self, json_data, video_id, headers={}):
|
||||
title = json_data['name'].strip()
|
||||
|
||||
num_drm_sources = 0
|
||||
formats, subtitles = [], {}
|
||||
sources = json_data.get('sources') or []
|
||||
for source in sources:
|
||||
container = source.get('container')
|
||||
ext = mimetype2ext(source.get('type'))
|
||||
src = source.get('src')
|
||||
skip_unplayable = not self.get_param('allow_unplayable_formats')
|
||||
# https://support.brightcove.com/playback-api-video-fields-reference#key_systems_object
|
||||
if skip_unplayable and (container == 'WVM' or source.get('key_systems')):
|
||||
num_drm_sources += 1
|
||||
continue
|
||||
elif ext == 'ism' and skip_unplayable:
|
||||
continue
|
||||
elif ext == 'm3u8' or container == 'M2TS':
|
||||
if ext == 'm3u8' or container == 'M2TS':
|
||||
if not src:
|
||||
continue
|
||||
f, subs = self._extract_m3u8_formats_and_subtitles(
|
||||
fmts, subs = self._extract_m3u8_formats_and_subtitles(
|
||||
src, video_id, 'mp4', 'm3u8_native', m3u8_id='hls', fatal=False)
|
||||
formats.extend(f)
|
||||
subtitles = self._merge_subtitles(subtitles, subs)
|
||||
elif ext == 'mpd':
|
||||
if not src:
|
||||
continue
|
||||
f, subs = self._extract_mpd_formats_and_subtitles(src, video_id, 'dash', fatal=False)
|
||||
formats.extend(f)
|
||||
fmts, subs = self._extract_mpd_formats_and_subtitles(src, video_id, 'dash', fatal=False)
|
||||
subtitles = self._merge_subtitles(subtitles, subs)
|
||||
else:
|
||||
streaming_src = source.get('streaming_src')
|
||||
@ -544,7 +534,13 @@ class BrightcoveNewIE(AdobePassIE):
|
||||
'play_path': stream_name,
|
||||
'format_id': build_format_id('rtmp'),
|
||||
})
|
||||
formats.append(f)
|
||||
fmts = [f]
|
||||
|
||||
# https://support.brightcove.com/playback-api-video-fields-reference#key_systems_object
|
||||
if container == 'WVM' or source.get('key_systems') or ext == 'ism':
|
||||
for f in fmts:
|
||||
f['has_drm'] = True
|
||||
formats.extend(fmts)
|
||||
|
||||
if not formats:
|
||||
errors = json_data.get('errors')
|
||||
@ -552,9 +548,6 @@ class BrightcoveNewIE(AdobePassIE):
|
||||
error = errors[0]
|
||||
self.raise_no_formats(
|
||||
error.get('message') or error.get('error_subcode') or error['error_code'], expected=True)
|
||||
elif (not self.get_param('allow_unplayable_formats')
|
||||
and sources and num_drm_sources == len(sources)):
|
||||
self.report_drm(video_id)
|
||||
|
||||
self._sort_formats(formats)
|
||||
|
||||
|
@ -1513,6 +1513,9 @@ from .toggle import (
|
||||
ToggleIE,
|
||||
MeWatchIE,
|
||||
)
|
||||
from .toggo import (
|
||||
ToggoIE,
|
||||
)
|
||||
from .tokentube import (
|
||||
TokentubeIE,
|
||||
TokentubeChannelIE
|
||||
|
73
yt_dlp/extractor/toggo.py
Normal file
73
yt_dlp/extractor/toggo.py
Normal file
@ -0,0 +1,73 @@
|
||||
from .common import InfoExtractor
|
||||
from ..utils import int_or_none, parse_qs
|
||||
|
||||
|
||||
class ToggoIE(InfoExtractor):
|
||||
IE_NAME = 'toggo'
|
||||
_VALID_URL = r'https?://(?:www\.)?toggo\.de/[\w-]+/folge/(?P<id>[\w-]+)'
|
||||
_TESTS = [{
|
||||
'url': 'https://www.toggo.de/weihnachtsmann--co-kg/folge/ein-geschenk-fuer-zwei',
|
||||
'info_dict': {
|
||||
'id': 'VEP2977',
|
||||
'ext': 'mp4',
|
||||
'title': 'Ein Geschenk für zwei',
|
||||
'display_id': 'ein-geschenk-fuer-zwei',
|
||||
'thumbnail': r're:^https?://.*\.(?:jpg|png)',
|
||||
'description': 'md5:b7715915bfa47824b4e4ad33fb5962f8',
|
||||
'release_timestamp': 1637259179,
|
||||
'series': 'Weihnachtsmann & Co. KG',
|
||||
'season': 'Weihnachtsmann & Co. KG',
|
||||
'season_number': 1,
|
||||
'season_id': 'VST118',
|
||||
'episode': 'Ein Geschenk für zwei',
|
||||
'episode_number': 7,
|
||||
'episode_id': 'VEP2977',
|
||||
'timestamp': 1581935960,
|
||||
'uploader_id': '6057955896001',
|
||||
'upload_date': '20200217',
|
||||
},
|
||||
'params': {'skip_download': True},
|
||||
}]
|
||||
|
||||
def _real_extract(self, url):
|
||||
display_id = self._match_id(url)
|
||||
data = self._download_json(
|
||||
f'https://production-n.toggo.de/api/assetstore/vod/asset/{display_id}', display_id)['data']
|
||||
|
||||
brightcove_id = next(
|
||||
x['value'] for x in data['custom_fields'] if x.get('key') == 'video-cloud-id')
|
||||
info = self._downloader.get_info_extractor('BrightcoveNew').extract(
|
||||
f'http://players.brightcove.net/6057955896001/default_default/index.html?videoId={brightcove_id}')
|
||||
|
||||
for f in info['formats']:
|
||||
if '/dash/live/cenc/' in f.get('fragment_base_url', ''):
|
||||
# Get hidden non-DRM format
|
||||
f['fragment_base_url'] = f['fragment_base_url'].replace('/cenc/', '/clear/')
|
||||
f['has_drm'] = False
|
||||
|
||||
if '/fairplay/' in f.get('manifest_url', ''):
|
||||
f['has_drm'] = True
|
||||
|
||||
thumbnails = [{
|
||||
'id': name,
|
||||
'url': url,
|
||||
'width': int_or_none(next(iter(parse_qs(url).get('width', [])), None)),
|
||||
} for name, url in (data.get('images') or {}).items()]
|
||||
|
||||
return {
|
||||
**info,
|
||||
'id': data.get('id'),
|
||||
'display_id': display_id,
|
||||
'title': data.get('title'),
|
||||
'language': data.get('language'),
|
||||
'thumbnails': thumbnails,
|
||||
'description': data.get('description'),
|
||||
'release_timestamp': data.get('earliest_start_date'),
|
||||
'series': data.get('series_title'),
|
||||
'season': data.get('season_title'),
|
||||
'season_number': data.get('season_no'),
|
||||
'season_id': data.get('season_id'),
|
||||
'episode': data.get('title'),
|
||||
'episode_number': data.get('episode_no'),
|
||||
'episode_id': data.get('id'),
|
||||
}
|
Loading…
Reference in New Issue
Block a user