2 from __future__
import unicode_literals
7 from .common
import InfoExtractor
28 class ORFTVthekIE(InfoExtractor
):
29 IE_NAME
= 'orf:tvthek'
30 IE_DESC
= 'ORF TVthek'
31 _VALID_URL
= r
'(?P<url>https?://tvthek\.orf\.at/(?:(?:[^/]+/){2}){1,2}(?P<id>\d+))(/[^/]+/(?P<vid>\d+))?(?:$|[?#])'
34 'url': 'https://tvthek.orf.at/profile/ZIB-2/1211/ZIB-2/14121079',
39 'params': {'noplaylist': True}
41 'url': 'https://tvthek.orf.at/profile/ZIB-2/1211/ZIB-2/14121079/Umfrage-Welches-Tier-ist-Sebastian-Kurz/15083150',
46 'params': {'playlist_items': '5'}
48 'url': 'https://tvthek.orf.at/profile/ZIB-2/1211/ZIB-2/14121079/Umfrage-Welches-Tier-ist-Sebastian-Kurz/15083150',
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?',
63 'params': {'noplaylist': True, 'skip_download': 'm3u8'}
65 'url': 'http://tvthek.orf.at/program/Aufgetischt/2745173/Aufgetischt-Mit-der-Steirischen-Tafelrunde/8891389',
67 'md5': '2942210346ed779588f428a92db88712',
71 'title': 'Aufgetischt: Mit der Steirischen Tafelrunde',
72 'description': 'md5:c1272f0245537812d4e36419c207b67d',
74 'upload_date': '20141208',
77 'skip': 'Blocked outside of Austria / Germany',
79 'url': 'http://tvthek.orf.at/topic/Im-Wandel-der-Zeit/8002126/Best-of-Ingrid-Thurnher/7982256',
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".',
88 'skip_download': True, # rtsp downloads
90 'skip': 'Blocked outside of Austria / Germany',
92 'url': 'http://tvthek.orf.at/topic/Fluechtlingskrise/10463081/Heimat-Fremde-Heimat/13879132/Senioren-betreuen-Migrantenkinder/13879141',
93 'only_matching': True,
95 'url': 'http://tvthek.orf.at/profile/Universum/35429',
96 'only_matching': True,
99 def _pagefunc(self
, url
, data_jsb
, n
, *, image
=None):
101 video_id
, title
= str(sd
['id']), sd
['title']
103 for fd
in sd
['sources']:
104 src
= url_or_none(fd
.get('src'))
107 format_id
= join_nonempty('delivery', 'quality', 'quality_string', from_dict
=fd
)
108 ext
= determine_ext(src
)
110 m3u8_formats
= self
._extract
_m
3u8_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
)
116 formats
.extend(self
._extract
_f
4m
_formats
(
117 src
, video_id
, f4m_id
=format_id
, fatal
=False))
119 formats
.extend(self
._extract
_mpd
_formats
(
120 src
, video_id
, mpd_id
=format_id
, fatal
=False, note
=f
'Downloading {format_id} mpd manifest'))
123 'format_id': format_id
,
125 'protocol': fd
.get('protocol'),
128 # Check for geoblocking.
129 # There is a property is_geoprotection, but that's always false
130 geo_str
= sd
.get('geoprotection_string')
132 (f
['url'] for f
in formats
if re
.match(r
'^https?://.*\.mp4$', f
['url'])),
133 None) if geo_str
else None
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')
139 self
._sort
_formats
(formats
)
142 for sub
in sd
.get('subtitles', []):
143 sub_src
= sub
.get('src')
146 subtitles
.setdefault(sub
.get('lang', 'de-AT'), []).append({
150 upload_date
= unified_strdate(sd
.get('created_date'))
153 preview
= sd
.get('preview_image_url')
160 image
= sd
.get('image_full_url') or image
171 'webpage_url': smuggle_url(f
'{url}/part/{video_id}', {'force_noplaylist': True}
),
173 'subtitles': subtitles
,
174 'description': sd
.get('description'),
175 'duration': int_or_none(sd
.get('duration_in_seconds')),
176 'upload_date': upload_date
,
177 'thumbnails': thumbnails
,
180 def _real_extract(self
, url
):
181 url
, smuggled_data
= unsmuggle_url(url
)
182 playlist_id
, video_id
, base_url
= self
._match
_valid
_url
(url
).group('id', 'vid', 'url')
183 webpage
= self
._download
_webpage
(url
, playlist_id
)
185 data_jsb
= self
._parse
_json
(
187 r
'<div[^>]+class=(["\']).*?VideoPlaylist
.*?\
1[^
>]+data
-jsb
=(["\'])(?P<json>.+?)\2',
188 webpage, 'playlist', group='json'),
189 playlist_id, transform_source=unescapeHTML)['playlist']['videos']
191 if not self._yes_playlist(playlist_id, video_id, smuggled_data):
192 data_jsb = [sd for sd in data_jsb if str(sd.get('id')) == video_id]
194 playlist_count = len(data_jsb)
195 image = self._og_search_thumbnail(webpage) if playlist_count == 1 else None
197 page_func = functools.partial(self._pagefunc, base_url, data_jsb, image=image)
200 'entries': InAdvancePagedList(page_func, playlist_count, 1),
205 class ORFRadioIE(InfoExtractor):
206 def _real_extract(self, url):
207 mobj = self._match_valid_url(url)
208 show_date = mobj.group('date')
209 show_id = mobj.group('show')
211 data = self._download_json(
212 'http://audioapi.orf.at/%s/api/json/current/broadcast/%s/%s'
213 % (self._API_STATION, show_id, show_date), show_id)
216 for info in data['streams']:
217 loop_stream_id = str_or_none(info.get('loopStreamId'))
218 if not loop_stream_id:
220 title = str_or_none(data.get('title'))
223 start = int_or_none(info.get('start'), scale=1000)
224 end = int_or_none(info.get('end'), scale=1000)
225 duration = end - start if end and start else None
227 'id': loop_stream_id.replace('.mp3', ''),
228 'url': 'https://loopstream01.apa.at/?channel=%s&id=%s' % (self._LOOP_STATION, loop_stream_id),
230 'description': clean_html(data.get('subtitle')),
231 'duration': duration,
234 'series': data.get('programTitle'),
240 'title': data.get('title'),
241 'description': clean_html(data.get('subtitle')),
246 class ORFFM4IE(ORFRadioIE):
248 IE_DESC = 'radio FM4'
249 _VALID_URL = r'https?://(?P<station>fm4)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>4\w+)'
251 _LOOP_STATION = 'fm4'
254 'url': 'http://fm4.orf.at/player/20170107/4CC',
255 'md5': '2b0be47375432a7ef104453432a19212',
257 'id': '2017-01-07_2100_tl_54_7DaysSat18_31295',
259 'title': 'Solid Steel Radioshow',
260 'description': 'Die Mixshow von Coldcut und Ninja Tune.',
262 'timestamp': 1483819257,
263 'upload_date': '20170107',
265 'skip': 'Shows from ORF radios are only available for 7 days.',
266 'only_matching': True,
270 class ORFNOEIE(ORFRadioIE):
272 IE_DESC = 'Radio Niederösterreich'
273 _VALID_URL = r'https?://(?P<station>noe)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)'
275 _LOOP_STATION = 'oe2n'
278 'url': 'https://noe.orf.at/player/20200423/NGM',
279 'only_matching': True,
283 class ORFWIEIE(ORFRadioIE):
285 IE_DESC = 'Radio Wien'
286 _VALID_URL = r'https?://(?P<station>wien)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)'
288 _LOOP_STATION = 'oe2w'
291 'url': 'https://wien.orf.at/player/20200423/WGUM',
292 'only_matching': True,
296 class ORFBGLIE(ORFRadioIE):
297 IE_NAME = 'orf:burgenland'
298 IE_DESC = 'Radio Burgenland'
299 _VALID_URL = r'https?://(?P<station>burgenland)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)'
301 _LOOP_STATION = 'oe2b'
304 'url': 'https://burgenland.orf.at/player/20200423/BGM',
305 'only_matching': True,
309 class ORFOOEIE(ORFRadioIE):
310 IE_NAME = 'orf:oberoesterreich'
311 IE_DESC = 'Radio Oberösterreich'
312 _VALID_URL = r'https?://(?P<station>ooe)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)'
314 _LOOP_STATION = 'oe2o'
317 'url': 'https://ooe.orf.at/player/20200423/OGMO',
318 'only_matching': True,
322 class ORFSTMIE(ORFRadioIE):
323 IE_NAME = 'orf:steiermark'
324 IE_DESC = 'Radio Steiermark'
325 _VALID_URL = r'https?://(?P<station>steiermark)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)'
327 _LOOP_STATION = 'oe2st'
330 'url': 'https://steiermark.orf.at/player/20200423/STGMS',
331 'only_matching': True,
335 class ORFKTNIE(ORFRadioIE):
336 IE_NAME = 'orf:kaernten'
337 IE_DESC = 'Radio Kärnten'
338 _VALID_URL = r'https?://(?P<station>kaernten)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)'
340 _LOOP_STATION = 'oe2k'
343 'url': 'https://kaernten.orf.at/player/20200423/KGUMO',
344 'only_matching': True,
348 class ORFSBGIE(ORFRadioIE):
349 IE_NAME = 'orf:salzburg'
350 IE_DESC = 'Radio Salzburg'
351 _VALID_URL = r'https?://(?P<station>salzburg)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)'
353 _LOOP_STATION = 'oe2s'
356 'url': 'https://salzburg.orf.at/player/20200423/SGUM',
357 'only_matching': True,
361 class ORFTIRIE(ORFRadioIE):
362 IE_NAME = 'orf:tirol'
363 IE_DESC = 'Radio Tirol'
364 _VALID_URL = r'https?://(?P<station>tirol)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)'
366 _LOOP_STATION = 'oe2t'
369 'url': 'https://tirol.orf.at/player/20200423/TGUMO',
370 'only_matching': True,
374 class ORFVBGIE(ORFRadioIE):
375 IE_NAME = 'orf:vorarlberg'
376 IE_DESC = 'Radio Vorarlberg'
377 _VALID_URL = r'https?://(?P<station>vorarlberg)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)'
379 _LOOP_STATION = 'oe2v'
382 'url': 'https://vorarlberg.orf.at/player/20200423/VGUM',
383 'only_matching': True,
387 class ORFOE3IE(ORFRadioIE):
389 IE_DESC = 'Radio Österreich 3'
390 _VALID_URL = r'https?://(?P<station>oe3)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)'
392 _LOOP_STATION = 'oe3'
395 'url': 'https://oe3.orf.at/player/20200424/3WEK',
396 'only_matching': True,
400 class ORFOE1IE(ORFRadioIE):
402 IE_DESC = 'Radio Österreich 1'
403 _VALID_URL = r'https?://(?P<station>oe1)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)'
405 _LOOP_STATION = 'oe1'
408 'url': 'http://oe1.orf.at/player/20170108/456544',
409 'md5': '34d8a6e67ea888293741c86a099b745b',
411 'id': '2017-01-08_0759_tl_51_7DaysSun6_256141',
413 'title': 'Morgenjournal',
415 'timestamp': 1483858796,
416 'upload_date': '20170108',
418 'skip': 'Shows from ORF radios are only available for 7 days.'
422 class ORFIPTVIE(InfoExtractor):
424 IE_DESC = 'iptv.ORF.at'
425 _VALID_URL = r'https?://iptv\.orf\.at/(?:#/)?stories/(?P<id>\d+)'
428 'url': 'http://iptv.orf.at/stories/2275236/',
429 'md5': 'c8b22af4718a4b4af58342529453e3e5',
433 'title': 'Weitere Evakuierungen um Vulkan Calbuco',
434 'description': 'md5:d689c959bdbcf04efeddedbf2299d633',
436 'thumbnail': r're:^https?://.*\.jpg$',
437 'upload_date': '20150425',
441 def _real_extract(self, url):
442 story_id = self._match_id(url)
444 webpage = self._download_webpage(
445 'http://iptv.orf.at/stories/%s' % story_id, story_id)
447 video_id = self._search_regex(
448 r'data-video(?:id)?="(\d
+)"', webpage, 'video id')
450 data = self._download_json(
451 'http://bits.orf.at/filehandler/static-api/json/current/data.json?file=%s' % video_id,
454 duration = float_or_none(data['duration'], 1000)
456 video = data['sources']['default']
457 load_balancer_url = video['loadBalancerUrl']
458 abr = int_or_none(video.get('audioBitrate'))
459 vbr = int_or_none(video.get('bitrate'))
460 fps = int_or_none(video.get('videoFps'))
461 width = int_or_none(video.get('videoWidth'))
462 height = int_or_none(video.get('videoHeight'))
463 thumbnail = video.get('preview')
465 rendition = self._download_json(
466 load_balancer_url, video_id, transform_source=strip_jsonp)
477 for format_id, format_url in rendition['redirect'].items():
478 if format_id == 'rtmp':
482 'format_id': format_id,
485 elif determine_ext(format_url) == 'f4m':
486 formats.extend(self._extract_f4m_formats(
487 format_url, video_id, f4m_id=format_id))
488 elif determine_ext(format_url) == 'm3u8':
489 formats.extend(self._extract_m3u8_formats(
490 format_url, video_id, 'mp4', m3u8_id=format_id))
493 self._sort_formats(formats)
495 title = remove_end(self._og_search_title(webpage), ' - iptv.ORF.at')
496 description = self._og_search_description(webpage)
497 upload_date = unified_strdate(self._html_search_meta(
498 'dc.date', webpage, 'upload date'))
503 'description': description,
504 'duration': duration,
505 'thumbnail': thumbnail,
506 'upload_date': upload_date,
511 class ORFFM4StoryIE(InfoExtractor):
512 IE_NAME = 'orf:fm4:story'
513 IE_DESC = 'fm4.orf.at stories'
514 _VALID_URL = r'https?://fm4\.orf\.at/stories/(?P<id>\d+)'
517 'url': 'http://fm4.orf.at/stories/2865738/',
519 'md5': 'e1c2c706c45c7b34cf478bbf409907ca',
523 'title': 'Manu Delago und Inner Tongue live',
524 '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.',
526 'thumbnail': r're:^https?://.*\.jpg$',
527 'upload_date': '20170913',
530 'md5': 'c6dd2179731f86f4f55a7b49899d515f',
534 'title': 'Manu Delago und Inner Tongue live (2)',
536 'thumbnail': r're:^https?://.*\.jpg$',
537 'upload_date': '20170913',
538 '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.',
543 def _real_extract(self, url):
544 story_id = self._match_id(url)
545 webpage = self._download_webpage(url, story_id)
548 all_ids = orderedSet(re.findall(r'data-video(?:id)?="(\d
+)"', webpage))
549 for idx, video_id in enumerate(all_ids):
550 data = self._download_json(
551 'http://bits.orf.at/filehandler/static-api/json/current/data.json?file=%s' % video_id,
554 duration = float_or_none(data['duration'], 1000)
556 video = data['sources']['q8c']
557 load_balancer_url = video['loadBalancerUrl']
558 abr = int_or_none(video.get('audioBitrate'))
559 vbr = int_or_none(video.get('bitrate'))
560 fps = int_or_none(video.get('videoFps'))
561 width = int_or_none(video.get('videoWidth'))
562 height = int_or_none(video.get('videoHeight'))
563 thumbnail = video.get('preview')
565 rendition = self._download_json(
566 load_balancer_url, video_id, transform_source=strip_jsonp)
577 for format_id, format_url in rendition['redirect'].items():
578 if format_id == 'rtmp':
582 'format_id': format_id,
585 elif determine_ext(format_url) == 'f4m':
586 formats.extend(self._extract_f4m_formats(
587 format_url, video_id, f4m_id=format_id))
588 elif determine_ext(format_url) == 'm3u8':
589 formats.extend(self._extract_m3u8_formats(
590 format_url, video_id, 'mp4', m3u8_id=format_id))
593 self._sort_formats(formats)
595 title = remove_end(self._og_search_title(webpage), ' - fm4.ORF.at')
597 # Titles are duplicates, make them unique
598 title += ' (' + str(idx + 1) + ')'
599 description = self._og_search_description(webpage)
600 upload_date = unified_strdate(self._html_search_meta(
601 'dc.date', webpage, 'upload date'))
606 'description': description,
607 'duration': duration,
608 'thumbnail': thumbnail,
609 'upload_date': upload_date,
613 return self.playlist_result(entries)