2 from __future__ import unicode_literals
6 from .common import InfoExtractor
7 from ..compat import compat_str
22 class ORFTVthekIE(InfoExtractor):
23 IE_NAME = 'orf:tvthek'
24 IE_DESC = 'ORF TVthek'
25 _VALID_URL = r'https?://tvthek\.orf\.at/(?:[^/]+/)+(?P<id>\d+)'
28 'url': 'http://tvthek.orf.at/program/Aufgetischt/2745173/Aufgetischt-Mit-der-Steirischen-Tafelrunde/8891389',
30 'md5': '2942210346ed779588f428a92db88712',
34 'title': 'Aufgetischt: Mit der Steirischen Tafelrunde',
35 'description': 'md5:c1272f0245537812d4e36419c207b67d',
37 'upload_date': '20141208',
40 'skip': 'Blocked outside of Austria / Germany',
42 'url': 'http://tvthek.orf.at/topic/Im-Wandel-der-Zeit/8002126/Best-of-Ingrid-Thurnher/7982256',
46 'title': 'Best of Ingrid Thurnher',
47 'upload_date': '20140527',
48 '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".',
51 'skip_download': True, # rtsp downloads
53 'skip': 'Blocked outside of Austria / Germany',
55 'url': 'http://tvthek.orf.at/topic/Fluechtlingskrise/10463081/Heimat-Fremde-Heimat/13879132/Senioren-betreuen-Migrantenkinder/13879141',
56 'only_matching': True,
58 'url': 'http://tvthek.orf.at/profile/Universum/35429',
59 'only_matching': True,
62 def _real_extract(self, url):
63 playlist_id = self._match_id(url)
64 webpage = self._download_webpage(url, playlist_id)
66 data_jsb = self._parse_json(
68 r'<div[^>]+class=(["\']).*?VideoPlaylist.*?\1[^>]+data-jsb=(["\'])(?P<json>.+?)\2',
69 webpage, 'playlist', group='json'),
70 playlist_id, transform_source=unescapeHTML)['playlist']['videos']
74 video_id, title = sd.get('id'), sd.get('title')
75 if not video_id or not title:
77 video_id = compat_str(video_id)
79 for fd in sd['sources']:
80 src = url_or_none(fd.get('src'))
84 for key in ('delivery', 'quality', 'quality_string'):
87 format_id_list.append(value)
88 format_id = '-'.join(format_id_list)
89 ext = determine_ext(src)
91 formats.extend(self._extract_m3u8_formats(
92 src, video_id, 'mp4', m3u8_id=format_id, fatal=False))
94 formats.extend(self._extract_f4m_formats(
95 src, video_id, f4m_id=format_id, fatal=False))
98 'format_id': format_id,
100 'protocol': fd.get('protocol'),
103 # Check for geoblocking.
104 # There is a property is_geoprotection, but that's always false
105 geo_str = sd.get('geoprotection_string')
111 if re.match(r'^https?://.*\.mp4$', f['url']))
112 except StopIteration:
115 req = HEADRequest(http_url)
116 self._request_webpage(
118 note='Testing for geoblocking',
120 'This video seems to be blocked outside of %s. '
121 'You may want to try the streaming-* formats.')
125 self._check_formats(formats, video_id)
126 self._sort_formats(formats)
129 for sub in sd.get('subtitles', []):
130 sub_src = sub.get('src')
133 subtitles.setdefault(sub.get('lang', 'de-AT'), []).append({
137 upload_date = unified_strdate(sd.get('created_date'))
143 'subtitles': subtitles,
144 'description': sd.get('description'),
145 'duration': int_or_none(sd.get('duration_in_seconds')),
146 'upload_date': upload_date,
147 'thumbnail': sd.get('image_full_url'),
157 class ORFRadioIE(InfoExtractor):
158 def _real_extract(self, url):
159 mobj = re.match(self._VALID_URL, url)
160 station = mobj.group('station')
161 show_date = mobj.group('date')
162 show_id = mobj.group('show')
165 show_id = '4%s' % show_id
167 data = self._download_json(
168 'http://audioapi.orf.at/%s/api/json/current/broadcast/%s/%s' % (station, show_id, show_date),
172 def extract_entry_dict(info, title, subtitle):
174 'id': info['loopStreamId'].replace('.mp3', ''),
175 'url': 'http://loopstream01.apa.at/?channel=%s&id=%s' % (station, info['loopStreamId']),
177 'description': subtitle,
178 'duration': (info['end'] - info['start']) / 1000,
179 'timestamp': info['start'] / 1000,
181 'series': data.get('programTitle')
184 entries = [extract_entry_dict(t, data['title'], data['subtitle']) for t in data['streams']]
189 'title': data['title'],
190 'description': data['subtitle'],
195 class ORFFM4IE(ORFRadioIE):
197 IE_DESC = 'radio FM4'
198 _VALID_URL = r'https?://(?P<station>fm4)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)'
201 'url': 'http://fm4.orf.at/player/20170107/CC',
202 'md5': '2b0be47375432a7ef104453432a19212',
204 'id': '2017-01-07_2100_tl_54_7DaysSat18_31295',
206 'title': 'Solid Steel Radioshow',
207 'description': 'Die Mixshow von Coldcut und Ninja Tune.',
209 'timestamp': 1483819257,
210 'upload_date': '20170107',
212 'skip': 'Shows from ORF radios are only available for 7 days.'
216 class ORFOE1IE(ORFRadioIE):
218 IE_DESC = 'Radio Österreich 1'
219 _VALID_URL = r'https?://(?P<station>oe1)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)'
222 'url': 'http://oe1.orf.at/player/20170108/456544',
223 'md5': '34d8a6e67ea888293741c86a099b745b',
225 'id': '2017-01-08_0759_tl_51_7DaysSun6_256141',
227 'title': 'Morgenjournal',
229 'timestamp': 1483858796,
230 'upload_date': '20170108',
232 'skip': 'Shows from ORF radios are only available for 7 days.'
236 class ORFIPTVIE(InfoExtractor):
238 IE_DESC = 'iptv.ORF.at'
239 _VALID_URL = r'https?://iptv\.orf\.at/(?:#/)?stories/(?P<id>\d+)'
242 'url': 'http://iptv.orf.at/stories/2275236/',
243 'md5': 'c8b22af4718a4b4af58342529453e3e5',
247 'title': 'Weitere Evakuierungen um Vulkan Calbuco',
248 'description': 'md5:d689c959bdbcf04efeddedbf2299d633',
250 'thumbnail': r're:^https?://.*\.jpg$',
251 'upload_date': '20150425',
255 def _real_extract(self, url):
256 story_id = self._match_id(url)
258 webpage = self._download_webpage(
259 'http://iptv.orf.at/stories/%s' % story_id, story_id)
261 video_id = self._search_regex(
262 r'data-video(?:id)?="(\d+)"', webpage, 'video id')
264 data = self._download_json(
265 'http://bits.orf.at/filehandler/static-api/json/current/data.json?file=%s' % video_id,
268 duration = float_or_none(data['duration'], 1000)
270 video = data['sources']['default']
271 load_balancer_url = video['loadBalancerUrl']
272 abr = int_or_none(video.get('audioBitrate'))
273 vbr = int_or_none(video.get('bitrate'))
274 fps = int_or_none(video.get('videoFps'))
275 width = int_or_none(video.get('videoWidth'))
276 height = int_or_none(video.get('videoHeight'))
277 thumbnail = video.get('preview')
279 rendition = self._download_json(
280 load_balancer_url, video_id, transform_source=strip_jsonp)
291 for format_id, format_url in rendition['redirect'].items():
292 if format_id == 'rtmp':
296 'format_id': format_id,
299 elif determine_ext(format_url) == 'f4m':
300 formats.extend(self._extract_f4m_formats(
301 format_url, video_id, f4m_id=format_id))
302 elif determine_ext(format_url) == 'm3u8':
303 formats.extend(self._extract_m3u8_formats(
304 format_url, video_id, 'mp4', m3u8_id=format_id))
307 self._sort_formats(formats)
309 title = remove_end(self._og_search_title(webpage), ' - iptv.ORF.at')
310 description = self._og_search_description(webpage)
311 upload_date = unified_strdate(self._html_search_meta(
312 'dc.date', webpage, 'upload date'))
317 'description': description,
318 'duration': duration,
319 'thumbnail': thumbnail,
320 'upload_date': upload_date,
325 class ORFFM4StoryIE(InfoExtractor):
326 IE_NAME = 'orf:fm4:story'
327 IE_DESC = 'fm4.orf.at stories'
328 _VALID_URL = r'https?://fm4\.orf\.at/stories/(?P<id>\d+)'
331 'url': 'http://fm4.orf.at/stories/2865738/',
333 'md5': 'e1c2c706c45c7b34cf478bbf409907ca',
337 'title': 'Manu Delago und Inner Tongue live',
338 '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.',
340 'thumbnail': r're:^https?://.*\.jpg$',
341 'upload_date': '20170913',
344 'md5': 'c6dd2179731f86f4f55a7b49899d515f',
348 'title': 'Manu Delago und Inner Tongue live (2)',
350 'thumbnail': r're:^https?://.*\.jpg$',
351 'upload_date': '20170913',
352 '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.',
357 def _real_extract(self, url):
358 story_id = self._match_id(url)
359 webpage = self._download_webpage(url, story_id)
362 all_ids = orderedSet(re.findall(r'data-video(?:id)?="(\d+)"', webpage))
363 for idx, video_id in enumerate(all_ids):
364 data = self._download_json(
365 'http://bits.orf.at/filehandler/static-api/json/current/data.json?file=%s' % video_id,
368 duration = float_or_none(data['duration'], 1000)
370 video = data['sources']['q8c']
371 load_balancer_url = video['loadBalancerUrl']
372 abr = int_or_none(video.get('audioBitrate'))
373 vbr = int_or_none(video.get('bitrate'))
374 fps = int_or_none(video.get('videoFps'))
375 width = int_or_none(video.get('videoWidth'))
376 height = int_or_none(video.get('videoHeight'))
377 thumbnail = video.get('preview')
379 rendition = self._download_json(
380 load_balancer_url, video_id, transform_source=strip_jsonp)
391 for format_id, format_url in rendition['redirect'].items():
392 if format_id == 'rtmp':
396 'format_id': format_id,
399 elif determine_ext(format_url) == 'f4m':
400 formats.extend(self._extract_f4m_formats(
401 format_url, video_id, f4m_id=format_id))
402 elif determine_ext(format_url) == 'm3u8':
403 formats.extend(self._extract_m3u8_formats(
404 format_url, video_id, 'mp4', m3u8_id=format_id))
407 self._sort_formats(formats)
409 title = remove_end(self._og_search_title(webpage), ' - fm4.ORF.at')
411 # Titles are duplicates, make them unique
412 title += ' (' + str(idx + 1) + ')'
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,
427 return self.playlist_result(entries)