]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/rte.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
7 from ..compat
import compat_HTTPError
19 class RteBaseIE(InfoExtractor
):
20 def _real_extract(self
, url
):
21 item_id
= self
._match
_id
(url
)
27 'https://feeds.rasset.ie/rteavgen/player/playlist?type=iptv&format=json&showId=',
28 'http://www.rte.ie/rteavgen/getplaylist/?type=web&format=json&id=',
31 for num
, ep_url
in enumerate(ENDPOINTS
, start
=1):
33 data
= self
._download
_json
(ep_url
+ item_id
, item_id
)
34 except ExtractorError
as ee
:
35 if num
< len(ENDPOINTS
) or formats
:
37 if isinstance(ee
.cause
, compat_HTTPError
) and ee
.cause
.code
== 404:
38 error_info
= self
._parse
_json
(ee
.cause
.read().decode(), item_id
, fatal
=False)
41 '%s said: %s' % (self
.IE_NAME
, error_info
['message']),
45 # NB the string values in the JSON are stored using XML escaping(!)
46 show
= try_get(data
, lambda x
: x
['shows'][0], dict)
51 title
= unescapeHTML(show
['title'])
52 description
= unescapeHTML(show
.get('description'))
53 thumbnail
= show
.get('thumbnail')
54 duration
= float_or_none(show
.get('duration'), 1000)
55 timestamp
= parse_iso8601(show
.get('published'))
59 'description': description
,
60 'thumbnail': thumbnail
,
61 'timestamp': timestamp
,
65 mg
= try_get(show
, lambda x
: x
['media:group'][0], dict)
70 m
= re
.match(r
'(?P<url>rtmpe?://[^/]+)/(?P<app>.+)/(?P<playpath>mp4:.*)', mg
['url'])
74 'url': m
['url'] + '/' + m
['app'],
76 'play_path': m
['playpath'],
82 if mg
.get('hls_server') and mg
.get('hls_url'):
83 formats
.extend(self
._extract
_m
3u8_formats
(
84 mg
['hls_server'] + mg
['hls_url'], item_id
, 'mp4',
85 entry_protocol
='m3u8_native', m3u8_id
='hls', fatal
=False))
87 if mg
.get('hds_server') and mg
.get('hds_url'):
88 formats
.extend(self
._extract
_f
4m
_formats
(
89 mg
['hds_server'] + mg
['hds_url'], item_id
,
90 f4m_id
='hds', fatal
=False))
92 mg_rte_server
= str_or_none(mg
.get('rte:server'))
93 mg_url
= str_or_none(mg
.get('url'))
94 if mg_rte_server
and mg_url
:
95 hds_url
= url_or_none(mg_rte_server
+ mg_url
)
97 formats
.extend(self
._extract
_f
4m
_formats
(
98 hds_url
, item_id
, f4m_id
='hds', fatal
=False))
100 self
._sort
_formats
(formats
)
102 info_dict
['formats'] = formats
106 class RteIE(RteBaseIE
):
108 IE_DESC
= 'Raidió Teilifís Éireann TV'
109 _VALID_URL
= r
'https?://(?:www\.)?rte\.ie/player/[^/]{2,3}/show/[^/]+/(?P<id>[0-9]+)'
111 'url': 'http://www.rte.ie/player/ie/show/iwitness-862/10478715/',
112 'md5': '4a76eb3396d98f697e6e8110563d2604',
117 'thumbnail': r
're:^https?://.*\.jpg$',
118 'description': 'The spirit of Ireland, one voice and one minute at a time.',
120 'upload_date': '20151012',
121 'timestamp': 1444694160,
126 class RteRadioIE(RteBaseIE
):
127 IE_NAME
= 'rte:radio'
128 IE_DESC
= 'Raidió Teilifís Éireann radio'
129 # Radioplayer URLs have two distinct specifier formats,
130 # the old format #!rii=<channel_id>:<id>:<playable_item_id>:<date>:
131 # the new format #!rii=b<channel_id>_<id>_<playable_item_id>_<date>_
132 # where the IDs are int/empty, the date is DD-MM-YYYY, and the specifier may be truncated.
133 # An <id> uniquely defines an individual recording, and is the only part we require.
134 _VALID_URL
= r
'https?://(?:www\.)?rte\.ie/radio/utils/radioplayer/rteradioweb\.html#!rii=(?:b?[0-9]*)(?:%3A|:|%5F|_)(?P<id>[0-9]+)'
137 # Old-style player URL; HLS and RTMPE formats
138 'url': 'http://www.rte.ie/radio/utils/radioplayer/rteradioweb.html#!rii=16:10507902:2414:27-12-2015:',
139 'md5': 'c79ccb2c195998440065456b69760411',
144 'thumbnail': r
're:^https?://.*\.jpg$',
145 'description': 'md5:9ce124a7fb41559ec68f06387cabddf0',
146 'timestamp': 1451203200,
147 'upload_date': '20151227',
151 # New-style player URL; RTMPE formats only
152 'url': 'http://rte.ie/radio/utils/radioplayer/rteradioweb.html#!rii=b16_3250678_8861_06-04-2012_',
156 'title': 'The Lyric Concert with Paul Herriott',
157 'thumbnail': r
're:^https?://.*\.jpg$',
159 'timestamp': 1333742400,
160 'upload_date': '20120406',
161 'duration': 7199.016,
165 'skip_download': True,