4 from .common
import InfoExtractor
22 from ..utils
.traversal
import traverse_obj
25 class ORFRadioIE(InfoExtractor
):
29 'fm4': ('fm4', 'fm4', 'orffm4'),
30 'noe': ('noe', 'oe2n', 'orfnoe'),
31 'wien': ('wie', 'oe2w', 'orfwie'),
32 'burgenland': ('bgl', 'oe2b', 'orfbgl'),
33 'ooe': ('ooe', 'oe2o', 'orfooe'),
34 'steiermark': ('stm', 'oe2st', 'orfstm'),
35 'kaernten': ('ktn', 'oe2k', 'orfktn'),
36 'salzburg': ('sbg', 'oe2s', 'orfsbg'),
37 'tirol': ('tir', 'oe2t', 'orftir'),
38 'vorarlberg': ('vbg', 'oe2v', 'orfvbg'),
39 'oe3': ('oe3', 'oe3', 'orfoe3'),
40 'oe1': ('oe1', 'oe1', 'orfoe1'),
42 _STATION_RE
= '|'.join(map(re
.escape
, STATION_INFO
.keys()))
44 _VALID_URL
= rf
'''(?x)
46 (?P<station>{_STATION_RE})\.orf\.at/player|
47 radiothek\.orf\.at/(?P<station2>{_STATION_RE})
48 )/(?P<date>[0-9]+)/(?P<show>\w+)'''
51 'url': 'https://radiothek.orf.at/ooe/20220801/OGMO',
54 'title': 'Guten Morgen OÖ',
55 'description': 'md5:a3f6083399ef92b8cbe2d421b180835a',
58 'md5': 'f33147d954a326e338ea52572c2810e8',
60 'id': '2022-08-01_0459_tl_66_7DaysMon1_319062',
62 'title': 'Guten Morgen OÖ',
63 'upload_date': '20220801',
65 'timestamp': 1659322789,
66 'description': 'md5:a3f6083399ef92b8cbe2d421b180835a',
70 'url': 'https://ooe.orf.at/player/20220801/OGMO',
73 'title': 'Guten Morgen OÖ',
74 'description': 'md5:a3f6083399ef92b8cbe2d421b180835a',
77 'md5': 'f33147d954a326e338ea52572c2810e8',
79 'id': '2022-08-01_0459_tl_66_7DaysMon1_319062',
81 'title': 'Guten Morgen OÖ',
82 'upload_date': '20220801',
84 'timestamp': 1659322789,
85 'description': 'md5:a3f6083399ef92b8cbe2d421b180835a',
89 'url': 'http://fm4.orf.at/player/20170107/4CC',
90 'only_matching': True,
92 'url': 'https://noe.orf.at/player/20200423/NGM',
93 'only_matching': True,
95 'url': 'https://wien.orf.at/player/20200423/WGUM',
96 'only_matching': True,
98 'url': 'https://burgenland.orf.at/player/20200423/BGM',
99 'only_matching': True,
101 'url': 'https://steiermark.orf.at/player/20200423/STGMS',
102 'only_matching': True,
104 'url': 'https://kaernten.orf.at/player/20200423/KGUMO',
105 'only_matching': True,
107 'url': 'https://salzburg.orf.at/player/20200423/SGUM',
108 'only_matching': True,
110 'url': 'https://tirol.orf.at/player/20200423/TGUMO',
111 'only_matching': True,
113 'url': 'https://vorarlberg.orf.at/player/20200423/VGUM',
114 'only_matching': True,
116 'url': 'https://oe3.orf.at/player/20200424/3WEK',
117 'only_matching': True,
119 'url': 'http://oe1.orf.at/player/20170108/456544',
120 'md5': '34d8a6e67ea888293741c86a099b745b',
122 'id': '2017-01-08_0759_tl_51_7DaysSun6_256141',
124 'title': 'Morgenjournal',
126 'timestamp': 1483858796,
127 'upload_date': '20170108',
129 'skip': 'Shows from ORF radios are only available for 7 days.',
132 def _entries(self
, data
, station
):
133 _
, loop_station
, old_ie
= self
.STATION_INFO
[station
]
134 for info
in data
['streams']:
135 item_id
= info
.get('loopStreamId')
138 video_id
= item_id
.replace('.mp3', '')
142 'url': f
'https://loopstream01.apa.at/?channel={loop_station}&id={item_id}',
143 '_old_archive_ids': [make_archive_id(old_ie
, video_id
)],
144 'title': data
.get('title'),
145 'description': clean_html(data
.get('subtitle')),
146 'duration': try_call(lambda: (info
['end'] - info
['start']) / 1000),
147 'timestamp': int_or_none(info
.get('start'), scale
=1000),
148 'series': data
.get('programTitle'),
151 def _real_extract(self
, url
):
152 station
, station2
, show_date
, show_id
= self
._match
_valid
_url
(url
).group('station', 'station2', 'date', 'show')
153 api_station
, _
, _
= self
.STATION_INFO
[station
or station2
]
154 data
= self
._download
_json
(
155 f
'http://audioapi.orf.at/{api_station}/api/json/current/broadcast/{show_id}/{show_date}', show_id
)
157 return self
.playlist_result(
158 self
._entries
(data
, station
or station2
), show_id
, data
.get('title'), clean_html(data
.get('subtitle')))
161 class ORFPodcastIE(InfoExtractor
):
162 IE_NAME
= 'orf:podcast'
163 _STATION_RE
= '|'.join(map(re
.escape
, (
164 'bgl', 'fm4', 'ktn', 'noe', 'oe1', 'oe3',
165 'ooe', 'sbg', 'stm', 'tir', 'tv', 'vbg', 'wie')))
166 _VALID_URL
= rf
'https?://sound\.orf\.at/podcast/(?P<station>{_STATION_RE})/(?P<show>[\w-]+)/(?P<id>[\w-]+)'
168 'url': 'https://sound.orf.at/podcast/oe3/fruehstueck-bei-mir/nicolas-stockhammer-15102023',
169 'md5': '526a5700e03d271a1505386a8721ab9b',
171 'id': 'nicolas-stockhammer-15102023',
173 'title': 'Nicolas Stockhammer (15.10.2023)',
175 'series': 'Frühstück bei mir',
177 'skip': 'ORF podcasts are only available for a limited time',
180 def _real_extract(self
, url
):
181 station
, show
, show_id
= self
._match
_valid
_url
(url
).group('station', 'show', 'id')
182 data
= self
._download
_json
(
183 f
'https://audioapi.orf.at/radiothek/api/2.0/podcast/{station}/{show}/{show_id}', show_id
)
189 **traverse_obj(data
, ('payload', {
190 'url': ('enclosures', 0, 'url'),
191 'ext': ('enclosures', 0, 'type', {mimetype2ext}
),
193 'description': ('description', {clean_html}
),
194 'duration': ('duration', {float_or_none(scale
=1000)}),
195 'series': ('podcast', 'title'),
200 class ORFIPTVIE(InfoExtractor
):
202 IE_DESC
= 'iptv.ORF.at'
203 _VALID_URL
= r
'https?://iptv\.orf\.at/(?:#/)?stories/(?P<id>\d+)'
206 'url': 'http://iptv.orf.at/stories/2275236/',
207 'md5': 'c8b22af4718a4b4af58342529453e3e5',
211 'title': 'Weitere Evakuierungen um Vulkan Calbuco',
212 'description': 'md5:d689c959bdbcf04efeddedbf2299d633',
214 'thumbnail': r
're:^https?://.*\.jpg$',
215 'upload_date': '20150425',
219 def _real_extract(self
, url
):
220 story_id
= self
._match
_id
(url
)
222 webpage
= self
._download
_webpage
(
223 f
'http://iptv.orf.at/stories/{story_id}', story_id
)
225 video_id
= self
._search
_regex
(
226 r
'data-video(?:id)?="(\d+)"', webpage
, 'video id')
228 data
= self
._download
_json
(
229 f
'http://bits.orf.at/filehandler/static-api/json/current/data.json?file={video_id}',
232 duration
= float_or_none(data
['duration'], 1000)
234 video
= data
['sources']['default']
235 load_balancer_url
= video
['loadBalancerUrl']
236 abr
= int_or_none(video
.get('audioBitrate'))
237 vbr
= int_or_none(video
.get('bitrate'))
238 fps
= int_or_none(video
.get('videoFps'))
239 width
= int_or_none(video
.get('videoWidth'))
240 height
= int_or_none(video
.get('videoHeight'))
241 thumbnail
= video
.get('preview')
243 rendition
= self
._download
_json
(
244 load_balancer_url
, video_id
, transform_source
=strip_jsonp
)
255 for format_id
, format_url
in rendition
['redirect'].items():
256 if format_id
== 'rtmp':
260 'format_id': format_id
,
263 elif determine_ext(format_url
) == 'f4m':
264 formats
.extend(self
._extract
_f
4m
_formats
(
265 format_url
, video_id
, f4m_id
=format_id
))
266 elif determine_ext(format_url
) == 'm3u8':
267 formats
.extend(self
._extract
_m
3u8_formats
(
268 format_url
, video_id
, 'mp4', m3u8_id
=format_id
))
272 title
= remove_end(self
._og
_search
_title
(webpage
), ' - iptv.ORF.at')
273 description
= self
._og
_search
_description
(webpage
)
274 upload_date
= unified_strdate(self
._html
_search
_meta
(
275 'dc.date', webpage
, 'upload date'))
280 'description': description
,
281 'duration': duration
,
282 'thumbnail': thumbnail
,
283 'upload_date': upload_date
,
288 class ORFFM4StoryIE(InfoExtractor
):
289 IE_NAME
= 'orf:fm4:story'
290 IE_DESC
= 'fm4.orf.at stories'
291 _VALID_URL
= r
'https?://fm4\.orf\.at/stories/(?P<id>\d+)'
294 'url': 'http://fm4.orf.at/stories/2865738/',
296 'md5': 'e1c2c706c45c7b34cf478bbf409907ca',
300 'title': 'Manu Delago und Inner Tongue live',
301 '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.',
303 'thumbnail': r
're:^https?://.*\.jpg$',
304 'upload_date': '20170913',
307 'md5': 'c6dd2179731f86f4f55a7b49899d515f',
311 'title': 'Manu Delago und Inner Tongue live (2)',
313 'thumbnail': r
're:^https?://.*\.jpg$',
314 'upload_date': '20170913',
315 '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.',
320 def _real_extract(self
, url
):
321 story_id
= self
._match
_id
(url
)
322 webpage
= self
._download
_webpage
(url
, story_id
)
325 all_ids
= orderedSet(re
.findall(r
'data-video(?:id)?="(\d+)"', webpage
))
326 for idx
, video_id
in enumerate(all_ids
):
327 data
= self
._download
_json
(
328 f
'http://bits.orf.at/filehandler/static-api/json/current/data.json?file={video_id}',
331 duration
= float_or_none(data
['duration'], 1000)
333 video
= data
['sources']['q8c']
334 load_balancer_url
= video
['loadBalancerUrl']
335 abr
= int_or_none(video
.get('audioBitrate'))
336 vbr
= int_or_none(video
.get('bitrate'))
337 fps
= int_or_none(video
.get('videoFps'))
338 width
= int_or_none(video
.get('videoWidth'))
339 height
= int_or_none(video
.get('videoHeight'))
340 thumbnail
= video
.get('preview')
342 rendition
= self
._download
_json
(
343 load_balancer_url
, video_id
, transform_source
=strip_jsonp
)
354 for format_id
, format_url
in rendition
['redirect'].items():
355 if format_id
== 'rtmp':
359 'format_id': format_id
,
362 elif determine_ext(format_url
) == 'f4m':
363 formats
.extend(self
._extract
_f
4m
_formats
(
364 format_url
, video_id
, f4m_id
=format_id
))
365 elif determine_ext(format_url
) == 'm3u8':
366 formats
.extend(self
._extract
_m
3u8_formats
(
367 format_url
, video_id
, 'mp4', m3u8_id
=format_id
))
371 title
= remove_end(self
._og
_search
_title
(webpage
), ' - fm4.ORF.at')
373 # Titles are duplicates, make them unique
374 title
+= ' (' + str(idx
+ 1) + ')'
375 description
= self
._og
_search
_description
(webpage
)
376 upload_date
= unified_strdate(self
._html
_search
_meta
(
377 'dc.date', webpage
, 'upload date'))
382 'description': description
,
383 'duration': duration
,
384 'thumbnail': thumbnail
,
385 'upload_date': upload_date
,
389 return self
.playlist_result(entries
)
392 class ORFONIE(InfoExtractor
):
394 _VALID_URL
= r
'https?://on\.orf\.at/video/(?P<id>\d+)(?:/(?P<segment>\d+))?'
396 'url': 'https://on.orf.at/video/14210000/school-of-champions-48',
401 'thumbnail': 'https://api-tvthek.orf.at/assets/segments/0167/98/thumb_16697671_segments_highlight_teaser.jpeg',
402 'title': 'School of Champions (4/8)',
403 'description': 'md5:d09ad279fc2e8502611e7648484b6afd',
404 'media_type': 'episode',
405 'timestamp': 1706558922,
406 'upload_date': '20240129',
407 'release_timestamp': 1706472362,
408 'release_date': '20240128',
409 'modified_timestamp': 1712756663,
410 'modified_date': '20240410',
411 '_old_archive_ids': ['orftvthek 14210000'],
414 'url': 'https://on.orf.at/video/3220355',
415 'md5': 'f94d98e667cf9a3851317efb4e136662',
420 'thumbnail': 'https://api-tvthek.orf.at/assets/segments/0002/60/thumb_159573_segments_highlight_teaser.png',
421 'title': '50 Jahre Burgenland: Der Festumzug',
422 'description': 'md5:1560bf855119544ee8c4fa5376a2a6b0',
423 'media_type': 'episode',
424 'timestamp': 52916400,
425 'upload_date': '19710905',
426 'release_timestamp': 52916400,
427 'release_date': '19710905',
428 'modified_timestamp': 1498536049,
429 'modified_date': '20170627',
430 '_old_archive_ids': ['orftvthek 3220355'],
433 # Video with multiple segments selecting the second segment
434 'url': 'https://on.orf.at/video/14226549/15639808/jugendbande-einbrueche-aus-langeweile',
435 'md5': '90f4ebff86b4580837b8a361d0232a9e',
440 'thumbnail': 'https://api-tvthek.orf.at/assets/segments/0175/43/thumb_17442704_segments_highlight_teaser.jpg',
441 'title': 'Jugendbande: Einbrüche aus Langeweile',
442 'description': 'md5:193df0bf0d91cf16830c211078097120',
443 'media_type': 'segment',
444 'timestamp': 1715792400,
445 'upload_date': '20240515',
446 'modified_timestamp': 1715794394,
447 'modified_date': '20240515',
448 '_old_archive_ids': ['orftvthek 15639808'],
450 'params': {'noplaylist': True},
452 # Video with multiple segments and no combined version
453 'url': 'https://on.orf.at/video/14227864/formel-1-grosser-preis-von-monaco-2024',
455 '_type': 'multi_video',
457 'duration': 18410.52,
458 'thumbnail': 'https://api-tvthek.orf.at/assets/segments/0176/04/thumb_17503881_segments_highlight_teaser.jpg',
459 'title': 'Formel 1: Großer Preis von Monaco 2024',
460 'description': 'md5:aeeb010710ccf70ce28ccb4482243d4f',
461 'media_type': 'episode',
462 'timestamp': 1716721200,
463 'upload_date': '20240526',
464 'release_timestamp': 1716721802,
465 'release_date': '20240526',
466 'modified_timestamp': 1716967501,
467 'modified_date': '20240529',
469 'playlist_count': 42,
471 # Video with multiple segments, but with combined version
472 'url': 'https://on.orf.at/video/14228172',
476 'duration': 3294.878,
477 'thumbnail': 'https://api-tvthek.orf.at/assets/segments/0176/17/thumb_17516455_segments_highlight_teaser.jpg',
478 'title': 'Willkommen Österreich mit Stermann & Grissemann',
479 'description': 'md5:5de034d033a9c27f989343be3bbd4839',
480 'media_type': 'episode',
481 'timestamp': 1716926584,
482 'upload_date': '20240528',
483 'release_timestamp': 1716919202,
484 'release_date': '20240528',
485 'modified_timestamp': 1716968045,
486 'modified_date': '20240529',
487 '_old_archive_ids': ['orftvthek 14228172'],
492 def _parse_metadata(api_json
):
493 return traverse_obj(api_json
, {
494 'id': ('id', {int}
, {str_or_none}
),
495 'age_limit': ('age_classification', {parse_age_limit}
),
496 'duration': ('exact_duration', {float_or_none(scale
=1000)}),
497 'title': (('title', 'headline'), {str}
),
498 'description': (('description', 'teaser_text'), {str}
),
499 'media_type': ('video_type', {str}
),
500 'thumbnail': ('_embedded', 'image', 'public_urls', 'highlight_teaser', 'url', {url_or_none}
),
501 'timestamp': (('date', 'episode_date'), {parse_iso8601}
),
502 'release_timestamp': ('release_date', {parse_iso8601}
),
503 'modified_timestamp': ('updated_at', {parse_iso8601}
),
506 def _extract_video_info(self
, video_id
, api_json
):
507 formats
, subtitles
= [], {}
508 for manifest_type
in traverse_obj(api_json
, ('sources', {dict.keys
}, ...)):
509 for manifest_url
in traverse_obj(api_json
, ('sources', manifest_type
, ..., 'src', {url_or_none}
)):
510 if manifest_type
== 'hls':
511 fmts
, subs
= self
._extract
_m
3u8_formats
_and
_subtitles
(
512 manifest_url
, video_id
, fatal
=False, m3u8_id
='hls')
513 elif manifest_type
== 'dash':
514 fmts
, subs
= self
._extract
_mpd
_formats
_and
_subtitles
(
515 manifest_url
, video_id
, fatal
=False, mpd_id
='dash')
519 self
._merge
_subtitles
(subs
, target
=subtitles
)
521 for sub_url
in traverse_obj(api_json
, (
522 '_embedded', 'subtitle',
523 ('xml_url', 'sami_url', 'stl_url', 'ttml_url', 'srt_url', 'vtt_url'), {url_or_none}
)):
524 self
._merge
_subtitles
({'de': [{'url': sub_url
}]}, target
=subtitles
)
529 'subtitles': subtitles
,
530 '_old_archive_ids': [make_archive_id('ORFTVthek', video_id
)],
531 **self
._parse
_metadata
(api_json
),
534 def _real_extract(self
, url
):
535 video_id
, segment_id
= self
._match
_valid
_url
(url
).group('id', 'segment')
537 encrypted_id
= base64
.b64encode(f
'3dSlfek03nsLKdj4Jsd{video_id}'.encode()).decode()
538 api_json
= self
._download
_json
(
539 f
'https://api-tvthek.orf.at/api/v4.3/public/episode/encrypted/{encrypted_id}', video_id
)
541 if traverse_obj(api_json
, 'is_drm_protected'):
542 self
.report_drm(video_id
)
544 segments
= traverse_obj(api_json
, ('_embedded', 'segments', lambda _
, v
: v
['id']))
545 selected_segment
= traverse_obj(segments
, (lambda _
, v
: str(v
['id']) == segment_id
, any
))
547 # selected_segment will be falsy if input URL did not include a valid segment_id
548 if selected_segment
and not self
._yes
_playlist
(video_id
, segment_id
, playlist_label
='episode', video_label
='segment'):
549 return self
._extract
_video
_info
(segment_id
, selected_segment
)
551 # Even some segmented videos have an unsegmented version available in API response root
552 if (self
._configuration
_arg
('prefer_segments_playlist')
553 or not traverse_obj(api_json
, ('sources', ..., ..., 'src', {url_or_none}
))):
554 return self
.playlist_result(
555 (self
._extract
_video
_info
(str(segment
['id']), segment
) for segment
in segments
),
556 video_id
, **self
._parse
_metadata
(api_json
), multi_video
=True)
558 return self
._extract
_video
_info
(video_id
, api_json
)