]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/orf.py
2 from __future__
import unicode_literals
6 from . common
import InfoExtractor
7 from .. compat
import compat_str
24 class ORFTVthekIE ( InfoExtractor
):
25 IE_NAME
= 'orf:tvthek'
26 IE_DESC
= 'ORF TVthek'
27 _VALID_URL
= r
'https?://tvthek\.orf\.at/(?:[^/]+/)+(?P<id>\d+)'
30 'url' : 'http://tvthek.orf.at/program/Aufgetischt/2745173/Aufgetischt-Mit-der-Steirischen-Tafelrunde/8891389' ,
32 'md5' : '2942210346ed779588f428a92db88712' ,
36 'title' : 'Aufgetischt: Mit der Steirischen Tafelrunde' ,
37 'description' : 'md5:c1272f0245537812d4e36419c207b67d' ,
39 'upload_date' : '20141208' ,
42 'skip' : 'Blocked outside of Austria / Germany' ,
44 'url' : 'http://tvthek.orf.at/topic/Im-Wandel-der-Zeit/8002126/Best-of-Ingrid-Thurnher/7982256' ,
48 'title' : 'Best of Ingrid Thurnher' ,
49 'upload_date' : '20140527' ,
50 '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".' ,
53 'skip_download' : True , # rtsp downloads
55 'skip' : 'Blocked outside of Austria / Germany' ,
57 'url' : 'http://tvthek.orf.at/topic/Fluechtlingskrise/10463081/Heimat-Fremde-Heimat/13879132/Senioren-betreuen-Migrantenkinder/13879141' ,
58 'only_matching' : True ,
60 'url' : 'http://tvthek.orf.at/profile/Universum/35429' ,
61 'only_matching' : True ,
64 def _real_extract ( self
, url
):
65 playlist_id
= self
._ match
_ id
( url
)
66 webpage
= self
._ download
_ webpage
( url
, playlist_id
)
68 data_jsb
= self
._ parse
_ json
(
70 r
'<div[^>]+class=(["\' ]).* ?VideoPlaylist
.* ?\
1 [ ^
>]+ data
- jsb
=([ " \' ])(?P<json>.+?)\2',
71 webpage, 'playlist', group='json'),
72 playlist_id, transform_source=unescapeHTML)['playlist']['videos']
76 video_id, title = sd.get('id'), sd.get('title')
77 if not video_id or not title:
79 video_id = compat_str(video_id)
81 for fd in sd['sources']:
82 src = url_or_none(fd.get('src'))
86 for key in ('delivery', 'quality', 'quality_string'):
89 format_id_list.append(value)
90 format_id = '-'.join(format_id_list)
91 ext = determine_ext(src)
93 m3u8_formats = self._extract_m3u8_formats(
94 src, video_id, 'mp4', m3u8_id=format_id, fatal=False)
95 if any('/geoprotection' in f['url'] for f in m3u8_formats):
96 self.raise_geo_restricted()
97 formats.extend(m3u8_formats)
99 formats.extend(self._extract_f4m_formats(
100 src, video_id, f4m_id=format_id, fatal=False))
102 formats.extend(self._extract_mpd_formats(
103 src, video_id, mpd_id=format_id, fatal=False))
106 'format_id': format_id,
108 'protocol': fd.get('protocol'),
111 # Check for geoblocking.
112 # There is a property is_geoprotection, but that's always false
113 geo_str = sd.get('geoprotection_string')
119 if re.match(r'^https?://.*\.mp4$', f['url']))
120 except StopIteration:
123 req = HEADRequest(http_url)
124 self._request_webpage(
126 note='Testing for geoblocking',
128 'This video seems to be blocked outside of %s . '
129 'You may want to try the streaming-* formats.')
133 self._check_formats(formats, video_id)
134 self._sort_formats(formats)
137 for sub in sd.get('subtitles', []):
138 sub_src = sub.get('src')
141 subtitles.setdefault(sub.get('lang', 'de-AT'), []).append({
145 upload_date = unified_strdate(sd.get('created_date'))
148 preview = sd.get('preview_image_url')
155 image = sd.get('image_full_url')
156 if not image and len(data_jsb) == 1:
157 image = self._og_search_thumbnail(webpage)
170 'subtitles': subtitles,
171 'description': sd.get('description'),
172 'duration': int_or_none(sd.get('duration_in_seconds')),
173 'upload_date': upload_date,
174 'thumbnails': thumbnails,
184 class ORFRadioIE(InfoExtractor):
185 def _real_extract(self, url):
186 mobj = self._match_valid_url(url)
187 show_date = mobj.group('date')
188 show_id = mobj.group('show')
190 data = self._download_json(
191 'http://audioapi.orf.at/ %s /api/json/current/broadcast/ %s / %s '
192 % (self._API_STATION, show_id, show_date), show_id)
195 for info in data['streams']:
196 loop_stream_id = str_or_none(info.get('loopStreamId'))
197 if not loop_stream_id:
199 title = str_or_none(data.get('title'))
202 start = int_or_none(info.get('start'), scale=1000)
203 end = int_or_none(info.get('end'), scale=1000)
204 duration = end - start if end and start else None
206 'id': loop_stream_id.replace('.mp3', ''),
207 'url': 'https://loopstream01.apa.at/?channel= %s &id= %s ' % (self._LOOP_STATION, loop_stream_id),
209 'description': clean_html(data.get('subtitle')),
210 'duration': duration,
213 'series': data.get('programTitle'),
219 'title': data.get('title'),
220 'description': clean_html(data.get('subtitle')),
225 class ORFFM4IE(ORFRadioIE):
227 IE_DESC = 'radio FM4'
228 _VALID_URL = r'https?://(?P<station>fm4)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>4\w+)'
230 _LOOP_STATION = 'fm4'
233 'url': 'http://fm4.orf.at/player/20170107/4CC',
234 'md5': '2b0be47375432a7ef104453432a19212',
236 'id': '2017-01-07_2100_tl_54_7DaysSat18_31295',
238 'title': 'Solid Steel Radioshow',
239 'description': 'Die Mixshow von Coldcut und Ninja Tune.',
241 'timestamp': 1483819257,
242 'upload_date': '20170107',
244 'skip': 'Shows from ORF radios are only available for 7 days.',
245 'only_matching': True,
249 class ORFNOEIE(ORFRadioIE):
251 IE_DESC = 'Radio Niederösterreich'
252 _VALID_URL = r'https?://(?P<station>noe)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)'
254 _LOOP_STATION = 'oe2n'
257 'url': 'https://noe.orf.at/player/20200423/NGM',
258 'only_matching': True,
262 class ORFWIEIE(ORFRadioIE):
264 IE_DESC = 'Radio Wien'
265 _VALID_URL = r'https?://(?P<station>wien)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)'
267 _LOOP_STATION = 'oe2w'
270 'url': 'https://wien.orf.at/player/20200423/WGUM',
271 'only_matching': True,
275 class ORFBGLIE(ORFRadioIE):
276 IE_NAME = 'orf:burgenland'
277 IE_DESC = 'Radio Burgenland'
278 _VALID_URL = r'https?://(?P<station>burgenland)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)'
280 _LOOP_STATION = 'oe2b'
283 'url': 'https://burgenland.orf.at/player/20200423/BGM',
284 'only_matching': True,
288 class ORFOOEIE(ORFRadioIE):
289 IE_NAME = 'orf:oberoesterreich'
290 IE_DESC = 'Radio Oberösterreich'
291 _VALID_URL = r'https?://(?P<station>ooe)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)'
293 _LOOP_STATION = 'oe2o'
296 'url': 'https://ooe.orf.at/player/20200423/OGMO',
297 'only_matching': True,
301 class ORFSTMIE(ORFRadioIE):
302 IE_NAME = 'orf:steiermark'
303 IE_DESC = 'Radio Steiermark'
304 _VALID_URL = r'https?://(?P<station>steiermark)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)'
306 _LOOP_STATION = 'oe2st'
309 'url': 'https://steiermark.orf.at/player/20200423/STGMS',
310 'only_matching': True,
314 class ORFKTNIE(ORFRadioIE):
315 IE_NAME = 'orf:kaernten'
316 IE_DESC = 'Radio Kärnten'
317 _VALID_URL = r'https?://(?P<station>kaernten)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)'
319 _LOOP_STATION = 'oe2k'
322 'url': 'https://kaernten.orf.at/player/20200423/KGUMO',
323 'only_matching': True,
327 class ORFSBGIE(ORFRadioIE):
328 IE_NAME = 'orf:salzburg'
329 IE_DESC = 'Radio Salzburg'
330 _VALID_URL = r'https?://(?P<station>salzburg)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)'
332 _LOOP_STATION = 'oe2s'
335 'url': 'https://salzburg.orf.at/player/20200423/SGUM',
336 'only_matching': True,
340 class ORFTIRIE(ORFRadioIE):
341 IE_NAME = 'orf:tirol'
342 IE_DESC = 'Radio Tirol'
343 _VALID_URL = r'https?://(?P<station>tirol)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)'
345 _LOOP_STATION = 'oe2t'
348 'url': 'https://tirol.orf.at/player/20200423/TGUMO',
349 'only_matching': True,
353 class ORFVBGIE(ORFRadioIE):
354 IE_NAME = 'orf:vorarlberg'
355 IE_DESC = 'Radio Vorarlberg'
356 _VALID_URL = r'https?://(?P<station>vorarlberg)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)'
358 _LOOP_STATION = 'oe2v'
361 'url': 'https://vorarlberg.orf.at/player/20200423/VGUM',
362 'only_matching': True,
366 class ORFOE3IE(ORFRadioIE):
368 IE_DESC = 'Radio Österreich 3'
369 _VALID_URL = r'https?://(?P<station>oe3)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)'
371 _LOOP_STATION = 'oe3'
374 'url': 'https://oe3.orf.at/player/20200424/3WEK',
375 'only_matching': True,
379 class ORFOE1IE(ORFRadioIE):
381 IE_DESC = 'Radio Österreich 1'
382 _VALID_URL = r'https?://(?P<station>oe1)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)'
384 _LOOP_STATION = 'oe1'
387 'url': 'http://oe1.orf.at/player/20170108/456544',
388 'md5': '34d8a6e67ea888293741c86a099b745b',
390 'id': '2017-01-08_0759_tl_51_7DaysSun6_256141',
392 'title': 'Morgenjournal',
394 'timestamp': 1483858796,
395 'upload_date': '20170108',
397 'skip': 'Shows from ORF radios are only available for 7 days.'
401 class ORFIPTVIE(InfoExtractor):
403 IE_DESC = 'iptv.ORF.at'
404 _VALID_URL = r'https?://iptv\.orf\.at/(?:#/)?stories/(?P<id>\d+)'
407 'url': 'http://iptv.orf.at/stories/2275236/',
408 'md5': 'c8b22af4718a4b4af58342529453e3e5',
412 'title': 'Weitere Evakuierungen um Vulkan Calbuco',
413 'description': 'md5:d689c959bdbcf04efeddedbf2299d633',
415 'thumbnail': r're:^https?://.*\.jpg$',
416 'upload_date': '20150425',
420 def _real_extract(self, url):
421 story_id = self._match_id(url)
423 webpage = self._download_webpage(
424 'http://iptv.orf.at/stories/ %s ' % story_id, story_id)
426 video_id = self._search_regex(
427 r'data-video(?:id)?=" ( \d
+) "', webpage, 'video id')
429 data = self._download_json(
430 'http://bits.orf.at/filehandler/static-api/json/current/data.json?file= %s ' % video_id,
433 duration = float_or_none(data['duration'], 1000)
435 video = data['sources']['default']
436 load_balancer_url = video['loadBalancerUrl']
437 abr = int_or_none(video.get('audioBitrate'))
438 vbr = int_or_none(video.get('bitrate'))
439 fps = int_or_none(video.get('videoFps'))
440 width = int_or_none(video.get('videoWidth'))
441 height = int_or_none(video.get('videoHeight'))
442 thumbnail = video.get('preview')
444 rendition = self._download_json(
445 load_balancer_url, video_id, transform_source=strip_jsonp)
456 for format_id, format_url in rendition['redirect'].items():
457 if format_id == 'rtmp':
461 'format_id': format_id,
464 elif determine_ext(format_url) == 'f4m':
465 formats.extend(self._extract_f4m_formats(
466 format_url, video_id, f4m_id=format_id))
467 elif determine_ext(format_url) == 'm3u8':
468 formats.extend(self._extract_m3u8_formats(
469 format_url, video_id, 'mp4', m3u8_id=format_id))
472 self._sort_formats(formats)
474 title = remove_end(self._og_search_title(webpage), ' - iptv.ORF.at')
475 description = self._og_search_description(webpage)
476 upload_date = unified_strdate(self._html_search_meta(
477 'dc.date', webpage, 'upload date'))
482 'description': description,
483 'duration': duration,
484 'thumbnail': thumbnail,
485 'upload_date': upload_date,
490 class ORFFM4StoryIE(InfoExtractor):
491 IE_NAME = 'orf:fm4:story'
492 IE_DESC = 'fm4.orf.at stories'
493 _VALID_URL = r'https?://fm4\.orf\.at/stories/(?P<id>\d+)'
496 'url': 'http://fm4.orf.at/stories/2865738/',
498 'md5': 'e1c2c706c45c7b34cf478bbf409907ca',
502 'title': 'Manu Delago und Inner Tongue live',
503 '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.',
505 'thumbnail': r're:^https?://.*\.jpg$',
506 'upload_date': '20170913',
509 'md5': 'c6dd2179731f86f4f55a7b49899d515f',
513 'title': 'Manu Delago und Inner Tongue live (2)',
515 'thumbnail': r're:^https?://.*\.jpg$',
516 'upload_date': '20170913',
517 '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.',
522 def _real_extract(self, url):
523 story_id = self._match_id(url)
524 webpage = self._download_webpage(url, story_id)
527 all_ids = orderedSet(re.findall(r'data-video(?:id)?=" ( \d
+) "', webpage))
528 for idx, video_id in enumerate(all_ids):
529 data = self._download_json(
530 'http://bits.orf.at/filehandler/static-api/json/current/data.json?file= %s ' % video_id,
533 duration = float_or_none(data['duration'], 1000)
535 video = data['sources']['q8c']
536 load_balancer_url = video['loadBalancerUrl']
537 abr = int_or_none(video.get('audioBitrate'))
538 vbr = int_or_none(video.get('bitrate'))
539 fps = int_or_none(video.get('videoFps'))
540 width = int_or_none(video.get('videoWidth'))
541 height = int_or_none(video.get('videoHeight'))
542 thumbnail = video.get('preview')
544 rendition = self._download_json(
545 load_balancer_url, video_id, transform_source=strip_jsonp)
556 for format_id, format_url in rendition['redirect'].items():
557 if format_id == 'rtmp':
561 'format_id': format_id,
564 elif determine_ext(format_url) == 'f4m':
565 formats.extend(self._extract_f4m_formats(
566 format_url, video_id, f4m_id=format_id))
567 elif determine_ext(format_url) == 'm3u8':
568 formats.extend(self._extract_m3u8_formats(
569 format_url, video_id, 'mp4', m3u8_id=format_id))
572 self._sort_formats(formats)
574 title = remove_end(self._og_search_title(webpage), ' - fm4.ORF.at')
576 # Titles are duplicates, make them unique
577 title += ' (' + str(idx + 1) + ')'
578 description = self._og_search_description(webpage)
579 upload_date = unified_strdate(self._html_search_meta(
580 'dc.date', webpage, 'upload date'))
585 'description': description,
586 'duration': duration,
587 'thumbnail': thumbnail,
588 'upload_date': upload_date,
592 return self.playlist_result(entries)