]>
jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/rte.py
2 from __future__
import unicode_literals
4 from . common
import InfoExtractor
12 class RteIE ( InfoExtractor
):
14 IE_DESC
= 'Raidió Teilifís Éireann TV'
15 _VALID_URL
= r
'https?://(?:www\.)?rte\.ie/player/[^/] {2,3} /show/[^/]+/(?P<id>[0-9]+)'
17 'url' : 'http://www.rte.ie/player/ie/show/iwitness-862/10478715/' ,
21 'title' : 'Watch iWitness online' ,
22 'thumbnail' : 're:^https?://.*\.jpg$' ,
23 'description' : 'iWitness : The spirit of Ireland, one voice and one minute at a time.' ,
27 'skip_download' : 'f4m fails with --test atm'
31 def _real_extract ( self
, url
):
32 video_id
= self
._ match
_ id
( url
)
33 webpage
= self
._ download
_ webpage
( url
, video_id
)
35 title
= self
._ og
_ search
_ title
( webpage
)
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 )
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'
44 feeds_url
= self
._ html
_ search
_ meta
( "feeds-prefix" , webpage
, 'feeds url' ) + video_id
45 json_string
= self
._ download
_ json
( feeds_url
, video_id
)
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
_ f
4 m
_ formats
( f4m_url
, video_id
)
54 'formats' : f4m_formats
,
55 'description' : description
,
56 'thumbnail' : thumbnail
,
61 class RteRadioIE ( InfoExtractor
):
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]+)'
70 'url' : 'http://www.rte.ie/radio/utils/radioplayer/rteradioweb.html#!rii=16:10507902:2414:27-12-2015:' ,
75 'thumbnail' : 're:^https?://.*\.jpg$' ,
76 '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.' ,
80 'skip_download' : 'f4m fails with --test atm'
84 def _real_extract ( self
, url
):
85 item_id
= self
._ match
_ id
( url
)
86 feeds_url
= 'http://www.rte.ie/rteavgen/getplaylist/?type=web&format=json&id=' + item_id
87 json_string
= self
._ download
_ json
( feeds_url
, item_id
)
89 # NB the string values in the JSON are stored using XML escaping(!)
90 show
= json_string
[ 'shows' ][ 0 ]
91 title
= unescapeHTML ( show
[ 'title' ])
92 description
= unescapeHTML ( show
. get ( 'description' ))
93 thumbnail
= show
. get ( 'thumbnail' )
94 duration
= float_or_none ( show
. get ( 'duration' ), 1000 )
96 mg
= show
[ 'media:group' ][ 0 ]
100 if mg
. get ( 'url' ) and not mg
[ 'url' ]. startswith ( 'rtmpe:' ):
101 formats
. append ( {'url': mg.get('url')}
)
103 if mg
. get ( 'hls_server' ) and mg
. get ( 'hls_url' ):
104 hls_url
= mg
[ 'hls_server' ] + mg
[ 'hls_url' ]
105 hls_formats
= self
._ extract
_ m
3u8_ formats
(
106 hls_url
, item_id
, 'mp4' , m3u8_id
= 'hls' , fatal
= False )
107 formats
. extend ( hls_formats
)
109 if mg
. get ( 'hds_server' ) and mg
. get ( 'hds_url' ):
110 f4m_url
= mg
[ 'hds_server' ] + mg
[ 'hds_url' ]
111 f4m_formats
= self
._ extract
_ f
4 m
_ formats
(
112 f4m_url
, item_id
, f4m_id
= 'hds' , fatal
= False )
113 formats
. extend ( f4m_formats
)
119 'description' : description
,
120 'thumbnail' : thumbnail
,
121 'duration' : duration
,