]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/orf.py
526e9acaf376990fa5179a2638bddd857bf090ab
[yt-dlp.git] / yt_dlp / extractor / orf.py
1 import base64
2 import functools
3 import re
4
5 from .common import InfoExtractor
6 from ..networking import HEADRequest
7 from ..utils import (
8 InAdvancePagedList,
9 clean_html,
10 determine_ext,
11 float_or_none,
12 int_or_none,
13 join_nonempty,
14 make_archive_id,
15 mimetype2ext,
16 orderedSet,
17 remove_end,
18 smuggle_url,
19 strip_jsonp,
20 try_call,
21 unescapeHTML,
22 unified_strdate,
23 unsmuggle_url,
24 url_or_none,
25 )
26 from ..utils.traversal import traverse_obj
27
28
29 class ORFTVthekIE(InfoExtractor):
30 IE_NAME = 'orf:tvthek'
31 IE_DESC = 'ORF TVthek'
32 _VALID_URL = r'(?P<url>https?://tvthek\.orf\.at/(?:(?:[^/]+/){2}){1,2}(?P<id>\d+))(/[^/]+/(?P<vid>\d+))?(?:$|[?#])'
33
34 _TESTS = [{
35 'url': 'https://tvthek.orf.at/profile/ZIB-2/1211/ZIB-2/14121079',
36 'info_dict': {
37 'id': '14121079',
38 },
39 'playlist_count': 11,
40 'params': {'noplaylist': True}
41 }, {
42 'url': 'https://tvthek.orf.at/profile/ZIB-2/1211/ZIB-2/14121079/Umfrage-Welches-Tier-ist-Sebastian-Kurz/15083150',
43 'info_dict': {
44 'id': '14121079',
45 },
46 'playlist_count': 1,
47 'params': {'playlist_items': '5'}
48 }, {
49 'url': 'https://tvthek.orf.at/profile/ZIB-2/1211/ZIB-2/14121079/Umfrage-Welches-Tier-ist-Sebastian-Kurz/15083150',
50 'info_dict': {
51 'id': '14121079',
52 },
53 'playlist': [{
54 'info_dict': {
55 'id': '15083150',
56 'ext': 'mp4',
57 'description': 'md5:7be1c485425f5f255a5e4e4815e77d04',
58 'thumbnail': 'https://api-tvthek.orf.at/uploads/media/segments/0130/59/824271ea35cd8931a0fb08ab316a5b0a1562342c.jpeg',
59 'title': 'Umfrage: Welches Tier ist Sebastian Kurz?',
60 }
61 }],
62 'playlist_count': 1,
63 'params': {'noplaylist': True, 'skip_download': 'm3u8'}
64 }, {
65 'url': 'http://tvthek.orf.at/program/Aufgetischt/2745173/Aufgetischt-Mit-der-Steirischen-Tafelrunde/8891389',
66 'playlist': [{
67 'md5': '2942210346ed779588f428a92db88712',
68 'info_dict': {
69 'id': '8896777',
70 'ext': 'mp4',
71 'title': 'Aufgetischt: Mit der Steirischen Tafelrunde',
72 'description': 'md5:c1272f0245537812d4e36419c207b67d',
73 'duration': 2668,
74 'upload_date': '20141208',
75 },
76 }],
77 'skip': 'Blocked outside of Austria / Germany',
78 }, {
79 'url': 'http://tvthek.orf.at/topic/Im-Wandel-der-Zeit/8002126/Best-of-Ingrid-Thurnher/7982256',
80 'info_dict': {
81 'id': '7982259',
82 'ext': 'mp4',
83 'title': 'Best of Ingrid Thurnher',
84 'upload_date': '20140527',
85 'description': 'Viele Jahre war Ingrid Thurnher das "Gesicht" der ZIB 2. Vor ihrem Wechsel zur ZIB 2 im Jahr 1995 moderierte sie unter anderem "Land und Leute", "Österreich-Bild" und "Niederösterreich heute".',
86 },
87 'params': {
88 'skip_download': True, # rtsp downloads
89 },
90 'skip': 'Blocked outside of Austria / Germany',
91 }, {
92 'url': 'http://tvthek.orf.at/topic/Fluechtlingskrise/10463081/Heimat-Fremde-Heimat/13879132/Senioren-betreuen-Migrantenkinder/13879141',
93 'only_matching': True,
94 }, {
95 'url': 'http://tvthek.orf.at/profile/Universum/35429',
96 'only_matching': True,
97 }]
98
99 def _pagefunc(self, url, data_jsb, n, *, image=None):
100 sd = data_jsb[n]
101 video_id, title = str(sd['id']), sd['title']
102 formats = []
103 for fd in sd['sources']:
104 src = url_or_none(fd.get('src'))
105 if not src:
106 continue
107 format_id = join_nonempty('delivery', 'quality', 'quality_string', from_dict=fd)
108 ext = determine_ext(src)
109 if ext == 'm3u8':
110 m3u8_formats = self._extract_m3u8_formats(
111 src, video_id, 'mp4', m3u8_id=format_id, fatal=False, note=f'Downloading {format_id} m3u8 manifest')
112 if any('/geoprotection' in f['url'] for f in m3u8_formats):
113 self.raise_geo_restricted()
114 formats.extend(m3u8_formats)
115 elif ext == 'f4m':
116 formats.extend(self._extract_f4m_formats(
117 src, video_id, f4m_id=format_id, fatal=False))
118 elif ext == 'mpd':
119 formats.extend(self._extract_mpd_formats(
120 src, video_id, mpd_id=format_id, fatal=False, note=f'Downloading {format_id} mpd manifest'))
121 else:
122 formats.append({
123 'format_id': format_id,
124 'url': src,
125 'protocol': fd.get('protocol'),
126 })
127
128 # Check for geoblocking.
129 # There is a property is_geoprotection, but that's always false
130 geo_str = sd.get('geoprotection_string')
131 http_url = next(
132 (f['url'] for f in formats if re.match(r'^https?://.*\.mp4$', f['url'])),
133 None) if geo_str else None
134 if http_url:
135 self._request_webpage(
136 HEADRequest(http_url), video_id, fatal=False, note='Testing for geoblocking',
137 errnote=f'This video seems to be blocked outside of {geo_str}. You may want to try the streaming-* formats')
138
139 subtitles = {}
140 for sub in sd.get('subtitles', []):
141 sub_src = sub.get('src')
142 if not sub_src:
143 continue
144 subtitles.setdefault(sub.get('lang', 'de-AT'), []).append({
145 'url': sub_src,
146 })
147
148 upload_date = unified_strdate(sd.get('created_date'))
149
150 thumbnails = []
151 preview = sd.get('preview_image_url')
152 if preview:
153 thumbnails.append({
154 'id': 'preview',
155 'url': preview,
156 'preference': 0,
157 })
158 image = sd.get('image_full_url') or image
159 if image:
160 thumbnails.append({
161 'id': 'full',
162 'url': image,
163 'preference': 1,
164 })
165
166 yield {
167 'id': video_id,
168 'title': title,
169 'webpage_url': smuggle_url(f'{url}/part/{video_id}', {'force_noplaylist': True}),
170 'formats': formats,
171 'subtitles': subtitles,
172 'description': sd.get('description'),
173 'duration': int_or_none(sd.get('duration_in_seconds')),
174 'upload_date': upload_date,
175 'thumbnails': thumbnails,
176 }
177
178 def _real_extract(self, url):
179 url, smuggled_data = unsmuggle_url(url)
180 playlist_id, video_id, base_url = self._match_valid_url(url).group('id', 'vid', 'url')
181 webpage = self._download_webpage(url, playlist_id)
182
183 data_jsb = self._parse_json(
184 self._search_regex(
185 r'<div[^>]+class=(["\']).*?VideoPlaylist.*?\1[^>]+data-jsb=(["\'])(?P<json>.+?)\2',
186 webpage, 'playlist', group='json'),
187 playlist_id, transform_source=unescapeHTML)['playlist']['videos']
188
189 if not self._yes_playlist(playlist_id, video_id, smuggled_data):
190 data_jsb = [sd for sd in data_jsb if str(sd.get('id')) == video_id]
191
192 playlist_count = len(data_jsb)
193 image = self._og_search_thumbnail(webpage) if playlist_count == 1 else None
194
195 page_func = functools.partial(self._pagefunc, base_url, data_jsb, image=image)
196 return {
197 '_type': 'playlist',
198 'entries': InAdvancePagedList(page_func, playlist_count, 1),
199 'id': playlist_id,
200 }
201
202
203 class ORFRadioIE(InfoExtractor):
204 IE_NAME = 'orf:radio'
205
206 STATION_INFO = {
207 'fm4': ('fm4', 'fm4', 'orffm4'),
208 'noe': ('noe', 'oe2n', 'orfnoe'),
209 'wien': ('wie', 'oe2w', 'orfwie'),
210 'burgenland': ('bgl', 'oe2b', 'orfbgl'),
211 'ooe': ('ooe', 'oe2o', 'orfooe'),
212 'steiermark': ('stm', 'oe2st', 'orfstm'),
213 'kaernten': ('ktn', 'oe2k', 'orfktn'),
214 'salzburg': ('sbg', 'oe2s', 'orfsbg'),
215 'tirol': ('tir', 'oe2t', 'orftir'),
216 'vorarlberg': ('vbg', 'oe2v', 'orfvbg'),
217 'oe3': ('oe3', 'oe3', 'orfoe3'),
218 'oe1': ('oe1', 'oe1', 'orfoe1'),
219 }
220 _STATION_RE = '|'.join(map(re.escape, STATION_INFO.keys()))
221
222 _VALID_URL = rf'''(?x)
223 https?://(?:
224 (?P<station>{_STATION_RE})\.orf\.at/player|
225 radiothek\.orf\.at/(?P<station2>{_STATION_RE})
226 )/(?P<date>[0-9]+)/(?P<show>\w+)'''
227
228 _TESTS = [{
229 'url': 'https://radiothek.orf.at/ooe/20220801/OGMO',
230 'info_dict': {
231 'id': 'OGMO',
232 'title': 'Guten Morgen OÖ',
233 'description': 'md5:a3f6083399ef92b8cbe2d421b180835a',
234 },
235 'playlist': [{
236 'md5': 'f33147d954a326e338ea52572c2810e8',
237 'info_dict': {
238 'id': '2022-08-01_0459_tl_66_7DaysMon1_319062',
239 'ext': 'mp3',
240 'title': 'Guten Morgen OÖ',
241 'upload_date': '20220801',
242 'duration': 18000,
243 'timestamp': 1659322789,
244 'description': 'md5:a3f6083399ef92b8cbe2d421b180835a',
245 }
246 }]
247 }, {
248 'url': 'https://ooe.orf.at/player/20220801/OGMO',
249 'info_dict': {
250 'id': 'OGMO',
251 'title': 'Guten Morgen OÖ',
252 'description': 'md5:a3f6083399ef92b8cbe2d421b180835a',
253 },
254 'playlist': [{
255 'md5': 'f33147d954a326e338ea52572c2810e8',
256 'info_dict': {
257 'id': '2022-08-01_0459_tl_66_7DaysMon1_319062',
258 'ext': 'mp3',
259 'title': 'Guten Morgen OÖ',
260 'upload_date': '20220801',
261 'duration': 18000,
262 'timestamp': 1659322789,
263 'description': 'md5:a3f6083399ef92b8cbe2d421b180835a',
264 }
265 }]
266 }, {
267 'url': 'http://fm4.orf.at/player/20170107/4CC',
268 'only_matching': True,
269 }, {
270 'url': 'https://noe.orf.at/player/20200423/NGM',
271 'only_matching': True,
272 }, {
273 'url': 'https://wien.orf.at/player/20200423/WGUM',
274 'only_matching': True,
275 }, {
276 'url': 'https://burgenland.orf.at/player/20200423/BGM',
277 'only_matching': True,
278 }, {
279 'url': 'https://steiermark.orf.at/player/20200423/STGMS',
280 'only_matching': True,
281 }, {
282 'url': 'https://kaernten.orf.at/player/20200423/KGUMO',
283 'only_matching': True,
284 }, {
285 'url': 'https://salzburg.orf.at/player/20200423/SGUM',
286 'only_matching': True,
287 }, {
288 'url': 'https://tirol.orf.at/player/20200423/TGUMO',
289 'only_matching': True,
290 }, {
291 'url': 'https://vorarlberg.orf.at/player/20200423/VGUM',
292 'only_matching': True,
293 }, {
294 'url': 'https://oe3.orf.at/player/20200424/3WEK',
295 'only_matching': True,
296 }, {
297 'url': 'http://oe1.orf.at/player/20170108/456544',
298 'md5': '34d8a6e67ea888293741c86a099b745b',
299 'info_dict': {
300 'id': '2017-01-08_0759_tl_51_7DaysSun6_256141',
301 'ext': 'mp3',
302 'title': 'Morgenjournal',
303 'duration': 609,
304 'timestamp': 1483858796,
305 'upload_date': '20170108',
306 },
307 'skip': 'Shows from ORF radios are only available for 7 days.'
308 }]
309
310 def _entries(self, data, station):
311 _, loop_station, old_ie = self.STATION_INFO[station]
312 for info in data['streams']:
313 item_id = info.get('loopStreamId')
314 if not item_id:
315 continue
316 video_id = item_id.replace('.mp3', '')
317 yield {
318 'id': video_id,
319 'ext': 'mp3',
320 'url': f'https://loopstream01.apa.at/?channel={loop_station}&id={item_id}',
321 '_old_archive_ids': [make_archive_id(old_ie, video_id)],
322 'title': data.get('title'),
323 'description': clean_html(data.get('subtitle')),
324 'duration': try_call(lambda: (info['end'] - info['start']) / 1000),
325 'timestamp': int_or_none(info.get('start'), scale=1000),
326 'series': data.get('programTitle'),
327 }
328
329 def _real_extract(self, url):
330 station, station2, show_date, show_id = self._match_valid_url(url).group('station', 'station2', 'date', 'show')
331 api_station, _, _ = self.STATION_INFO[station or station2]
332 data = self._download_json(
333 f'http://audioapi.orf.at/{api_station}/api/json/current/broadcast/{show_id}/{show_date}', show_id)
334
335 return self.playlist_result(
336 self._entries(data, station or station2), show_id, data.get('title'), clean_html(data.get('subtitle')))
337
338
339 class ORFPodcastIE(InfoExtractor):
340 IE_NAME = 'orf:podcast'
341 _STATION_RE = '|'.join(map(re.escape, (
342 'bgl', 'fm4', 'ktn', 'noe', 'oe1', 'oe3',
343 'ooe', 'sbg', 'stm', 'tir', 'tv', 'vbg', 'wie')))
344 _VALID_URL = rf'https?://sound\.orf\.at/podcast/(?P<station>{_STATION_RE})/(?P<show>[\w-]+)/(?P<id>[\w-]+)'
345 _TESTS = [{
346 'url': 'https://sound.orf.at/podcast/oe3/fruehstueck-bei-mir/nicolas-stockhammer-15102023',
347 'md5': '526a5700e03d271a1505386a8721ab9b',
348 'info_dict': {
349 'id': 'nicolas-stockhammer-15102023',
350 'ext': 'mp3',
351 'title': 'Nicolas Stockhammer (15.10.2023)',
352 'duration': 3396.0,
353 'series': 'Frühstück bei mir',
354 },
355 'skip': 'ORF podcasts are only available for a limited time'
356 }]
357
358 def _real_extract(self, url):
359 station, show, show_id = self._match_valid_url(url).group('station', 'show', 'id')
360 data = self._download_json(
361 f'https://audioapi.orf.at/radiothek/api/2.0/podcast/{station}/{show}/{show_id}', show_id)
362
363 return {
364 'id': show_id,
365 'ext': 'mp3',
366 'vcodec': 'none',
367 **traverse_obj(data, ('payload', {
368 'url': ('enclosures', 0, 'url'),
369 'ext': ('enclosures', 0, 'type', {mimetype2ext}),
370 'title': 'title',
371 'description': ('description', {clean_html}),
372 'duration': ('duration', {functools.partial(float_or_none, scale=1000)}),
373 'series': ('podcast', 'title'),
374 })),
375 }
376
377
378 class ORFIPTVIE(InfoExtractor):
379 IE_NAME = 'orf:iptv'
380 IE_DESC = 'iptv.ORF.at'
381 _VALID_URL = r'https?://iptv\.orf\.at/(?:#/)?stories/(?P<id>\d+)'
382
383 _TEST = {
384 'url': 'http://iptv.orf.at/stories/2275236/',
385 'md5': 'c8b22af4718a4b4af58342529453e3e5',
386 'info_dict': {
387 'id': '350612',
388 'ext': 'flv',
389 'title': 'Weitere Evakuierungen um Vulkan Calbuco',
390 'description': 'md5:d689c959bdbcf04efeddedbf2299d633',
391 'duration': 68.197,
392 'thumbnail': r're:^https?://.*\.jpg$',
393 'upload_date': '20150425',
394 },
395 }
396
397 def _real_extract(self, url):
398 story_id = self._match_id(url)
399
400 webpage = self._download_webpage(
401 'http://iptv.orf.at/stories/%s' % story_id, story_id)
402
403 video_id = self._search_regex(
404 r'data-video(?:id)?="(\d+)"', webpage, 'video id')
405
406 data = self._download_json(
407 'http://bits.orf.at/filehandler/static-api/json/current/data.json?file=%s' % video_id,
408 video_id)[0]
409
410 duration = float_or_none(data['duration'], 1000)
411
412 video = data['sources']['default']
413 load_balancer_url = video['loadBalancerUrl']
414 abr = int_or_none(video.get('audioBitrate'))
415 vbr = int_or_none(video.get('bitrate'))
416 fps = int_or_none(video.get('videoFps'))
417 width = int_or_none(video.get('videoWidth'))
418 height = int_or_none(video.get('videoHeight'))
419 thumbnail = video.get('preview')
420
421 rendition = self._download_json(
422 load_balancer_url, video_id, transform_source=strip_jsonp)
423
424 f = {
425 'abr': abr,
426 'vbr': vbr,
427 'fps': fps,
428 'width': width,
429 'height': height,
430 }
431
432 formats = []
433 for format_id, format_url in rendition['redirect'].items():
434 if format_id == 'rtmp':
435 ff = f.copy()
436 ff.update({
437 'url': format_url,
438 'format_id': format_id,
439 })
440 formats.append(ff)
441 elif determine_ext(format_url) == 'f4m':
442 formats.extend(self._extract_f4m_formats(
443 format_url, video_id, f4m_id=format_id))
444 elif determine_ext(format_url) == 'm3u8':
445 formats.extend(self._extract_m3u8_formats(
446 format_url, video_id, 'mp4', m3u8_id=format_id))
447 else:
448 continue
449
450 title = remove_end(self._og_search_title(webpage), ' - iptv.ORF.at')
451 description = self._og_search_description(webpage)
452 upload_date = unified_strdate(self._html_search_meta(
453 'dc.date', webpage, 'upload date'))
454
455 return {
456 'id': video_id,
457 'title': title,
458 'description': description,
459 'duration': duration,
460 'thumbnail': thumbnail,
461 'upload_date': upload_date,
462 'formats': formats,
463 }
464
465
466 class ORFFM4StoryIE(InfoExtractor):
467 IE_NAME = 'orf:fm4:story'
468 IE_DESC = 'fm4.orf.at stories'
469 _VALID_URL = r'https?://fm4\.orf\.at/stories/(?P<id>\d+)'
470
471 _TEST = {
472 'url': 'http://fm4.orf.at/stories/2865738/',
473 'playlist': [{
474 'md5': 'e1c2c706c45c7b34cf478bbf409907ca',
475 'info_dict': {
476 'id': '547792',
477 'ext': 'flv',
478 'title': 'Manu Delago und Inner Tongue live',
479 'description': 'Manu Delago und Inner Tongue haben bei der FM4 Soundpark Session live alles gegeben. Hier gibt es Fotos und die gesamte Session als Video.',
480 'duration': 1748.52,
481 'thumbnail': r're:^https?://.*\.jpg$',
482 'upload_date': '20170913',
483 },
484 }, {
485 'md5': 'c6dd2179731f86f4f55a7b49899d515f',
486 'info_dict': {
487 'id': '547798',
488 'ext': 'flv',
489 'title': 'Manu Delago und Inner Tongue live (2)',
490 'duration': 1504.08,
491 'thumbnail': r're:^https?://.*\.jpg$',
492 'upload_date': '20170913',
493 'description': 'Manu Delago und Inner Tongue haben bei der FM4 Soundpark Session live alles gegeben. Hier gibt es Fotos und die gesamte Session als Video.',
494 },
495 }],
496 }
497
498 def _real_extract(self, url):
499 story_id = self._match_id(url)
500 webpage = self._download_webpage(url, story_id)
501
502 entries = []
503 all_ids = orderedSet(re.findall(r'data-video(?:id)?="(\d+)"', webpage))
504 for idx, video_id in enumerate(all_ids):
505 data = self._download_json(
506 'http://bits.orf.at/filehandler/static-api/json/current/data.json?file=%s' % video_id,
507 video_id)[0]
508
509 duration = float_or_none(data['duration'], 1000)
510
511 video = data['sources']['q8c']
512 load_balancer_url = video['loadBalancerUrl']
513 abr = int_or_none(video.get('audioBitrate'))
514 vbr = int_or_none(video.get('bitrate'))
515 fps = int_or_none(video.get('videoFps'))
516 width = int_or_none(video.get('videoWidth'))
517 height = int_or_none(video.get('videoHeight'))
518 thumbnail = video.get('preview')
519
520 rendition = self._download_json(
521 load_balancer_url, video_id, transform_source=strip_jsonp)
522
523 f = {
524 'abr': abr,
525 'vbr': vbr,
526 'fps': fps,
527 'width': width,
528 'height': height,
529 }
530
531 formats = []
532 for format_id, format_url in rendition['redirect'].items():
533 if format_id == 'rtmp':
534 ff = f.copy()
535 ff.update({
536 'url': format_url,
537 'format_id': format_id,
538 })
539 formats.append(ff)
540 elif determine_ext(format_url) == 'f4m':
541 formats.extend(self._extract_f4m_formats(
542 format_url, video_id, f4m_id=format_id))
543 elif determine_ext(format_url) == 'm3u8':
544 formats.extend(self._extract_m3u8_formats(
545 format_url, video_id, 'mp4', m3u8_id=format_id))
546 else:
547 continue
548
549 title = remove_end(self._og_search_title(webpage), ' - fm4.ORF.at')
550 if idx >= 1:
551 # Titles are duplicates, make them unique
552 title += ' (' + str(idx + 1) + ')'
553 description = self._og_search_description(webpage)
554 upload_date = unified_strdate(self._html_search_meta(
555 'dc.date', webpage, 'upload date'))
556
557 entries.append({
558 'id': video_id,
559 'title': title,
560 'description': description,
561 'duration': duration,
562 'thumbnail': thumbnail,
563 'upload_date': upload_date,
564 'formats': formats,
565 })
566
567 return self.playlist_result(entries)
568
569
570 class ORFONIE(InfoExtractor):
571 IE_NAME = 'orf:on'
572 _VALID_URL = r'https?://on\.orf\.at/video/(?P<id>\d{8})/(?P<slug>[\w-]+)'
573 _TESTS = [{
574 'url': 'https://on.orf.at/video/14210000/school-of-champions-48',
575 'info_dict': {
576 'id': '14210000',
577 'ext': 'mp4',
578 'duration': 2651.08,
579 'thumbnail': 'https://api-tvthek.orf.at/assets/segments/0167/98/thumb_16697671_segments_highlight_teaser.jpeg',
580 'title': 'School of Champions (4/8)',
581 'description': 'md5:d09ad279fc2e8502611e7648484b6afd',
582 'media_type': 'episode',
583 'timestamp': 1706472362,
584 'upload_date': '20240128',
585 }
586 }]
587
588 def _extract_video(self, video_id, display_id):
589 encrypted_id = base64.b64encode(f'3dSlfek03nsLKdj4Jsd{video_id}'.encode()).decode()
590 api_json = self._download_json(
591 f'https://api-tvthek.orf.at/api/v4.3/public/episode/encrypted/{encrypted_id}', display_id)
592
593 formats, subtitles = [], {}
594 for manifest_type in traverse_obj(api_json, ('sources', {dict.keys}, ...)):
595 for manifest_url in traverse_obj(api_json, ('sources', manifest_type, ..., 'src', {url_or_none})):
596 if manifest_type == 'hls':
597 fmts, subs = self._extract_m3u8_formats_and_subtitles(
598 manifest_url, display_id, fatal=False, m3u8_id='hls')
599 elif manifest_type == 'dash':
600 fmts, subs = self._extract_mpd_formats_and_subtitles(
601 manifest_url, display_id, fatal=False, mpd_id='dash')
602 else:
603 continue
604 formats.extend(fmts)
605 self._merge_subtitles(subs, target=subtitles)
606
607 return {
608 'id': video_id,
609 'formats': formats,
610 'subtitles': subtitles,
611 **traverse_obj(api_json, {
612 'duration': ('duration_second', {float_or_none}),
613 'title': (('title', 'headline'), {str}),
614 'description': (('description', 'teaser_text'), {str}),
615 'media_type': ('video_type', {str}),
616 }, get_all=False),
617 }
618
619 def _real_extract(self, url):
620 video_id, display_id = self._match_valid_url(url).group('id', 'slug')
621 webpage = self._download_webpage(url, display_id)
622
623 return {
624 'id': video_id,
625 'title': self._html_search_meta(['og:title', 'twitter:title'], webpage, default=None),
626 'description': self._html_search_meta(
627 ['description', 'og:description', 'twitter:description'], webpage, default=None),
628 **self._search_json_ld(webpage, display_id, fatal=False),
629 **self._extract_video(video_id, display_id),
630 }