2 from __future__ import unicode_literals
6 from .common import InfoExtractor
14 class RteIE(InfoExtractor):
16 IE_DESC = 'Raidió Teilifís Éireann TV'
17 _VALID_URL = r'https?://(?:www\.)?rte\.ie/player/[^/]{2,3}/show/[^/]+/(?P<id>[0-9]+)'
19 'url': 'http://www.rte.ie/player/ie/show/iwitness-862/10478715/',
23 'title': 'Watch iWitness online',
24 'thumbnail': 're:^https?://.*\.jpg$',
25 'description': 'iWitness : The spirit of Ireland, one voice and one minute at a time.',
29 'skip_download': 'f4m fails with --test atm'
33 def _real_extract(self, url):
34 video_id = self._match_id(url)
35 webpage = self._download_webpage(url, video_id)
37 title = self._og_search_title(webpage)
38 description = self._html_search_meta('description', webpage, 'description')
39 duration = float_or_none(self._html_search_meta(
40 'duration', webpage, 'duration', fatal=False), 1000)
42 thumbnail_id = self._search_regex(
43 r'<meta name="thumbnail" content="uri:irus:(.*?)" />', webpage, 'thumbnail')
44 thumbnail = 'http://img.rasset.ie/' + thumbnail_id + '.jpg'
46 feeds_url = self._html_search_meta('feeds-prefix', webpage, 'feeds url') + video_id
47 json_string = self._download_json(feeds_url, video_id)
49 # f4m_url = server + relative_url
50 f4m_url = json_string['shows'][0]['media:group'][0]['rte:server'] + json_string['shows'][0]['media:group'][0]['url']
51 f4m_formats = self._extract_f4m_formats(f4m_url, video_id)
52 self._sort_formats(f4m_formats)
57 'formats': f4m_formats,
58 'description': description,
59 'thumbnail': thumbnail,
64 class RteRadioIE(InfoExtractor):
66 IE_DESC = 'Raidió Teilifís Éireann radio'
67 # Radioplayer URLs have two distinct specifier formats,
68 # the old format #!rii=<channel_id>:<id>:<playable_item_id>:<date>:
69 # the new format #!rii=b<channel_id>_<id>_<playable_item_id>_<date>_
70 # where the IDs are int/empty, the date is DD-MM-YYYY, and the specifier may be truncated.
71 # An <id> uniquely defines an individual recording, and is the only part we require.
72 _VALID_URL = r'https?://(?:www\.)?rte\.ie/radio/utils/radioplayer/rteradioweb\.html#!rii=(?:b?[0-9]*)(?:%3A|:|%5F|_)(?P<id>[0-9]+)'
75 # Old-style player URL; HLS and RTMPE formats
76 'url': 'http://www.rte.ie/radio/utils/radioplayer/rteradioweb.html#!rii=16:10507902:2414:27-12-2015:',
81 'thumbnail': 're:^https?://.*\.jpg$',
82 'description': 'md5:9ce124a7fb41559ec68f06387cabddf0',
83 'timestamp': 1451203200,
84 'upload_date': '20151227',
88 'skip_download': 'f4m fails with --test atm'
91 # New-style player URL; RTMPE formats only
92 'url': 'http://rte.ie/radio/utils/radioplayer/rteradioweb.html#!rii=b16_3250678_8861_06-04-2012_',
96 'title': 'The Lyric Concert with Paul Herriott',
97 'thumbnail': 're:^https?://.*\.jpg$',
99 'timestamp': 1333742400,
100 'upload_date': '20120406',
101 'duration': 7199.016,
104 'skip_download': 'f4m fails with --test atm'
108 def _real_extract(self, url):
109 item_id = self._match_id(url)
111 json_string = self._download_json(
112 'http://www.rte.ie/rteavgen/getplaylist/?type=web&format=json&id=' + item_id,
115 # NB the string values in the JSON are stored using XML escaping(!)
116 show = json_string['shows'][0]
117 title = unescapeHTML(show['title'])
118 description = unescapeHTML(show.get('description'))
119 thumbnail = show.get('thumbnail')
120 duration = float_or_none(show.get('duration'), 1000)
121 timestamp = parse_iso8601(show.get('published'))
123 mg = show['media:group'][0]
128 m = re.match(r'(?P<url>rtmpe?://[^/]+)/(?P<app>.+)/(?P<playpath>mp4:.*)', mg['url'])
132 'url': m['url'] + '/' + m['app'],
134 'play_path': m['playpath'],
140 if mg.get('hls_server') and mg.get('hls_url'):
141 formats.extend(self._extract_m3u8_formats(
142 mg['hls_server'] + mg['hls_url'], item_id, 'mp4',
143 entry_protocol='m3u8_native', m3u8_id='hls', fatal=False))
145 if mg.get('hds_server') and mg.get('hds_url'):
146 formats.extend(self._extract_f4m_formats(
147 mg['hds_server'] + mg['hds_url'], item_id,
148 f4m_id='hds', fatal=False))
150 self._sort_formats(formats)
155 'description': description,
156 'thumbnail': thumbnail,
157 'timestamp': timestamp,
158 'duration': duration,