orf.py 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import base64
  4. import functools
  5. import re
  6. from .common import InfoExtractor
  7. from ..utils import (
  8. clean_html,
  9. determine_ext,
  10. float_or_none,
  11. int_or_none,
  12. merge_dicts,
  13. orderedSet,
  14. parse_age_limit,
  15. parse_iso8601,
  16. remove_end,
  17. str_or_none,
  18. strip_jsonp,
  19. txt_or_none,
  20. unified_strdate,
  21. url_or_none,
  22. )
  23. from ..traversal import T, traverse_obj
  24. k_float_or_none = functools.partial(float_or_none, scale=1000)
  25. class ORFRadioIE(InfoExtractor):
  26. def _real_extract(self, url):
  27. mobj = re.match(self._VALID_URL, url)
  28. show_date = mobj.group('date')
  29. show_id = mobj.group('show')
  30. data = self._download_json(
  31. 'http://audioapi.orf.at/%s/api/json/current/broadcast/%s/%s'
  32. % (self._API_STATION, show_id, show_date), show_id)
  33. entries = []
  34. for info in data['streams']:
  35. loop_stream_id = str_or_none(info.get('loopStreamId'))
  36. if not loop_stream_id:
  37. continue
  38. title = str_or_none(data.get('title'))
  39. if not title:
  40. continue
  41. start = int_or_none(info.get('start'), scale=1000)
  42. end = int_or_none(info.get('end'), scale=1000)
  43. duration = end - start if end and start else None
  44. entries.append({
  45. 'id': loop_stream_id.replace('.mp3', ''),
  46. 'url': 'https://loopstream01.apa.at/?channel=%s&id=%s' % (self._LOOP_STATION, loop_stream_id),
  47. 'title': title,
  48. 'description': clean_html(data.get('subtitle')),
  49. 'duration': duration,
  50. 'timestamp': start,
  51. 'ext': 'mp3',
  52. 'series': data.get('programTitle'),
  53. })
  54. return {
  55. '_type': 'playlist',
  56. 'id': show_id,
  57. 'title': data.get('title'),
  58. 'description': clean_html(data.get('subtitle')),
  59. 'entries': entries,
  60. }
  61. class ORFFM4IE(ORFRadioIE):
  62. IE_NAME = 'orf:fm4'
  63. IE_DESC = 'radio FM4'
  64. _VALID_URL = r'https?://(?P<station>fm4)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>4\w+)'
  65. _API_STATION = 'fm4'
  66. _LOOP_STATION = 'fm4'
  67. _TEST = {
  68. 'url': 'http://fm4.orf.at/player/20170107/4CC',
  69. 'md5': '2b0be47375432a7ef104453432a19212',
  70. 'info_dict': {
  71. 'id': '2017-01-07_2100_tl_54_7DaysSat18_31295',
  72. 'ext': 'mp3',
  73. 'title': 'Solid Steel Radioshow',
  74. 'description': 'Die Mixshow von Coldcut und Ninja Tune.',
  75. 'duration': 3599,
  76. 'timestamp': 1483819257,
  77. 'upload_date': '20170107',
  78. },
  79. 'skip': 'Shows from ORF radios are only available for 7 days.',
  80. 'only_matching': True,
  81. }
  82. class ORFNOEIE(ORFRadioIE):
  83. IE_NAME = 'orf:noe'
  84. IE_DESC = 'Radio Niederösterreich'
  85. _VALID_URL = r'https?://(?P<station>noe)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)'
  86. _API_STATION = 'noe'
  87. _LOOP_STATION = 'oe2n'
  88. _TEST = {
  89. 'url': 'https://noe.orf.at/player/20200423/NGM',
  90. 'only_matching': True,
  91. }
  92. class ORFWIEIE(ORFRadioIE):
  93. IE_NAME = 'orf:wien'
  94. IE_DESC = 'Radio Wien'
  95. _VALID_URL = r'https?://(?P<station>wien)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)'
  96. _API_STATION = 'wie'
  97. _LOOP_STATION = 'oe2w'
  98. _TEST = {
  99. 'url': 'https://wien.orf.at/player/20200423/WGUM',
  100. 'only_matching': True,
  101. }
  102. class ORFBGLIE(ORFRadioIE):
  103. IE_NAME = 'orf:burgenland'
  104. IE_DESC = 'Radio Burgenland'
  105. _VALID_URL = r'https?://(?P<station>burgenland)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)'
  106. _API_STATION = 'bgl'
  107. _LOOP_STATION = 'oe2b'
  108. _TEST = {
  109. 'url': 'https://burgenland.orf.at/player/20200423/BGM',
  110. 'only_matching': True,
  111. }
  112. class ORFOOEIE(ORFRadioIE):
  113. IE_NAME = 'orf:oberoesterreich'
  114. IE_DESC = 'Radio Oberösterreich'
  115. _VALID_URL = r'https?://(?P<station>ooe)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)'
  116. _API_STATION = 'ooe'
  117. _LOOP_STATION = 'oe2o'
  118. _TEST = {
  119. 'url': 'https://ooe.orf.at/player/20200423/OGMO',
  120. 'only_matching': True,
  121. }
  122. class ORFSTMIE(ORFRadioIE):
  123. IE_NAME = 'orf:steiermark'
  124. IE_DESC = 'Radio Steiermark'
  125. _VALID_URL = r'https?://(?P<station>steiermark)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)'
  126. _API_STATION = 'stm'
  127. _LOOP_STATION = 'oe2st'
  128. _TEST = {
  129. 'url': 'https://steiermark.orf.at/player/20200423/STGMS',
  130. 'only_matching': True,
  131. }
  132. class ORFKTNIE(ORFRadioIE):
  133. IE_NAME = 'orf:kaernten'
  134. IE_DESC = 'Radio Kärnten'
  135. _VALID_URL = r'https?://(?P<station>kaernten)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)'
  136. _API_STATION = 'ktn'
  137. _LOOP_STATION = 'oe2k'
  138. _TEST = {
  139. 'url': 'https://kaernten.orf.at/player/20200423/KGUMO',
  140. 'only_matching': True,
  141. }
  142. class ORFSBGIE(ORFRadioIE):
  143. IE_NAME = 'orf:salzburg'
  144. IE_DESC = 'Radio Salzburg'
  145. _VALID_URL = r'https?://(?P<station>salzburg)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)'
  146. _API_STATION = 'sbg'
  147. _LOOP_STATION = 'oe2s'
  148. _TEST = {
  149. 'url': 'https://salzburg.orf.at/player/20200423/SGUM',
  150. 'only_matching': True,
  151. }
  152. class ORFTIRIE(ORFRadioIE):
  153. IE_NAME = 'orf:tirol'
  154. IE_DESC = 'Radio Tirol'
  155. _VALID_URL = r'https?://(?P<station>tirol)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)'
  156. _API_STATION = 'tir'
  157. _LOOP_STATION = 'oe2t'
  158. _TEST = {
  159. 'url': 'https://tirol.orf.at/player/20200423/TGUMO',
  160. 'only_matching': True,
  161. }
  162. class ORFVBGIE(ORFRadioIE):
  163. IE_NAME = 'orf:vorarlberg'
  164. IE_DESC = 'Radio Vorarlberg'
  165. _VALID_URL = r'https?://(?P<station>vorarlberg)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)'
  166. _API_STATION = 'vbg'
  167. _LOOP_STATION = 'oe2v'
  168. _TEST = {
  169. 'url': 'https://vorarlberg.orf.at/player/20200423/VGUM',
  170. 'only_matching': True,
  171. }
  172. class ORFOE3IE(ORFRadioIE):
  173. IE_NAME = 'orf:oe3'
  174. IE_DESC = 'Radio Österreich 3'
  175. _VALID_URL = r'https?://(?P<station>oe3)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)'
  176. _API_STATION = 'oe3'
  177. _LOOP_STATION = 'oe3'
  178. _TEST = {
  179. 'url': 'https://oe3.orf.at/player/20200424/3WEK',
  180. 'only_matching': True,
  181. }
  182. class ORFOE1IE(ORFRadioIE):
  183. IE_NAME = 'orf:oe1'
  184. IE_DESC = 'Radio Österreich 1'
  185. _VALID_URL = r'https?://(?P<station>oe1)\.orf\.at/player/(?P<date>[0-9]+)/(?P<show>\w+)'
  186. _API_STATION = 'oe1'
  187. _LOOP_STATION = 'oe1'
  188. _TEST = {
  189. 'url': 'http://oe1.orf.at/player/20170108/456544',
  190. 'md5': '34d8a6e67ea888293741c86a099b745b',
  191. 'info_dict': {
  192. 'id': '2017-01-08_0759_tl_51_7DaysSun6_256141',
  193. 'ext': 'mp3',
  194. 'title': 'Morgenjournal',
  195. 'duration': 609,
  196. 'timestamp': 1483858796,
  197. 'upload_date': '20170108',
  198. },
  199. 'skip': 'Shows from ORF radios are only available for 7 days.'
  200. }
  201. class ORFIPTVIE(InfoExtractor):
  202. IE_NAME = 'orf:iptv'
  203. IE_DESC = 'iptv.ORF.at'
  204. _WORKING = False # URLs redirect to orf.at/
  205. _VALID_URL = r'https?://iptv\.orf\.at/(?:#/)?stories/(?P<id>\d+)'
  206. _TEST = {
  207. 'url': 'http://iptv.orf.at/stories/2275236/',
  208. 'md5': 'c8b22af4718a4b4af58342529453e3e5',
  209. 'info_dict': {
  210. 'id': '350612',
  211. 'ext': 'flv',
  212. 'title': 'Weitere Evakuierungen um Vulkan Calbuco',
  213. 'description': 'md5:d689c959bdbcf04efeddedbf2299d633',
  214. 'duration': 68.197,
  215. 'thumbnail': r're:^https?://.*\.jpg$',
  216. 'upload_date': '20150425',
  217. },
  218. }
  219. def _real_extract(self, url):
  220. story_id = self._match_id(url)
  221. webpage = self._download_webpage(
  222. 'http://iptv.orf.at/stories/%s' % story_id, story_id)
  223. video_id = self._search_regex(
  224. r'data-video(?:id)?="(\d+)"', webpage, 'video id')
  225. data = self._download_json(
  226. 'http://bits.orf.at/filehandler/static-api/json/current/data.json?file=%s' % video_id,
  227. video_id)[0]
  228. duration = float_or_none(data['duration'], 1000)
  229. video = data['sources']['default']
  230. load_balancer_url = video['loadBalancerUrl']
  231. abr = int_or_none(video.get('audioBitrate'))
  232. vbr = int_or_none(video.get('bitrate'))
  233. fps = int_or_none(video.get('videoFps'))
  234. width = int_or_none(video.get('videoWidth'))
  235. height = int_or_none(video.get('videoHeight'))
  236. thumbnail = video.get('preview')
  237. rendition = self._download_json(
  238. load_balancer_url, video_id, transform_source=strip_jsonp)
  239. f = {
  240. 'abr': abr,
  241. 'vbr': vbr,
  242. 'fps': fps,
  243. 'width': width,
  244. 'height': height,
  245. }
  246. formats = []
  247. for format_id, format_url in rendition['redirect'].items():
  248. if format_id == 'rtmp':
  249. ff = f.copy()
  250. ff.update({
  251. 'url': format_url,
  252. 'format_id': format_id,
  253. })
  254. formats.append(ff)
  255. elif determine_ext(format_url) == 'f4m':
  256. formats.extend(self._extract_f4m_formats(
  257. format_url, video_id, f4m_id=format_id))
  258. elif determine_ext(format_url) == 'm3u8':
  259. formats.extend(self._extract_m3u8_formats(
  260. format_url, video_id, 'mp4', m3u8_id=format_id))
  261. else:
  262. continue
  263. self._sort_formats(formats)
  264. title = remove_end(self._og_search_title(webpage), ' - iptv.ORF.at')
  265. description = self._og_search_description(webpage)
  266. upload_date = unified_strdate(self._html_search_meta(
  267. 'dc.date', webpage, 'upload date'))
  268. return {
  269. 'id': video_id,
  270. 'title': title,
  271. 'description': description,
  272. 'duration': duration,
  273. 'thumbnail': thumbnail,
  274. 'upload_date': upload_date,
  275. 'formats': formats,
  276. }
  277. class ORFFM4StoryIE(InfoExtractor):
  278. IE_NAME = 'orf:fm4:story'
  279. IE_DESC = 'fm4.orf.at stories'
  280. _VALID_URL = r'https?://fm4\.orf\.at/stories/(?P<id>\d+)'
  281. _TEST = {
  282. 'url': 'http://fm4.orf.at/stories/2865738/',
  283. 'playlist': [{
  284. 'md5': 'e1c2c706c45c7b34cf478bbf409907ca',
  285. 'info_dict': {
  286. 'id': '547792',
  287. 'ext': 'flv',
  288. 'title': 'Manu Delago und Inner Tongue live',
  289. '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.',
  290. 'duration': 1748.52,
  291. 'thumbnail': r're:^https?://.*\.jpg$',
  292. 'upload_date': '20170913',
  293. },
  294. }, {
  295. 'md5': 'c6dd2179731f86f4f55a7b49899d515f',
  296. 'info_dict': {
  297. 'id': '547798',
  298. 'ext': 'flv',
  299. 'title': 'Manu Delago und Inner Tongue live (2)',
  300. 'duration': 1504.08,
  301. 'thumbnail': r're:^https?://.*\.jpg$',
  302. 'upload_date': '20170913',
  303. '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.',
  304. },
  305. }],
  306. }
  307. def _real_extract(self, url):
  308. story_id = self._match_id(url)
  309. webpage = self._download_webpage(url, story_id)
  310. entries = []
  311. all_ids = orderedSet(re.findall(r'data-video(?:id)?="(\d+)"', webpage))
  312. for idx, video_id in enumerate(all_ids):
  313. data = self._download_json(
  314. 'http://bits.orf.at/filehandler/static-api/json/current/data.json?file=%s' % video_id,
  315. video_id)[0]
  316. duration = float_or_none(data['duration'], 1000)
  317. video = data['sources']['q8c']
  318. load_balancer_url = video['loadBalancerUrl']
  319. abr = int_or_none(video.get('audioBitrate'))
  320. vbr = int_or_none(video.get('bitrate'))
  321. fps = int_or_none(video.get('videoFps'))
  322. width = int_or_none(video.get('videoWidth'))
  323. height = int_or_none(video.get('videoHeight'))
  324. thumbnail = video.get('preview')
  325. rendition = self._download_json(
  326. load_balancer_url, video_id, transform_source=strip_jsonp)
  327. f = {
  328. 'abr': abr,
  329. 'vbr': vbr,
  330. 'fps': fps,
  331. 'width': width,
  332. 'height': height,
  333. }
  334. formats = []
  335. for format_id, format_url in rendition['redirect'].items():
  336. if format_id == 'rtmp':
  337. ff = f.copy()
  338. ff.update({
  339. 'url': format_url,
  340. 'format_id': format_id,
  341. })
  342. formats.append(ff)
  343. elif determine_ext(format_url) == 'f4m':
  344. formats.extend(self._extract_f4m_formats(
  345. format_url, video_id, f4m_id=format_id))
  346. elif determine_ext(format_url) == 'm3u8':
  347. formats.extend(self._extract_m3u8_formats(
  348. format_url, video_id, 'mp4', m3u8_id=format_id))
  349. else:
  350. continue
  351. self._sort_formats(formats)
  352. title = remove_end(self._og_search_title(webpage), ' - fm4.ORF.at')
  353. if idx >= 1:
  354. # Titles are duplicates, make them unique
  355. title += ' (' + str(idx + 1) + ')'
  356. description = self._og_search_description(webpage)
  357. upload_date = unified_strdate(self._html_search_meta(
  358. 'dc.date', webpage, 'upload date'))
  359. entries.append({
  360. 'id': video_id,
  361. 'title': title,
  362. 'description': description,
  363. 'duration': duration,
  364. 'thumbnail': thumbnail,
  365. 'upload_date': upload_date,
  366. 'formats': formats,
  367. })
  368. return self.playlist_result(entries)
  369. class ORFONBase(InfoExtractor):
  370. _ENC_PFX = '3dSlfek03nsLKdj4Jsd'
  371. _API_PATH = 'episode'
  372. def _call_api(self, video_id, **kwargs):
  373. encrypted_id = base64.b64encode('{0}{1}'.format(
  374. self._ENC_PFX, video_id).encode('utf-8')).decode('ascii')
  375. return self._download_json(
  376. 'https://api-tvthek.orf.at/api/v4.3/public/{0}/encrypted/{1}'.format(
  377. self._API_PATH, encrypted_id),
  378. video_id, **kwargs)
  379. @classmethod
  380. def _parse_metadata(cls, api_json):
  381. return traverse_obj(api_json, {
  382. 'id': ('id', T(int), T(txt_or_none)),
  383. 'age_limit': ('age_classification', T(parse_age_limit)),
  384. 'duration': ((('exact_duration', T(k_float_or_none)),
  385. ('duration_second', T(float_or_none))),),
  386. 'title': (('title', 'headline'), T(txt_or_none)),
  387. 'description': (('description', 'teaser_text'), T(txt_or_none)),
  388. # 'media_type': ('video_type', T(txt_or_none)),
  389. 'thumbnail': ('_embedded', 'image', 'public_urls', 'highlight_teaser', 'url', T(url_or_none)),
  390. 'timestamp': (('date', 'episode_date'), T(parse_iso8601)),
  391. 'release_timestamp': ('release_date', T(parse_iso8601)),
  392. # 'modified_timestamp': ('updated_at', T(parse_iso8601)),
  393. }, get_all=False)
  394. def _extract_video(self, video_id, segment_id):
  395. # Not a segmented episode: return single video
  396. # Segmented episode without valid segment id: return entire playlist
  397. # Segmented episode with valid segment id and yes-playlist: return entire playlist
  398. # Segmented episode with valid segment id and no-playlist: return single video corresponding to segment id
  399. # If a multi_video playlist would be returned, but an unsegmented source exists, that source is chosen instead.
  400. api_json = self._call_api(video_id)
  401. if traverse_obj(api_json, 'is_drm_protected'):
  402. self.report_drm(video_id)
  403. # updates formats, subtitles
  404. def extract_sources(src_json, video_id):
  405. for manifest_type in traverse_obj(src_json, ('sources', T(dict.keys), Ellipsis)):
  406. for manifest_url in traverse_obj(src_json, ('sources', manifest_type, Ellipsis, 'src', T(url_or_none))):
  407. if manifest_type == 'hls':
  408. fmts, subs = self._extract_m3u8_formats(
  409. manifest_url, video_id, fatal=False, m3u8_id='hls',
  410. ext='mp4', entry_protocol='m3u8_native'), {}
  411. for f in fmts:
  412. if '_vo.' in f['url']:
  413. f['acodec'] = 'none'
  414. elif manifest_type == 'dash':
  415. fmts, subs = self._extract_mpd_formats_and_subtitles(
  416. manifest_url, video_id, fatal=False, mpd_id='dash')
  417. else:
  418. continue
  419. formats.extend(fmts)
  420. self._merge_subtitles(subs, target=subtitles)
  421. formats, subtitles = [], {}
  422. if segment_id is None:
  423. extract_sources(api_json, video_id)
  424. if not formats:
  425. segments = traverse_obj(api_json, (
  426. '_embedded', 'segments', lambda _, v: v['id']))
  427. if len(segments) > 1 and segment_id is not None:
  428. if not self._yes_playlist(video_id, segment_id, playlist_label='collection', video_label='segment'):
  429. segments = [next(s for s in segments if txt_or_none(s['id']) == segment_id)]
  430. entries = []
  431. for seg in segments:
  432. formats, subtitles = [], {}
  433. extract_sources(seg, segment_id)
  434. self._sort_formats(formats)
  435. entries.append(merge_dicts({
  436. 'formats': formats,
  437. 'subtitles': subtitles,
  438. }, self._parse_metadata(seg), rev=True))
  439. result = merge_dicts(
  440. {'_type': 'multi_video' if len(entries) > 1 else 'playlist'},
  441. self._parse_metadata(api_json),
  442. self.playlist_result(entries, video_id))
  443. # not yet processed in core for playlist/multi
  444. self._downloader._fill_common_fields(result)
  445. return result
  446. else:
  447. self._sort_formats(formats)
  448. for sub_url in traverse_obj(api_json, (
  449. '_embedded', 'subtitle',
  450. ('xml_url', 'sami_url', 'stl_url', 'ttml_url', 'srt_url', 'vtt_url'),
  451. T(url_or_none))):
  452. self._merge_subtitles({'de': [{'url': sub_url}]}, target=subtitles)
  453. return merge_dicts({
  454. 'id': video_id,
  455. 'formats': formats,
  456. 'subtitles': subtitles,
  457. # '_old_archive_ids': [self._downloader._make_archive_id({'ie_key': 'ORFTVthek', 'id': video_id})],
  458. }, self._parse_metadata(api_json), rev=True)
  459. def _real_extract(self, url):
  460. video_id, segment_id = self._match_valid_url(url).group('id', 'segment')
  461. webpage = self._download_webpage(url, video_id)
  462. # ORF doesn't like 410 or 404
  463. if self._search_regex(r'<div\b[^>]*>\s*(Nicht mehr verfügbar)\s*</div>', webpage, 'Availability', default=False):
  464. raise ExtractorError('Content is no longer available', expected=True, video_id=video_id)
  465. return merge_dicts({
  466. 'id': video_id,
  467. 'title': self._html_search_meta(['og:title', 'twitter:title'], webpage, default=None),
  468. 'description': self._html_search_meta(
  469. ['description', 'og:description', 'twitter:description'], webpage, default=None),
  470. }, self._search_json_ld(webpage, video_id, default={}),
  471. self._extract_video(video_id, segment_id),
  472. rev=True)
  473. class ORFONIE(ORFONBase):
  474. IE_NAME = 'orf:on'
  475. _VALID_URL = r'https?://on\.orf\.at/video/(?P<id>\d+)(?:/(?P<segment>\d+))?'
  476. _TESTS = [{
  477. 'url': 'https://on.orf.at/video/14210000/school-of-champions-48',
  478. 'info_dict': {
  479. 'id': '14210000',
  480. 'ext': 'mp4',
  481. 'duration': 2651.08,
  482. 'thumbnail': 'https://api-tvthek.orf.at/assets/segments/0167/98/thumb_16697671_segments_highlight_teaser.jpeg',
  483. 'title': 'School of Champions (4/8)',
  484. 'description': r're:(?s)Luca hat sein ganzes Leben in den Bergen Südtirols verbracht und ist bei seiner Mutter aufgewachsen, .{1029} Leo$',
  485. # 'media_type': 'episode',
  486. 'timestamp': 1706558922,
  487. 'upload_date': '20240129',
  488. 'release_timestamp': 1706472362,
  489. 'release_date': '20240128',
  490. # 'modified_timestamp': 1712756663,
  491. # 'modified_date': '20240410',
  492. # '_old_archive_ids': ['orftvthek 14210000'],
  493. },
  494. 'params': {
  495. 'format': 'bestvideo',
  496. },
  497. }, {
  498. 'url': 'https://on.orf.at/video/3220355',
  499. 'md5': '925a93b2b9a37da5c9b979d7cf71aa2e',
  500. 'info_dict': {
  501. 'id': '3220355',
  502. 'ext': 'mp4',
  503. 'duration': 445.04,
  504. 'thumbnail': 'https://api-tvthek.orf.at/assets/segments/0002/60/thumb_159573_segments_highlight_teaser.png',
  505. 'title': '50 Jahre Burgenland: Der Festumzug',
  506. 'description': r're:(?s)Aus allen Landesteilen zogen festlich geschmückte Wagen und Musikkapellen .{270} Jenakowitsch$',
  507. # 'media_type': 'episode',
  508. 'timestamp': 52916400,
  509. 'upload_date': '19710905',
  510. 'release_timestamp': 52916400,
  511. 'release_date': '19710905',
  512. # 'modified_timestamp': 1498536049,
  513. # 'modified_date': '20170627',
  514. # '_old_archive_ids': ['orftvthek 3220355'],
  515. },
  516. }, {
  517. # Video with multiple segments selecting the second segment
  518. 'url': 'https://on.orf.at/video/14226549/15639808/jugendbande-einbrueche-aus-langeweile',
  519. 'md5': 'fc151bba8c05ea77ab5693617e4a33d3',
  520. 'info_dict': {
  521. 'id': '15639808',
  522. 'ext': 'mp4',
  523. 'duration': 97.707,
  524. 'thumbnail': 'https://api-tvthek.orf.at/assets/segments/0175/43/thumb_17442704_segments_highlight_teaser.jpg',
  525. 'title': 'Jugendbande: Einbrüche aus Langeweile',
  526. 'description': r're:Jugendbande: Einbrüche aus Langeweile \| Neuer Kinder- und .{259} Wanda$',
  527. # 'media_type': 'segment',
  528. 'timestamp': 1715792400,
  529. 'upload_date': '20240515',
  530. # 'modified_timestamp': 1715794394,
  531. # 'modified_date': '20240515',
  532. # '_old_archive_ids': ['orftvthek 15639808'],
  533. },
  534. 'params': {
  535. 'noplaylist': True,
  536. 'format': 'bestvideo',
  537. },
  538. }, {
  539. # Video with multiple segments and no combined version
  540. 'url': 'https://on.orf.at/video/14227864/formel-1-grosser-preis-von-monaco-2024',
  541. 'info_dict': {
  542. '_type': 'multi_video',
  543. 'id': '14227864',
  544. 'duration': 18410.52,
  545. 'thumbnail': 'https://api-tvthek.orf.at/assets/segments/0176/04/thumb_17503881_segments_highlight_teaser.jpg',
  546. 'title': 'Formel 1: Großer Preis von Monaco 2024',
  547. 'description': 'md5:aeeb010710ccf70ce28ccb4482243d4f',
  548. # 'media_type': 'episode',
  549. 'timestamp': 1716721200,
  550. 'upload_date': '20240526',
  551. 'release_timestamp': 1716721802,
  552. 'release_date': '20240526',
  553. # 'modified_timestamp': 1716884702,
  554. # 'modified_date': '20240528',
  555. },
  556. 'playlist_count': 42,
  557. 'skip': 'Gone: Nicht mehr verfügbar',
  558. }, {
  559. # Video with multiple segments, but with combined version
  560. 'url': 'https://on.orf.at/video/14228172',
  561. 'info_dict': {
  562. 'id': '14228172',
  563. 'ext': 'mp4',
  564. 'duration': 3294.878,
  565. 'thumbnail': 'https://api-tvthek.orf.at/assets/segments/0176/29/thumb_17528242_segments_highlight_teaser.jpg',
  566. 'title': 'Willkommen Österreich mit Stermann & Grissemann',
  567. 'description': r're:Zum Saisonfinale freuen sich die urlaubsreifen Gastgeber Stermann und .{1863} Geschichten\.$',
  568. # 'media_type': 'episode',
  569. 'timestamp': 1716926584,
  570. 'upload_date': '20240528',
  571. 'release_timestamp': 1716919202,
  572. 'release_date': '20240528',
  573. # 'modified_timestamp': 1716968045,
  574. # 'modified_date': '20240529',
  575. # '_old_archive_ids': ['orftvthek 14228172'],
  576. },
  577. 'params': {
  578. 'format': 'bestvideo',
  579. },
  580. 'skip': 'Gone: Nicht mehr verfügbar',
  581. }]
  582. class ORFONLiveIE(ORFONBase):
  583. _ENC_PFX = '8876324jshjd7293ktd'
  584. _API_PATH = 'livestream'
  585. _VALID_URL = r'https?://on\.orf\.at/livestream/(?P<id>\d+)(?:/(?P<segment>\d+))?'
  586. _TESTS = [{
  587. 'url': 'https://on.orf.at/livestream/14320204/pressekonferenz-neos-zu-aktuellen-entwicklungen',
  588. 'info_dict': {
  589. 'id': '14320204',
  590. 'ext': 'mp4',
  591. 'title': 'Pressekonferenz: Neos zu aktuellen Entwicklungen',
  592. 'description': r're:(?s)Neos-Chefin Beate Meinl-Reisinger informi.{598}ng\."',
  593. 'timestamp': 1716886335,
  594. 'upload_date': '20240528',
  595. # 'modified_timestamp': 1712756663,
  596. # 'modified_date': '20240410',
  597. # '_old_archive_ids': ['orftvthek 14210000'],
  598. },
  599. 'params': {
  600. 'format': 'bestvideo',
  601. },
  602. }]
  603. @classmethod
  604. def _parse_metadata(cls, api_json):
  605. return merge_dicts(
  606. super(ORFONLiveIE, cls)._parse_metadata(api_json),
  607. traverse_obj(api_json, {
  608. 'timestamp': ('updated_at', T(parse_iso8601)),
  609. 'release_timestamp': ('start', T(parse_iso8601)),
  610. 'is_live': True,
  611. }))