[ie/dropbox] Fix password-protected video extraction (#11636)
[yt-dlp3.git] / yt_dlp / extractor / toggo.py
blob1ddec493d8142affb83e8384a69e7de62c4765f9
1 from .common import InfoExtractor
2 from ..utils import int_or_none, parse_qs
5 class ToggoIE(InfoExtractor):
6 IE_NAME = 'toggo'
7 _VALID_URL = r'https?://(?:www\.)?toggo\.de/(?:toggolino/)?[^/?#]+/(?:folge|video)/(?P<id>[^/?#]+)'
8 _TESTS = [{
9 'url': 'https://www.toggo.de/weihnachtsmann--co-kg/folge/ein-geschenk-fuer-zwei',
10 'info_dict': {
11 'id': 'VEP2977',
12 'ext': 'mp4',
13 'title': 'Ein Geschenk für zwei',
14 'display_id': 'ein-geschenk-fuer-zwei',
15 'thumbnail': r're:^https?://.*\.(?:jpg|png)',
16 'description': 'md5:b7715915bfa47824b4e4ad33fb5962f8',
17 'release_timestamp': 1637259179,
18 'series': 'Weihnachtsmann & Co. KG',
19 'season': 'Weihnachtsmann & Co. KG',
20 'season_number': 1,
21 'season_id': 'VST118',
22 'episode': 'Ein Geschenk für zwei',
23 'episode_number': 7,
24 'episode_id': 'VEP2977',
25 'timestamp': 1581935960,
26 'uploader_id': '6057955896001',
27 'upload_date': '20200217',
29 'params': {'skip_download': True},
30 }, {
31 'url': 'https://www.toggo.de/grizzy--die-lemminge/folge/ab-durch-die-wand-vogelfrei-rock\'n\'lemming',
32 'only_matching': True,
33 }, {
34 'url': 'https://www.toggo.de/toggolino/paw-patrol/folge/der-wetter-zeppelin-der-chili-kochwettbewerb',
35 'only_matching': True,
36 }, {
37 'url': 'https://www.toggo.de/toggolino/paw-patrol/video/paw-patrol-rettung-im-anflug',
38 'only_matching': True,
41 def _real_extract(self, url):
42 display_id = self._match_id(url)
43 data = self._download_json(
44 f'https://production-n.toggo.de/api/assetstore/vod/asset/{display_id}', display_id)['data']
46 brightcove_id = next(
47 x['value'] for x in data['custom_fields'] if x.get('key') == 'video-cloud-id')
48 info = self._downloader.get_info_extractor('BrightcoveNew').extract(
49 f'http://players.brightcove.net/6057955896001/default_default/index.html?videoId={brightcove_id}')
51 for f in info['formats']:
52 if '/dash/live/cenc/' in f.get('fragment_base_url', ''):
53 # Get hidden non-DRM format
54 f['fragment_base_url'] = f['fragment_base_url'].replace('/cenc/', '/clear/')
55 f['has_drm'] = False
57 if '/fairplay/' in f.get('manifest_url', ''):
58 f['has_drm'] = True
60 thumbnails = [{
61 'id': name,
62 'url': url,
63 'width': int_or_none(next(iter(parse_qs(url).get('width', [])), None)),
64 } for name, url in (data.get('images') or {}).items()]
66 return {
67 **info,
68 'id': data.get('id'),
69 'display_id': display_id,
70 'title': data.get('title'),
71 'language': data.get('language'),
72 'thumbnails': thumbnails,
73 'description': data.get('description'),
74 'release_timestamp': data.get('earliest_start_date'),
75 'series': data.get('series_title'),
76 'season': data.get('season_title'),
77 'season_number': data.get('season_no'),
78 'season_id': data.get('season_id'),
79 'episode': data.get('title'),
80 'episode_number': data.get('episode_no'),
81 'episode_id': data.get('id'),