]>
Commit | Line | Data |
---|---|---|
25fadd06 | 1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
4 | from .common import InfoExtractor | |
25fadd06 | 5 | from ..utils import ( |
6 | float_or_none, | |
9938a17f | 7 | parse_iso8601, |
896c7a23 | 8 | unescapeHTML, |
25fadd06 | 9 | ) |
10 | ||
11 | ||
12 | class RteIE(InfoExtractor): | |
896c7a23 | 13 | IE_NAME = 'rte' |
14 | IE_DESC = 'Raidió Teilifís Éireann TV' | |
6df7179e | 15 | _VALID_URL = r'https?://(?:www\.)?rte\.ie/player/[^/]{2,3}/show/[^/]+/(?P<id>[0-9]+)' |
25fadd06 | 16 | _TEST = { |
36eb802b | 17 | 'url': 'http://www.rte.ie/player/ie/show/iwitness-862/10478715/', |
25fadd06 | 18 | 'info_dict': { |
36eb802b | 19 | 'id': '10478715', |
896c7a23 | 20 | 'ext': 'flv', |
36eb802b | 21 | 'title': 'Watch iWitness online', |
25fadd06 | 22 | 'thumbnail': 're:^https?://.*\.jpg$', |
36eb802b JMF |
23 | 'description': 'iWitness : The spirit of Ireland, one voice and one minute at a time.', |
24 | 'duration': 60.046, | |
ea1d5bdc PH |
25 | }, |
26 | 'params': { | |
27 | 'skip_download': 'f4m fails with --test atm' | |
25fadd06 | 28 | } |
29 | } | |
3462af03 | 30 | |
25fadd06 | 31 | def _real_extract(self, url): |
32 | video_id = self._match_id(url) | |
25fadd06 | 33 | webpage = self._download_webpage(url, video_id) |
ea1d5bdc | 34 | |
25fadd06 | 35 | title = self._og_search_title(webpage) |
ea1d5bdc PH |
36 | description = self._html_search_meta('description', webpage, 'description') |
37 | duration = float_or_none(self._html_search_meta( | |
38 | 'duration', webpage, 'duration', fatal=False), 1000) | |
39 | ||
40 | thumbnail_id = self._search_regex( | |
41 | r'<meta name="thumbnail" content="uri:irus:(.*?)" />', webpage, 'thumbnail') | |
42 | thumbnail = 'http://img.rasset.ie/' + thumbnail_id + '.jpg' | |
43 | ||
25fadd06 | 44 | feeds_url = self._html_search_meta("feeds-prefix", webpage, 'feeds url') + video_id |
45 | json_string = self._download_json(feeds_url, video_id) | |
ea1d5bdc | 46 | |
25fadd06 | 47 | # f4m_url = server + relative_url |
48 | f4m_url = json_string['shows'][0]['media:group'][0]['rte:server'] + json_string['shows'][0]['media:group'][0]['url'] | |
49 | f4m_formats = self._extract_f4m_formats(f4m_url, video_id) | |
ea1d5bdc | 50 | |
25fadd06 | 51 | return { |
52 | 'id': video_id, | |
53 | 'title': title, | |
54 | 'formats': f4m_formats, | |
55 | 'description': description, | |
56 | 'thumbnail': thumbnail, | |
57 | 'duration': duration, | |
ea1d5bdc | 58 | } |
896c7a23 | 59 | |
60 | ||
896c7a23 | 61 | class RteRadioIE(InfoExtractor): |
62 | IE_NAME = 'rte:radio' | |
63 | IE_DESC = 'Raidió Teilifís Éireann radio' | |
64 | # Radioplayer URLs have the specifier #!rii=<channel_id>:<id>:<playable_item_id>:<date>: | |
65 | # where the IDs are int/empty, the date is DD-MM-YYYY, and the specifier may be truncated. | |
66 | # An <id> uniquely defines an individual recording, and is the only part we require. | |
67 | _VALID_URL = r'https?://(?:www\.)?rte\.ie/radio/utils/radioplayer/rteradioweb\.html#!rii=(?:[0-9]*)(?:%3A|:)(?P<id>[0-9]+)' | |
68 | ||
69 | _TEST = { | |
70 | 'url': 'http://www.rte.ie/radio/utils/radioplayer/rteradioweb.html#!rii=16:10507902:2414:27-12-2015:', | |
71 | 'info_dict': { | |
72 | 'id': '10507902', | |
9938a17f | 73 | 'ext': 'mp4', |
896c7a23 | 74 | 'title': 'Gloria', |
75 | 'thumbnail': 're:^https?://.*\.jpg$', | |
9938a17f S |
76 | 'description': 'md5:9ce124a7fb41559ec68f06387cabddf0', |
77 | 'timestamp': 1451203200, | |
78 | 'upload_date': '20151227', | |
896c7a23 | 79 | 'duration': 7230.0, |
80 | }, | |
81 | 'params': { | |
82 | 'skip_download': 'f4m fails with --test atm' | |
83 | } | |
84 | } | |
85 | ||
86 | def _real_extract(self, url): | |
87 | item_id = self._match_id(url) | |
9938a17f S |
88 | |
89 | json_string = self._download_json( | |
90 | 'http://www.rte.ie/rteavgen/getplaylist/?type=web&format=json&id=' + item_id, | |
91 | item_id) | |
896c7a23 | 92 | |
93 | # NB the string values in the JSON are stored using XML escaping(!) | |
94 | show = json_string['shows'][0] | |
95 | title = unescapeHTML(show['title']) | |
96 | description = unescapeHTML(show.get('description')) | |
97 | thumbnail = show.get('thumbnail') | |
98 | duration = float_or_none(show.get('duration'), 1000) | |
9938a17f | 99 | timestamp = parse_iso8601(show.get('published')) |
896c7a23 | 100 | |
101 | mg = show['media:group'][0] | |
102 | ||
103 | formats = [] | |
104 | ||
105 | if mg.get('url') and not mg['url'].startswith('rtmpe:'): | |
9746f431 | 106 | formats.append({'url': mg['url']}) |
896c7a23 | 107 | |
108 | if mg.get('hls_server') and mg.get('hls_url'): | |
9746f431 S |
109 | formats.extend(self._extract_m3u8_formats( |
110 | mg['hls_server'] + mg['hls_url'], item_id, 'mp4', | |
111 | entry_protocol='m3u8_native', m3u8_id='hls', fatal=False)) | |
896c7a23 | 112 | |
113 | if mg.get('hds_server') and mg.get('hds_url'): | |
9746f431 S |
114 | formats.extend(self._extract_f4m_formats( |
115 | mg['hds_server'] + mg['hds_url'], item_id, | |
116 | f4m_id='hds', fatal=False)) | |
117 | ||
118 | self._sort_formats(formats) | |
896c7a23 | 119 | |
120 | return { | |
121 | 'id': item_id, | |
122 | 'title': title, | |
896c7a23 | 123 | 'description': description, |
124 | 'thumbnail': thumbnail, | |
9938a17f | 125 | 'timestamp': timestamp, |
896c7a23 | 126 | 'duration': duration, |
9938a17f | 127 | 'formats': formats, |
896c7a23 | 128 | } |