4 from .common
import InfoExtractor
26 class ORFTVthekIE(InfoExtractor
):
27 IE_NAME
= 'orf:tvthek'
28 IE_DESC
= 'ORF TVthek'
29 _VALID_URL
= r
'(?P<url>https?://tvthek\.orf\.at/(?:(?:[^/]+/){2}){1,2}(?P<id>\d+))(/[^/]+/(?P<vid>\d+))?(?:$|[?#])'
32 'url': 'https://tvthek.orf.at/profile/ZIB-2/1211/ZIB-2/14121079',
37 'params': {'noplaylist': True}
39 'url': 'https://tvthek.orf.at/profile/ZIB-2/1211/ZIB-2/14121079/Umfrage-Welches-Tier-ist-Sebastian-Kurz/15083150',
44 'params': {'playlist_items': '5'}
46 'url': 'https://tvthek.orf.at/profile/ZIB-2/1211/ZIB-2/14121079/Umfrage-Welches-Tier-ist-Sebastian-Kurz/15083150',
55 'description': 'md5:7be1c485425f5f255a5e4e4815e77d04',
56 'thumbnail': 'https://api-tvthek.orf.at/uploads/media/segments/0130/59/824271ea35cd8931a0fb08ab316a5b0a1562342c.jpeg',
57 'title': 'Umfrage: Welches Tier ist Sebastian Kurz?',
61 'params': {'noplaylist': True, 'skip_download': 'm3u8'}
63 'url': 'http://tvthek.orf.at/program/Aufgetischt/2745173/Aufgetischt-Mit-der-Steirischen-Tafelrunde/8891389',
65 'md5': '2942210346ed779588f428a92db88712',
69 'title': 'Aufgetischt: Mit der Steirischen Tafelrunde',
70 'description': 'md5:c1272f0245537812d4e36419c207b67d',
72 'upload_date': '20141208',
75 'skip': 'Blocked outside of Austria / Germany',
77 'url': 'http://tvthek.orf.at/topic/Im-Wandel-der-Zeit/8002126/Best-of-Ingrid-Thurnher/7982256',
81 'title': 'Best of Ingrid Thurnher',
82 'upload_date': '20140527',
83 '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 'skip_download': True, # rtsp downloads
88 'skip': 'Blocked outside of Austria / Germany',
90 'url': 'http://tvthek.orf.at/topic/Fluechtlingskrise/10463081/Heimat-Fremde-Heimat/13879132/Senioren-betreuen-Migrantenkinder/13879141',
91 'only_matching': True,
93 'url': 'http://tvthek.orf.at/profile/Universum/35429',
94 'only_matching': True,
97 def _pagefunc(self
, url
, data_jsb
, n
, *, image
=None):
99 video_id
, title
= str(sd
['id']), sd
['title']
101 for fd
in sd
['sources']:
102 src
= url_or_none(fd
.get('src'))
105 format_id
= join_nonempty('delivery', 'quality', 'quality_string', from_dict
=fd
)
106 ext
= determine_ext(src
)
108 m3u8_formats
= self
._extract
_m
3u8_formats
(
109 src
, video_id
, 'mp4', m3u8_id
=format_id
, fatal
=False, note
=f
'Downloading {format_id} m3u8 manifest')
110 if any('/geoprotection' in f
['url'] for f
in m3u8_formats
):
111 self
.raise_geo_restricted()
112 formats
.extend(m3u8_formats
)
114 formats
.extend(self
._extract
_f
4m
_formats
(
115 src
, video_id
, f4m_id
=format_id
, fatal
=False))
117 formats
.extend(self
._extract
_mpd
_formats
(
118 src
, video_id
, mpd_id
=format_id
, fatal
=False, note
=f
'Downloading {format_id} mpd manifest'))
121 'format_id': format_id
,
123 'protocol': fd
.get('protocol'),
126 # Check for geoblocking.
127 # There is a property is_geoprotection, but that's always false
128 geo_str
= sd
.get('geoprotection_string')
130 (f
['url'] for f
in formats
if re
.match(r
'^https?://.*\.mp4$', f
['url'])),
131 None) if geo_str
else None
133 self
._request
_webpage
(
134 HEADRequest(http_url
), video_id
, fatal
=False, note
='Testing for geoblocking',
135 errnote
=f
'This video seems to be blocked outside of {geo_str}. You may want to try the streaming-* formats')
137 self
._sort
_formats
(formats
)
140 for sub
in sd
.get('subtitles', []):
141 sub_src
= sub
.get('src')
144 subtitles
.setdefault(sub
.get('lang', 'de-AT'), []).append({
148 upload_date
= unified_strdate(sd
.get('created_date'))
151 preview
= sd
.get('preview_image_url')
158 image
= sd
.get('image_full_url') or image
169 'webpage_url': smuggle_url(f
'{url}/part/{video_id}', {'force_noplaylist': True}
),
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
,
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
)
183 data_jsb
= self
._parse
_json
(
185 r
'<div[^>]+class=(["\']).*?VideoPlaylist
.*?\
1[^
>]+data
-jsb
=(["\'])(?P<json>.+?)\2',
186 webpage, 'playlist', group='json'),
187 playlist_id, transform_source=unescapeHTML)['playlist']['videos']
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]
192 playlist_count = len(data_jsb)
193 image = self._og_search_thumbnail(webpage) if playlist_count == 1 else None
195 page_func = functools.partial(self._pagefunc, base_url, data_jsb, image=image)
198 'entries': InAdvancePagedList(page_func, playlist_count, 1),
203 class ORFRadioIE(InfoExtractor):
204 IE_NAME = 'orf:radio'
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'),
220 _STATION_RE = '|'.join(map(re.escape, STATION_INFO.keys()))
222 _VALID_URL = rf'''(?x)
224 (?P<station>{_STATION_RE})\.orf\.at/player|
225 radiothek\.orf\.at/(?P<station2>{_STATION_RE})
226 )/(?P<date>[0-9]+)/(?P<show>\w+)'''
229 'url': 'https://radiothek.orf.at/ooe/20220801/OGMO',
232 'title': 'Guten Morgen OÖ',
233 'description': 'md5:a3f6083399ef92b8cbe2d421b180835a',
236 'md5': 'f33147d954a326e338ea52572c2810e8',
238 'id': '2022-08-01_0459_tl_66_7DaysMon1_319062',
240 'title': 'Guten Morgen OÖ',
241 'upload_date': '20220801',
243 'timestamp': 1659322789,
244 'description': 'md5:a3f6083399ef92b8cbe2d421b180835a',
248 'url': 'https://ooe.orf.at/player/20220801/OGMO',
251 'title': 'Guten Morgen OÖ',
252 'description': 'md5:a3f6083399ef92b8cbe2d421b180835a',
255 'md5': 'f33147d954a326e338ea52572c2810e8',
257 'id': '2022-08-01_0459_tl_66_7DaysMon1_319062',
259 'title': 'Guten Morgen OÖ',
260 'upload_date': '20220801',
262 'timestamp': 1659322789,
263 'description': 'md5:a3f6083399ef92b8cbe2d421b180835a',
267 'url': 'http://fm4.orf.at/player/20170107/4CC',
268 'only_matching': True,
270 'url': 'https://noe.orf.at/player/20200423/NGM',
271 'only_matching': True,
273 'url': 'https://wien.orf.at/player/20200423/WGUM',
274 'only_matching': True,
276 'url': 'https://burgenland.orf.at/player/20200423/BGM',
277 'only_matching': True,
279 'url': 'https://steiermark.orf.at/player/20200423/STGMS',
280 'only_matching': True,
282 'url': 'https://kaernten.orf.at/player/20200423/KGUMO',
283 'only_matching': True,
285 'url': 'https://salzburg.orf.at/player/20200423/SGUM',
286 'only_matching': True,
288 'url': 'https://tirol.orf.at/player/20200423/TGUMO',
289 'only_matching': True,
291 'url': 'https://vorarlberg.orf.at/player/20200423/VGUM',
292 'only_matching': True,
294 'url': 'https://oe3.orf.at/player/20200424/3WEK',
295 'only_matching': True,
297 'url': 'http://oe1.orf.at/player/20170108/456544',
298 'md5': '34d8a6e67ea888293741c86a099b745b',
300 'id': '2017-01-08_0759_tl_51_7DaysSun6_256141',
302 'title': 'Morgenjournal',
304 'timestamp': 1483858796,
305 'upload_date': '20170108',
307 'skip': 'Shows from ORF radios are only available for 7 days.'
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')
316 video_id = item_id.replace('.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'),
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)
335 return self.playlist_result(
336 self._entries(data, station or station2), show_id, data.get('title'), clean_html(data.get('subtitle')))
339 class ORFIPTVIE(InfoExtractor):
341 IE_DESC = 'iptv.ORF.at'
342 _VALID_URL = r'https?://iptv\.orf\.at/(?:#/)?stories/(?P<id>\d+)'
345 'url': 'http://iptv.orf.at/stories/2275236/',
346 'md5': 'c8b22af4718a4b4af58342529453e3e5',
350 'title': 'Weitere Evakuierungen um Vulkan Calbuco',
351 'description': 'md5:d689c959bdbcf04efeddedbf2299d633',
353 'thumbnail': r're:^https?://.*\.jpg$',
354 'upload_date': '20150425',
358 def _real_extract(self, url):
359 story_id = self._match_id(url)
361 webpage = self._download_webpage(
362 'http://iptv.orf.at/stories/%s' % story_id, story_id)
364 video_id = self._search_regex(
365 r'data-video(?:id)?="(\d
+)"', webpage, 'video id')
367 data = self._download_json(
368 'http://bits.orf.at/filehandler/static-api/json/current/data.json?file=%s' % video_id,
371 duration = float_or_none(data['duration'], 1000)
373 video = data['sources']['default']
374 load_balancer_url = video['loadBalancerUrl']
375 abr = int_or_none(video.get('audioBitrate'))
376 vbr = int_or_none(video.get('bitrate'))
377 fps = int_or_none(video.get('videoFps'))
378 width = int_or_none(video.get('videoWidth'))
379 height = int_or_none(video.get('videoHeight'))
380 thumbnail = video.get('preview')
382 rendition = self._download_json(
383 load_balancer_url, video_id, transform_source=strip_jsonp)
394 for format_id, format_url in rendition['redirect'].items():
395 if format_id == 'rtmp':
399 'format_id': format_id,
402 elif determine_ext(format_url) == 'f4m':
403 formats.extend(self._extract_f4m_formats(
404 format_url, video_id, f4m_id=format_id))
405 elif determine_ext(format_url) == 'm3u8':
406 formats.extend(self._extract_m3u8_formats(
407 format_url, video_id, 'mp4', m3u8_id=format_id))
410 self._sort_formats(formats)
412 title = remove_end(self._og_search_title(webpage), ' - iptv.ORF.at')
413 description = self._og_search_description(webpage)
414 upload_date = unified_strdate(self._html_search_meta(
415 'dc.date', webpage, 'upload date'))
420 'description': description,
421 'duration': duration,
422 'thumbnail': thumbnail,
423 'upload_date': upload_date,
428 class ORFFM4StoryIE(InfoExtractor):
429 IE_NAME = 'orf:fm4:story'
430 IE_DESC = 'fm4.orf.at stories'
431 _VALID_URL = r'https?://fm4\.orf\.at/stories/(?P<id>\d+)'
434 'url': 'http://fm4.orf.at/stories/2865738/',
436 'md5': 'e1c2c706c45c7b34cf478bbf409907ca',
440 'title': 'Manu Delago und Inner Tongue live',
441 '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.',
443 'thumbnail': r're:^https?://.*\.jpg$',
444 'upload_date': '20170913',
447 'md5': 'c6dd2179731f86f4f55a7b49899d515f',
451 'title': 'Manu Delago und Inner Tongue live (2)',
453 'thumbnail': r're:^https?://.*\.jpg$',
454 'upload_date': '20170913',
455 '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.',
460 def _real_extract(self, url):
461 story_id = self._match_id(url)
462 webpage = self._download_webpage(url, story_id)
465 all_ids = orderedSet(re.findall(r'data-video(?:id)?="(\d
+)"', webpage))
466 for idx, video_id in enumerate(all_ids):
467 data = self._download_json(
468 'http://bits.orf.at/filehandler/static-api/json/current/data.json?file=%s' % video_id,
471 duration = float_or_none(data['duration'], 1000)
473 video = data['sources']['q8c']
474 load_balancer_url = video['loadBalancerUrl']
475 abr = int_or_none(video.get('audioBitrate'))
476 vbr = int_or_none(video.get('bitrate'))
477 fps = int_or_none(video.get('videoFps'))
478 width = int_or_none(video.get('videoWidth'))
479 height = int_or_none(video.get('videoHeight'))
480 thumbnail = video.get('preview')
482 rendition = self._download_json(
483 load_balancer_url, video_id, transform_source=strip_jsonp)
494 for format_id, format_url in rendition['redirect'].items():
495 if format_id == 'rtmp':
499 'format_id': format_id,
502 elif determine_ext(format_url) == 'f4m':
503 formats.extend(self._extract_f4m_formats(
504 format_url, video_id, f4m_id=format_id))
505 elif determine_ext(format_url) == 'm3u8':
506 formats.extend(self._extract_m3u8_formats(
507 format_url, video_id, 'mp4', m3u8_id=format_id))
510 self._sort_formats(formats)
512 title = remove_end(self._og_search_title(webpage), ' - fm4.ORF.at')
514 # Titles are duplicates, make them unique
515 title += ' (' + str(idx + 1) + ')'
516 description = self._og_search_description(webpage)
517 upload_date = unified_strdate(self._html_search_meta(
518 'dc.date', webpage, 'upload date'))
523 'description': description,
524 'duration': duration,
525 'thumbnail': thumbnail,
526 'upload_date': upload_date,
530 return self.playlist_result(entries)