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')
164 data = self._download_json(
165 'http://audioapi.orf.at/%s/api/json/current/broadcast/%s/%s' % (station, show_id, show_date),
169 def extract_entry_dict(info, title, subtitle):
171 'id': info['loopStreamId'].replace('.mp3', ''),
172 'url': 'http://loopstream01.apa.at/?channel=%s&id=%s' % (station, info['loopStreamId']),
174 'description': subtitle,
175 'duration': (info['end'] - info['start']) / 1000,
176 'timestamp': info['start'] / 1000,
178 'series': data.get('programTitle')
181 entries = [extract_entry_dict(t, data['title'], data['subtitle']) for t in data['streams']]
186 'title': data['title'],
187 'description': data['subtitle'],
192 class ORFFM4IE(ORFRadioIE):
194 IE_DESC = 'radio FM4'
195 _VALID_URL = r'https?://(?P<station>fm4)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>4\w+)'
198 'url': 'http://fm4.orf.at/player/20170107/4CC',
199 'md5': '2b0be47375432a7ef104453432a19212',
201 'id': '2017-01-07_2100_tl_54_7DaysSat18_31295',
203 'title': 'Solid Steel Radioshow',
204 'description': 'Die Mixshow von Coldcut und Ninja Tune.',
206 'timestamp': 1483819257,
207 'upload_date': '20170107',
209 'skip': 'Shows from ORF radios are only available for 7 days.'
213 class ORFOE1IE(ORFRadioIE):
215 IE_DESC = 'Radio Österreich 1'
216 _VALID_URL = r'https?://(?P<station>oe1)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)'
219 'url': 'http://oe1.orf.at/player/20170108/456544',
220 'md5': '34d8a6e67ea888293741c86a099b745b',
222 'id': '2017-01-08_0759_tl_51_7DaysSun6_256141',
224 'title': 'Morgenjournal',
226 'timestamp': 1483858796,
227 'upload_date': '20170108',
229 'skip': 'Shows from ORF radios are only available for 7 days.'
233 class ORFIPTVIE(InfoExtractor):
235 IE_DESC = 'iptv.ORF.at'
236 _VALID_URL = r'https?://iptv\.orf\.at/(?:#/)?stories/(?P<id>\d+)'
239 'url': 'http://iptv.orf.at/stories/2275236/',
240 'md5': 'c8b22af4718a4b4af58342529453e3e5',
244 'title': 'Weitere Evakuierungen um Vulkan Calbuco',
245 'description': 'md5:d689c959bdbcf04efeddedbf2299d633',
247 'thumbnail': r're:^https?://.*\.jpg$',
248 'upload_date': '20150425',
252 def _real_extract(self, url):
253 story_id = self._match_id(url)
255 webpage = self._download_webpage(
256 'http://iptv.orf.at/stories/%s' % story_id, story_id)
258 video_id = self._search_regex(
259 r'data-video(?:id)?="(\d+)"', webpage, 'video id')
261 data = self._download_json(
262 'http://bits.orf.at/filehandler/static-api/json/current/data.json?file=%s' % video_id,
265 duration = float_or_none(data['duration'], 1000)
267 video = data['sources']['default']
268 load_balancer_url = video['loadBalancerUrl']
269 abr = int_or_none(video.get('audioBitrate'))
270 vbr = int_or_none(video.get('bitrate'))
271 fps = int_or_none(video.get('videoFps'))
272 width = int_or_none(video.get('videoWidth'))
273 height = int_or_none(video.get('videoHeight'))
274 thumbnail = video.get('preview')
276 rendition = self._download_json(
277 load_balancer_url, video_id, transform_source=strip_jsonp)
288 for format_id, format_url in rendition['redirect'].items():
289 if format_id == 'rtmp':
293 'format_id': format_id,
296 elif determine_ext(format_url) == 'f4m':
297 formats.extend(self._extract_f4m_formats(
298 format_url, video_id, f4m_id=format_id))
299 elif determine_ext(format_url) == 'm3u8':
300 formats.extend(self._extract_m3u8_formats(
301 format_url, video_id, 'mp4', m3u8_id=format_id))
304 self._sort_formats(formats)
306 title = remove_end(self._og_search_title(webpage), ' - iptv.ORF.at')
307 description = self._og_search_description(webpage)
308 upload_date = unified_strdate(self._html_search_meta(
309 'dc.date', webpage, 'upload date'))
314 'description': description,
315 'duration': duration,
316 'thumbnail': thumbnail,
317 'upload_date': upload_date,
322 class ORFFM4StoryIE(InfoExtractor):
323 IE_NAME = 'orf:fm4:story'
324 IE_DESC = 'fm4.orf.at stories'
325 _VALID_URL = r'https?://fm4\.orf\.at/stories/(?P<id>\d+)'
328 'url': 'http://fm4.orf.at/stories/2865738/',
330 'md5': 'e1c2c706c45c7b34cf478bbf409907ca',
334 'title': 'Manu Delago und Inner Tongue live',
335 '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.',
337 'thumbnail': r're:^https?://.*\.jpg$',
338 'upload_date': '20170913',
341 'md5': 'c6dd2179731f86f4f55a7b49899d515f',
345 'title': 'Manu Delago und Inner Tongue live (2)',
347 'thumbnail': r're:^https?://.*\.jpg$',
348 'upload_date': '20170913',
349 '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.',
354 def _real_extract(self, url):
355 story_id = self._match_id(url)
356 webpage = self._download_webpage(url, story_id)
359 all_ids = orderedSet(re.findall(r'data-video(?:id)?="(\d+)"', webpage))
360 for idx, video_id in enumerate(all_ids):
361 data = self._download_json(
362 'http://bits.orf.at/filehandler/static-api/json/current/data.json?file=%s' % video_id,
365 duration = float_or_none(data['duration'], 1000)
367 video = data['sources']['q8c']
368 load_balancer_url = video['loadBalancerUrl']
369 abr = int_or_none(video.get('audioBitrate'))
370 vbr = int_or_none(video.get('bitrate'))
371 fps = int_or_none(video.get('videoFps'))
372 width = int_or_none(video.get('videoWidth'))
373 height = int_or_none(video.get('videoHeight'))
374 thumbnail = video.get('preview')
376 rendition = self._download_json(
377 load_balancer_url, video_id, transform_source=strip_jsonp)
388 for format_id, format_url in rendition['redirect'].items():
389 if format_id == 'rtmp':
393 'format_id': format_id,
396 elif determine_ext(format_url) == 'f4m':
397 formats.extend(self._extract_f4m_formats(
398 format_url, video_id, f4m_id=format_id))
399 elif determine_ext(format_url) == 'm3u8':
400 formats.extend(self._extract_m3u8_formats(
401 format_url, video_id, 'mp4', m3u8_id=format_id))
404 self._sort_formats(formats)
406 title = remove_end(self._og_search_title(webpage), ' - fm4.ORF.at')
408 # Titles are duplicates, make them unique
409 title += ' (' + str(idx + 1) + ')'
410 description = self._og_search_description(webpage)
411 upload_date = unified_strdate(self._html_search_meta(
412 'dc.date', webpage, 'upload date'))
417 'description': description,
418 'duration': duration,
419 'thumbnail': thumbnail,
420 'upload_date': upload_date,
424 return self.playlist_result(entries)