]>
Commit | Line | Data |
---|---|---|
89284910 | 1 | # coding: utf-8 |
5d73273f | 2 | from __future__ import unicode_literals |
89284910 | 3 | |
b695e3f9 | 4 | import functools |
5d73273f | 5 | import re |
54543467 JMF |
6 | |
7 | from .common import InfoExtractor | |
8 | from ..utils import ( | |
aca2fd22 | 9 | clean_html, |
0732a905 PH |
10 | determine_ext, |
11 | float_or_none, | |
5d73273f | 12 | HEADRequest, |
b695e3f9 | 13 | InAdvancePagedList, |
14137b57 | 14 | int_or_none, |
34921b43 | 15 | join_nonempty, |
0732a905 | 16 | orderedSet, |
14137b57 | 17 | remove_end, |
b695e3f9 | 18 | smuggle_url, |
aca2fd22 | 19 | str_or_none, |
0732a905 | 20 | strip_jsonp, |
73c801d6 | 21 | unescapeHTML, |
0732a905 | 22 | unified_strdate, |
b695e3f9 | 23 | unsmuggle_url, |
4b6aca17 | 24 | url_or_none, |
54543467 JMF |
25 | ) |
26 | ||
5d73273f | 27 | |
eb368012 S |
28 | class ORFTVthekIE(InfoExtractor): |
29 | IE_NAME = 'orf:tvthek' | |
30 | IE_DESC = 'ORF TVthek' | |
b695e3f9 | 31 | _VALID_URL = r'(?P<url>https?://tvthek\.orf\.at/(?:(?:[^/]+/){2}){1,2}(?P<id>\d+))(/[^/]+/(?P<vid>\d+))?(?:$|[?#])' |
5d73273f | 32 | |
13d27a42 | 33 | _TESTS = [{ |
b695e3f9 | 34 | 'url': 'https://tvthek.orf.at/profile/ZIB-2/1211/ZIB-2/14121079', |
35 | 'info_dict': { | |
36 | 'id': '14121079', | |
37 | }, | |
38 | 'playlist_count': 11, | |
39 | 'params': {'noplaylist': True} | |
40 | }, { | |
41 | 'url': 'https://tvthek.orf.at/profile/ZIB-2/1211/ZIB-2/14121079/Umfrage-Welches-Tier-ist-Sebastian-Kurz/15083150', | |
42 | 'info_dict': { | |
43 | 'id': '14121079', | |
44 | }, | |
45 | 'playlist_count': 1, | |
46 | 'params': {'playlist_items': '5'} | |
47 | }, { | |
48 | 'url': 'https://tvthek.orf.at/profile/ZIB-2/1211/ZIB-2/14121079/Umfrage-Welches-Tier-ist-Sebastian-Kurz/15083150', | |
49 | 'info_dict': { | |
50 | 'id': '14121079', | |
51 | 'playlist_count': 1 | |
52 | }, | |
53 | 'playlist': [{ | |
54 | 'info_dict': { | |
55 | 'id': '15083150', | |
56 | 'ext': 'mp4', | |
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?', | |
60 | } | |
61 | }], | |
62 | 'playlist_count': 1, | |
63 | 'params': {'noplaylist': True, 'skip_download': 'm3u8'} | |
64 | }, { | |
a6620ac2 PH |
65 | 'url': 'http://tvthek.orf.at/program/Aufgetischt/2745173/Aufgetischt-Mit-der-Steirischen-Tafelrunde/8891389', |
66 | 'playlist': [{ | |
67 | 'md5': '2942210346ed779588f428a92db88712', | |
68 | 'info_dict': { | |
69 | 'id': '8896777', | |
70 | 'ext': 'mp4', | |
71 | 'title': 'Aufgetischt: Mit der Steirischen Tafelrunde', | |
72 | 'description': 'md5:c1272f0245537812d4e36419c207b67d', | |
73 | 'duration': 2668, | |
74 | 'upload_date': '20141208', | |
75 | }, | |
76 | }], | |
13d27a42 PH |
77 | 'skip': 'Blocked outside of Austria / Germany', |
78 | }, { | |
79 | 'url': 'http://tvthek.orf.at/topic/Im-Wandel-der-Zeit/8002126/Best-of-Ingrid-Thurnher/7982256', | |
7b0d333a NP |
80 | 'info_dict': { |
81 | 'id': '7982259', | |
82 | 'ext': 'mp4', | |
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".', | |
86 | }, | |
87 | 'params': { | |
88 | 'skip_download': True, # rtsp downloads | |
89 | }, | |
7512aa98 | 90 | 'skip': 'Blocked outside of Austria / Germany', |
73c801d6 S |
91 | }, { |
92 | 'url': 'http://tvthek.orf.at/topic/Fluechtlingskrise/10463081/Heimat-Fremde-Heimat/13879132/Senioren-betreuen-Migrantenkinder/13879141', | |
7512aa98 | 93 | 'only_matching': True, |
73c801d6 S |
94 | }, { |
95 | 'url': 'http://tvthek.orf.at/profile/Universum/35429', | |
7512aa98 | 96 | 'only_matching': True, |
13d27a42 | 97 | }] |
54543467 | 98 | |
b695e3f9 | 99 | def _pagefunc(self, url, data_jsb, n, *, image=None): |
100 | sd = data_jsb[n] | |
101 | video_id, title = str(sd['id']), sd['title'] | |
102 | formats = [] | |
103 | for fd in sd['sources']: | |
104 | src = url_or_none(fd.get('src')) | |
105 | if not src: | |
106 | continue | |
107 | format_id = join_nonempty('delivery', 'quality', 'quality_string', from_dict=fd) | |
108 | ext = determine_ext(src) | |
109 | if ext == 'm3u8': | |
110 | m3u8_formats = self._extract_m3u8_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) | |
115 | elif ext == 'f4m': | |
116 | formats.extend(self._extract_f4m_formats( | |
117 | src, video_id, f4m_id=format_id, fatal=False)) | |
118 | elif ext == 'mpd': | |
119 | formats.extend(self._extract_mpd_formats( | |
120 | src, video_id, mpd_id=format_id, fatal=False, note=f'Downloading {format_id} mpd manifest')) | |
121 | else: | |
122 | formats.append({ | |
123 | 'format_id': format_id, | |
124 | 'url': src, | |
125 | 'protocol': fd.get('protocol'), | |
126 | }) | |
127 | ||
128 | # Check for geoblocking. | |
129 | # There is a property is_geoprotection, but that's always false | |
130 | geo_str = sd.get('geoprotection_string') | |
131 | http_url = next( | |
132 | (f['url'] for f in formats if re.match(r'^https?://.*\.mp4$', f['url'])), | |
133 | None) if geo_str else None | |
134 | if http_url: | |
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') | |
138 | ||
139 | self._sort_formats(formats) | |
140 | ||
141 | subtitles = {} | |
142 | for sub in sd.get('subtitles', []): | |
143 | sub_src = sub.get('src') | |
144 | if not sub_src: | |
145 | continue | |
146 | subtitles.setdefault(sub.get('lang', 'de-AT'), []).append({ | |
147 | 'url': sub_src, | |
148 | }) | |
149 | ||
150 | upload_date = unified_strdate(sd.get('created_date')) | |
151 | ||
152 | thumbnails = [] | |
153 | preview = sd.get('preview_image_url') | |
154 | if preview: | |
155 | thumbnails.append({ | |
156 | 'id': 'preview', | |
157 | 'url': preview, | |
158 | 'preference': 0, | |
159 | }) | |
160 | image = sd.get('image_full_url') or image | |
161 | if image: | |
162 | thumbnails.append({ | |
163 | 'id': 'full', | |
164 | 'url': image, | |
165 | 'preference': 1, | |
166 | }) | |
167 | ||
168 | yield { | |
169 | 'id': video_id, | |
170 | 'title': title, | |
171 | 'webpage_url': smuggle_url(f'{url}/part/{video_id}', {'force_noplaylist': True}), | |
172 | 'formats': formats, | |
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, | |
178 | } | |
179 | ||
54543467 | 180 | def _real_extract(self, url): |
b695e3f9 | 181 | url, smuggled_data = unsmuggle_url(url) |
182 | playlist_id, video_id, base_url = self._match_valid_url(url).group('id', 'vid', 'url') | |
54543467 JMF |
183 | webpage = self._download_webpage(url, playlist_id) |
184 | ||
73c801d6 S |
185 | data_jsb = self._parse_json( |
186 | self._search_regex( | |
187 | r'<div[^>]+class=(["\']).*?VideoPlaylist.*?\1[^>]+data-jsb=(["\'])(?P<json>.+?)\2', | |
188 | webpage, 'playlist', group='json'), | |
189 | playlist_id, transform_source=unescapeHTML)['playlist']['videos'] | |
5d73273f | 190 | |
b695e3f9 | 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] | |
46358f64 | 193 | |
b695e3f9 | 194 | playlist_count = len(data_jsb) |
195 | image = self._og_search_thumbnail(webpage) if playlist_count == 1 else None | |
5d73273f | 196 | |
b695e3f9 | 197 | page_func = functools.partial(self._pagefunc, base_url, data_jsb, image=image) |
5d73273f PH |
198 | return { |
199 | '_type': 'playlist', | |
b695e3f9 | 200 | 'entries': InAdvancePagedList(page_func, playlist_count, 1), |
5d73273f PH |
201 | 'id': playlist_id, |
202 | } | |
eb368012 S |
203 | |
204 | ||
efe93167 | 205 | class ORFRadioIE(InfoExtractor): |
eb368012 | 206 | def _real_extract(self, url): |
5ad28e7f | 207 | mobj = self._match_valid_url(url) |
eb368012 S |
208 | show_date = mobj.group('date') |
209 | show_id = mobj.group('show') | |
210 | ||
211 | data = self._download_json( | |
aca2fd22 | 212 | 'http://audioapi.orf.at/%s/api/json/current/broadcast/%s/%s' |
13283058 | 213 | % (self._API_STATION, show_id, show_date), show_id) |
aca2fd22 S |
214 | |
215 | entries = [] | |
216 | for info in data['streams']: | |
217 | loop_stream_id = str_or_none(info.get('loopStreamId')) | |
218 | if not loop_stream_id: | |
219 | continue | |
220 | title = str_or_none(data.get('title')) | |
221 | if not title: | |
222 | continue | |
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 | |
226 | entries.append({ | |
227 | 'id': loop_stream_id.replace('.mp3', ''), | |
b73612a2 | 228 | 'url': 'https://loopstream01.apa.at/?channel=%s&id=%s' % (self._LOOP_STATION, loop_stream_id), |
eb368012 | 229 | 'title': title, |
aca2fd22 S |
230 | 'description': clean_html(data.get('subtitle')), |
231 | 'duration': duration, | |
232 | 'timestamp': start, | |
0146c6cd | 233 | 'ext': 'mp3', |
aca2fd22 S |
234 | 'series': data.get('programTitle'), |
235 | }) | |
eb368012 S |
236 | |
237 | return { | |
238 | '_type': 'playlist', | |
239 | 'id': show_id, | |
aca2fd22 S |
240 | 'title': data.get('title'), |
241 | 'description': clean_html(data.get('subtitle')), | |
242 | 'entries': entries, | |
5f6a1245 | 243 | } |
14137b57 S |
244 | |
245 | ||
efe93167 | 246 | class ORFFM4IE(ORFRadioIE): |
247 | IE_NAME = 'orf:fm4' | |
248 | IE_DESC = 'radio FM4' | |
9ba179c1 | 249 | _VALID_URL = r'https?://(?P<station>fm4)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>4\w+)' |
13283058 | 250 | _API_STATION = 'fm4' |
251 | _LOOP_STATION = 'fm4' | |
efe93167 | 252 | |
1339ecb2 | 253 | _TEST = { |
9ba179c1 | 254 | 'url': 'http://fm4.orf.at/player/20170107/4CC', |
1339ecb2 S |
255 | 'md5': '2b0be47375432a7ef104453432a19212', |
256 | 'info_dict': { | |
257 | 'id': '2017-01-07_2100_tl_54_7DaysSat18_31295', | |
258 | 'ext': 'mp3', | |
259 | 'title': 'Solid Steel Radioshow', | |
260 | 'description': 'Die Mixshow von Coldcut und Ninja Tune.', | |
261 | 'duration': 3599, | |
262 | 'timestamp': 1483819257, | |
263 | 'upload_date': '20170107', | |
264 | }, | |
aca2fd22 S |
265 | 'skip': 'Shows from ORF radios are only available for 7 days.', |
266 | 'only_matching': True, | |
1339ecb2 | 267 | } |
efe93167 | 268 | |
269 | ||
13283058 | 270 | class ORFNOEIE(ORFRadioIE): |
271 | IE_NAME = 'orf:noe' | |
272 | IE_DESC = 'Radio Niederösterreich' | |
273 | _VALID_URL = r'https?://(?P<station>noe)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)' | |
274 | _API_STATION = 'noe' | |
275 | _LOOP_STATION = 'oe2n' | |
276 | ||
277 | _TEST = { | |
278 | 'url': 'https://noe.orf.at/player/20200423/NGM', | |
279 | 'only_matching': True, | |
280 | } | |
281 | ||
282 | ||
283 | class ORFWIEIE(ORFRadioIE): | |
284 | IE_NAME = 'orf:wien' | |
285 | IE_DESC = 'Radio Wien' | |
286 | _VALID_URL = r'https?://(?P<station>wien)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)' | |
287 | _API_STATION = 'wie' | |
288 | _LOOP_STATION = 'oe2w' | |
289 | ||
290 | _TEST = { | |
291 | 'url': 'https://wien.orf.at/player/20200423/WGUM', | |
292 | 'only_matching': True, | |
293 | } | |
294 | ||
295 | ||
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+)' | |
300 | _API_STATION = 'bgl' | |
301 | _LOOP_STATION = 'oe2b' | |
302 | ||
303 | _TEST = { | |
304 | 'url': 'https://burgenland.orf.at/player/20200423/BGM', | |
305 | 'only_matching': True, | |
306 | } | |
307 | ||
308 | ||
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+)' | |
313 | _API_STATION = 'ooe' | |
314 | _LOOP_STATION = 'oe2o' | |
315 | ||
316 | _TEST = { | |
317 | 'url': 'https://ooe.orf.at/player/20200423/OGMO', | |
318 | 'only_matching': True, | |
319 | } | |
320 | ||
321 | ||
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+)' | |
326 | _API_STATION = 'stm' | |
327 | _LOOP_STATION = 'oe2st' | |
328 | ||
329 | _TEST = { | |
330 | 'url': 'https://steiermark.orf.at/player/20200423/STGMS', | |
331 | 'only_matching': True, | |
332 | } | |
333 | ||
334 | ||
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+)' | |
339 | _API_STATION = 'ktn' | |
340 | _LOOP_STATION = 'oe2k' | |
341 | ||
342 | _TEST = { | |
343 | 'url': 'https://kaernten.orf.at/player/20200423/KGUMO', | |
344 | 'only_matching': True, | |
345 | } | |
346 | ||
347 | ||
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+)' | |
352 | _API_STATION = 'sbg' | |
353 | _LOOP_STATION = 'oe2s' | |
354 | ||
355 | _TEST = { | |
356 | 'url': 'https://salzburg.orf.at/player/20200423/SGUM', | |
357 | 'only_matching': True, | |
358 | } | |
359 | ||
360 | ||
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+)' | |
365 | _API_STATION = 'tir' | |
366 | _LOOP_STATION = 'oe2t' | |
367 | ||
368 | _TEST = { | |
369 | 'url': 'https://tirol.orf.at/player/20200423/TGUMO', | |
370 | 'only_matching': True, | |
371 | } | |
372 | ||
373 | ||
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+)' | |
378 | _API_STATION = 'vbg' | |
379 | _LOOP_STATION = 'oe2v' | |
380 | ||
381 | _TEST = { | |
382 | 'url': 'https://vorarlberg.orf.at/player/20200423/VGUM', | |
383 | 'only_matching': True, | |
384 | } | |
385 | ||
386 | ||
387 | class ORFOE3IE(ORFRadioIE): | |
388 | IE_NAME = 'orf:oe3' | |
389 | IE_DESC = 'Radio Österreich 3' | |
390 | _VALID_URL = r'https?://(?P<station>oe3)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)' | |
391 | _API_STATION = 'oe3' | |
392 | _LOOP_STATION = 'oe3' | |
393 | ||
394 | _TEST = { | |
395 | 'url': 'https://oe3.orf.at/player/20200424/3WEK', | |
396 | 'only_matching': True, | |
397 | } | |
398 | ||
399 | ||
efe93167 | 400 | class ORFOE1IE(ORFRadioIE): |
401 | IE_NAME = 'orf:oe1' | |
402 | IE_DESC = 'Radio Österreich 1' | |
1339ecb2 | 403 | _VALID_URL = r'https?://(?P<station>oe1)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)' |
13283058 | 404 | _API_STATION = 'oe1' |
405 | _LOOP_STATION = 'oe1' | |
efe93167 | 406 | |
1339ecb2 S |
407 | _TEST = { |
408 | 'url': 'http://oe1.orf.at/player/20170108/456544', | |
409 | 'md5': '34d8a6e67ea888293741c86a099b745b', | |
410 | 'info_dict': { | |
411 | 'id': '2017-01-08_0759_tl_51_7DaysSun6_256141', | |
412 | 'ext': 'mp3', | |
413 | 'title': 'Morgenjournal', | |
414 | 'duration': 609, | |
415 | 'timestamp': 1483858796, | |
416 | 'upload_date': '20170108', | |
417 | }, | |
418 | 'skip': 'Shows from ORF radios are only available for 7 days.' | |
419 | } | |
efe93167 | 420 | |
421 | ||
14137b57 S |
422 | class ORFIPTVIE(InfoExtractor): |
423 | IE_NAME = 'orf:iptv' | |
424 | IE_DESC = 'iptv.ORF.at' | |
5886b38d | 425 | _VALID_URL = r'https?://iptv\.orf\.at/(?:#/)?stories/(?P<id>\d+)' |
14137b57 S |
426 | |
427 | _TEST = { | |
529d26c3 S |
428 | 'url': 'http://iptv.orf.at/stories/2275236/', |
429 | 'md5': 'c8b22af4718a4b4af58342529453e3e5', | |
14137b57 | 430 | 'info_dict': { |
529d26c3 | 431 | 'id': '350612', |
14137b57 | 432 | 'ext': 'flv', |
529d26c3 S |
433 | 'title': 'Weitere Evakuierungen um Vulkan Calbuco', |
434 | 'description': 'md5:d689c959bdbcf04efeddedbf2299d633', | |
435 | 'duration': 68.197, | |
ec85ded8 | 436 | 'thumbnail': r're:^https?://.*\.jpg$', |
529d26c3 | 437 | 'upload_date': '20150425', |
14137b57 S |
438 | }, |
439 | } | |
440 | ||
441 | def _real_extract(self, url): | |
442 | story_id = self._match_id(url) | |
443 | ||
444 | webpage = self._download_webpage( | |
445 | 'http://iptv.orf.at/stories/%s' % story_id, story_id) | |
446 | ||
447 | video_id = self._search_regex( | |
448 | r'data-video(?:id)?="(\d+)"', webpage, 'video id') | |
449 | ||
450 | data = self._download_json( | |
451 | 'http://bits.orf.at/filehandler/static-api/json/current/data.json?file=%s' % video_id, | |
452 | video_id)[0] | |
453 | ||
454 | duration = float_or_none(data['duration'], 1000) | |
455 | ||
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') | |
464 | ||
465 | rendition = self._download_json( | |
466 | load_balancer_url, video_id, transform_source=strip_jsonp) | |
467 | ||
468 | f = { | |
469 | 'abr': abr, | |
470 | 'vbr': vbr, | |
471 | 'fps': fps, | |
472 | 'width': width, | |
473 | 'height': height, | |
474 | } | |
475 | ||
476 | formats = [] | |
477 | for format_id, format_url in rendition['redirect'].items(): | |
478 | if format_id == 'rtmp': | |
479 | ff = f.copy() | |
480 | ff.update({ | |
481 | 'url': format_url, | |
482 | 'format_id': format_id, | |
483 | }) | |
484 | formats.append(ff) | |
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)) | |
491 | else: | |
492 | continue | |
493 | self._sort_formats(formats) | |
494 | ||
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')) | |
499 | ||
500 | return { | |
501 | 'id': video_id, | |
502 | 'title': title, | |
503 | 'description': description, | |
504 | 'duration': duration, | |
505 | 'thumbnail': thumbnail, | |
506 | 'upload_date': upload_date, | |
507 | 'formats': formats, | |
508 | } | |
0732a905 PH |
509 | |
510 | ||
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+)' | |
515 | ||
516 | _TEST = { | |
517 | 'url': 'http://fm4.orf.at/stories/2865738/', | |
518 | 'playlist': [{ | |
519 | 'md5': 'e1c2c706c45c7b34cf478bbf409907ca', | |
520 | 'info_dict': { | |
521 | 'id': '547792', | |
522 | 'ext': 'flv', | |
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.', | |
525 | 'duration': 1748.52, | |
526 | 'thumbnail': r're:^https?://.*\.jpg$', | |
527 | 'upload_date': '20170913', | |
528 | }, | |
529 | }, { | |
530 | 'md5': 'c6dd2179731f86f4f55a7b49899d515f', | |
531 | 'info_dict': { | |
532 | 'id': '547798', | |
533 | 'ext': 'flv', | |
534 | 'title': 'Manu Delago und Inner Tongue live (2)', | |
535 | 'duration': 1504.08, | |
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.', | |
539 | }, | |
540 | }], | |
541 | } | |
542 | ||
543 | def _real_extract(self, url): | |
544 | story_id = self._match_id(url) | |
545 | webpage = self._download_webpage(url, story_id) | |
546 | ||
547 | entries = [] | |
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, | |
552 | video_id)[0] | |
553 | ||
554 | duration = float_or_none(data['duration'], 1000) | |
555 | ||
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') | |
564 | ||
565 | rendition = self._download_json( | |
566 | load_balancer_url, video_id, transform_source=strip_jsonp) | |
567 | ||
568 | f = { | |
569 | 'abr': abr, | |
570 | 'vbr': vbr, | |
571 | 'fps': fps, | |
572 | 'width': width, | |
573 | 'height': height, | |
574 | } | |
575 | ||
576 | formats = [] | |
577 | for format_id, format_url in rendition['redirect'].items(): | |
578 | if format_id == 'rtmp': | |
579 | ff = f.copy() | |
580 | ff.update({ | |
581 | 'url': format_url, | |
582 | 'format_id': format_id, | |
583 | }) | |
584 | formats.append(ff) | |
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)) | |
591 | else: | |
592 | continue | |
593 | self._sort_formats(formats) | |
594 | ||
595 | title = remove_end(self._og_search_title(webpage), ' - fm4.ORF.at') | |
596 | if idx >= 1: | |
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')) | |
602 | ||
603 | entries.append({ | |
604 | 'id': video_id, | |
605 | 'title': title, | |
606 | 'description': description, | |
607 | 'duration': duration, | |
608 | 'thumbnail': thumbnail, | |
609 | 'upload_date': upload_date, | |
610 | 'formats': formats, | |
611 | }) | |
612 | ||
613 | return self.playlist_result(entries) |