2 from __future__ import unicode_literals
4 from .common import InfoExtractor
11 class RteIE(InfoExtractor):
13 IE_DESC = 'Raidió Teilifís Éireann TV'
14 _VALID_URL = r'https?://(?:www\.)?rte\.ie/player/[^/]{2,3}/show/[^/]+/(?P<id>[0-9]+)'
16 'url': 'http://www.rte.ie/player/ie/show/iwitness-862/10478715/',
20 'title': 'Watch iWitness online',
21 'thumbnail': 're:^https?://.*\.jpg$',
22 'description': 'iWitness : The spirit of Ireland, one voice and one minute at a time.',
26 'skip_download': 'f4m fails with --test atm'
30 def _real_extract(self, url):
31 video_id = self._match_id(url)
32 webpage = self._download_webpage(url, video_id)
34 title = self._og_search_title(webpage)
35 description = self._html_search_meta('description', webpage, 'description')
36 duration = float_or_none(self._html_search_meta(
37 'duration', webpage, 'duration', fatal=False), 1000)
39 thumbnail_id = self._search_regex(
40 r'<meta name="thumbnail" content="uri:irus:(.*?)" />', webpage, 'thumbnail')
41 thumbnail = 'http://img.rasset.ie/' + thumbnail_id + '.jpg'
43 feeds_url = self._html_search_meta("feeds-prefix", webpage, 'feeds url') + video_id
44 json_string = self._download_json(feeds_url, video_id)
46 # f4m_url = server + relative_url
47 f4m_url = json_string['shows'][0]['media:group'][0]['rte:server'] + json_string['shows'][0]['media:group'][0]['url']
48 f4m_formats = self._extract_f4m_formats(f4m_url, video_id)
53 'formats': f4m_formats,
54 'description': description,
55 'thumbnail': thumbnail,
60 class RteRadioIE(InfoExtractor):
62 IE_DESC = 'Raidió Teilifís Éireann radio'
63 # Radioplayer URLs have the specifier #!rii=<channel_id>:<id>:<playable_item_id>:<date>:
64 # where the IDs are int/empty, the date is DD-MM-YYYY, and the specifier may be truncated.
65 # An <id> uniquely defines an individual recording, and is the only part we require.
66 _VALID_URL = r'https?://(?:www\.)?rte\.ie/radio/utils/radioplayer/rteradioweb\.html#!rii=(?:[0-9]*)(?:%3A|:)(?P<id>[0-9]+)'
69 'url': 'http://www.rte.ie/radio/utils/radioplayer/rteradioweb.html#!rii=16:10507902:2414:27-12-2015:',
74 'thumbnail': 're:^https?://.*\.jpg$',
75 'description': 'Tim Thurston guides you through a millennium of sacred music featuring Gregorian chant, pure solo voices and choral masterpieces, framed around the glorious music of J.S. Bach.',
79 'skip_download': 'f4m fails with --test atm'
83 def _real_extract(self, url):
84 item_id = self._match_id(url)
85 feeds_url = 'http://www.rte.ie/rteavgen/getplaylist/?type=web&format=json&id=' + item_id
86 json_string = self._download_json(feeds_url, item_id)
88 # NB the string values in the JSON are stored using XML escaping(!)
89 show = json_string['shows'][0]
90 title = unescapeHTML(show['title'])
91 description = unescapeHTML(show.get('description'))
92 thumbnail = show.get('thumbnail')
93 duration = float_or_none(show.get('duration'), 1000)
95 mg = show['media:group'][0]
99 if mg.get('url') and not mg['url'].startswith('rtmpe:'):
100 formats.append({'url': mg['url']})
102 if mg.get('hls_server') and mg.get('hls_url'):
103 formats.extend(self._extract_m3u8_formats(
104 mg['hls_server'] + mg['hls_url'], item_id, 'mp4',
105 entry_protocol='m3u8_native', m3u8_id='hls', fatal=False))
107 if mg.get('hds_server') and mg.get('hds_url'):
108 formats.extend(self._extract_f4m_formats(
109 mg['hds_server'] + mg['hds_url'], item_id,
110 f4m_id='hds', fatal=False))
112 self._sort_formats(formats)
118 'description': description,
119 'thumbnail': thumbnail,
120 'duration': duration,