]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/orf.py
6ae30679a0a226b0d242b2ef773fbab9a90920c5
2 from __future__
import unicode_literals
9 from . common
import InfoExtractor
22 class ORFTVthekIE ( InfoExtractor
):
23 IE_NAME
= 'orf:tvthek'
24 IE_DESC
= 'ORF TVthek'
25 _VALID_URL
= r
'https?://tvthek\.orf\.at/(?:programs/.+?/episodes|topics?/.+?|program/[^/]+)/(?P<id>\d+)'
28 'url' : 'http://tvthek.orf.at/program/Aufgetischt/2745173/Aufgetischt-Mit-der-Steirischen-Tafelrunde/8891389' ,
30 'md5' : '2942210346ed779588f428a92db88712' ,
34 'title' : 'Aufgetischt: Mit der Steirischen Tafelrunde' ,
35 'description' : 'md5:c1272f0245537812d4e36419c207b67d' ,
37 'upload_date' : '20141208' ,
40 'skip' : 'Blocked outside of Austria / Germany' ,
42 'url' : 'http://tvthek.orf.at/topic/Im-Wandel-der-Zeit/8002126/Best-of-Ingrid-Thurnher/7982256' ,
46 'title' : 'Best of Ingrid Thurnher' ,
47 'upload_date' : '20140527' ,
48 'description' : 'Viele Jahre war Ingrid Thurnher das "Gesicht" der ZIB 2. Vor ihrem Wechsel zur ZIB 2 im Jahr 1995 moderierte sie unter anderem "Land und Leute", "Österreich-Bild" und "Niederösterreich heute".' ,
51 'skip_download' : True , # rtsp downloads
53 '_skip' : 'Blocked outside of Austria / Germany' ,
56 def _real_extract ( self
, url
):
57 playlist_id
= self
._ match
_ id
( url
)
58 webpage
= self
._ download
_ webpage
( url
, playlist_id
)
60 data_json
= self
._ search
_ regex
(
61 r
'initializeAdworx\((.+?)\);\n' , webpage
, 'video info' )
62 all_data
= json
. loads ( data_json
)
64 def get_segments ( all_data
):
67 'Tracker::EPISODE_DETAIL_PAGE_OVER_PROGRAM' ,
68 'Tracker::EPISODE_DETAIL_PAGE_OVER_TOPIC' ):
69 return data
[ 'values' ][ 'segments' ]
71 sdata
= get_segments ( all_data
)
73 raise ExtractorError ( 'Unable to extract segments' )
75 def quality_to_int ( s
):
76 m
= re
. search ( '([0-9]+)' , s
)
79 return int ( m
. group ( 1 ))
85 'preference' : - 10 if fd
[ 'delivery' ] == 'hls' else None ,
86 'format_id' : ' %s-%s-%s ' % (
87 fd
[ 'delivery' ], fd
[ 'quality' ], fd
[ 'quality_string' ]),
89 'protocol' : fd
[ 'protocol' ],
90 'quality' : quality_to_int ( fd
[ 'quality' ]),
91 } for fd
in sd
[ 'playlist_item_array' ][ 'sources' ]]
93 # Check for geoblocking.
94 # There is a property is_geoprotection, but that's always false
95 geo_str
= sd
. get ( 'geoprotection_string' )
101 if re
. match ( r
'^https?://.*\.mp4$' , f
[ 'url' ]))
102 except StopIteration :
105 req
= HEADRequest ( http_url
)
106 self
._ request
_ webpage
(
108 note
= 'Testing for geoblocking' ,
110 'This video seems to be blocked outside of %s . '
111 'You may want to try the streaming-* formats.' )
115 self
._ check
_ formats
( formats
, video_id
)
116 self
._ sort
_ formats
( formats
)
118 upload_date
= unified_strdate ( sd
[ 'created_date' ])
122 'title' : sd
[ 'header' ],
124 'description' : sd
. get ( 'description' ),
125 'duration' : int ( sd
[ 'duration_in_seconds' ]),
126 'upload_date' : upload_date
,
127 'thumbnail' : sd
. get ( 'image_full_url' ),
137 class ORFOE1IE ( InfoExtractor
):
139 IE_DESC
= 'Radio Österreich 1'
140 _VALID_URL
= r
'https?://oe1\.orf\.at/(?:programm/|konsole\?.*?\btrack_id=)(?P<id>[0-9]+)'
142 # Audios on ORF radio are only available for 7 days, so we can't add tests.
144 'url' : 'http://oe1.orf.at/konsole?show=on_demand#?track_id=394211' ,
145 'only_matching' : True ,
147 'url' : 'http://oe1.orf.at/konsole?show=ondemand&track_id=443608&load_day=/programm/konsole/tag/20160726' ,
148 'only_matching' : True ,
151 def _real_extract ( self
, url
):
152 show_id
= self
._ match
_ id
( url
)
153 data
= self
._ download
_ json
(
154 'http://oe1.orf.at/programm/ %s /konsole' % show_id
,
158 timestamp
= datetime
. datetime
. strptime ( ' %s %s ' % (
159 data
[ 'item' ][ 'day_label' ],
162 unix_timestamp
= calendar
. timegm ( timestamp
. utctimetuple ())
166 'title' : data
[ 'item' ][ 'title' ],
167 'url' : data
[ 'item' ][ 'url_stream' ],
169 'description' : data
[ 'item' ]. get ( 'info' ),
170 'timestamp' : unix_timestamp
174 class ORFFM4IE ( InfoExtractor
):
176 IE_DESC
= 'radio FM4'
177 _VALID_URL
= r
'https?://fm4\.orf\.at/(?:7tage/?#|player/)(?P<date>[0-9]+)/(?P<show>\w+)'
180 'url' : 'http://fm4.orf.at/player/20160110/IS/' ,
181 'md5' : '01e736e8f1cef7e13246e880a59ad298' ,
183 'id' : '2016-01-10_2100_tl_54_7DaysSun13_11244' ,
186 'description' : 'md5:384c543f866c4e422a55f66a62d669cd' ,
188 'timestamp' : 1452456073 ,
189 'upload_date' : '20160110' ,
191 'skip' : 'Live streams on FM4 got deleted soon' ,
194 def _real_extract ( self
, url
):
195 mobj
= re
. match ( self
._ VALID
_U RL
, url
)
196 show_date
= mobj
. group ( 'date' )
197 show_id
= mobj
. group ( 'show' )
199 data
= self
._ download
_ json
(
200 'http://audioapi.orf.at/fm4/json/2.0/broadcasts/ %s /4 %s ' % ( show_date
, show_id
),
204 def extract_entry_dict ( info
, title
, subtitle
):
206 'id' : info
[ 'loopStreamId' ]. replace ( '.mp3' , '' ),
207 'url' : 'http://loopstream01.apa.at/?channel=fm4&id= %s ' % info
[ 'loopStreamId' ],
209 'description' : subtitle
,
210 'duration' : ( info
[ 'end' ] - info
[ 'start' ]) / 1000 ,
211 'timestamp' : info
[ 'start' ] / 1000 ,
215 entries
= [ extract_entry_dict ( t
, data
[ 'title' ], data
[ 'subtitle' ]) for t
in data
[ 'streams' ]]
220 'title' : data
[ 'title' ],
221 'description' : data
[ 'subtitle' ],
226 class ORFIPTVIE ( InfoExtractor
):
228 IE_DESC
= 'iptv.ORF.at'
229 _VALID_URL
= r
'https?://iptv\.orf\.at/(?:#/)?stories/(?P<id>\d+)'
232 'url' : 'http://iptv.orf.at/stories/2275236/' ,
233 'md5' : 'c8b22af4718a4b4af58342529453e3e5' ,
237 'title' : 'Weitere Evakuierungen um Vulkan Calbuco' ,
238 'description' : 'md5:d689c959bdbcf04efeddedbf2299d633' ,
240 'thumbnail' : 're:^https?://.*\.jpg$' ,
241 'upload_date' : '20150425' ,
245 def _real_extract ( self
, url
):
246 story_id
= self
._ match
_ id
( url
)
248 webpage
= self
._ download
_ webpage
(
249 'http://iptv.orf.at/stories/ %s ' % story_id
, story_id
)
251 video_id
= self
._ search
_ regex
(
252 r
'data-video(?:id)?="(\d+)"' , webpage
, 'video id' )
254 data
= self
._ download
_ json
(
255 'http://bits.orf.at/filehandler/static-api/json/current/data.json?file= %s ' % video_id
,
258 duration
= float_or_none ( data
[ 'duration' ], 1000 )
260 video
= data
[ 'sources' ][ 'default' ]
261 load_balancer_url
= video
[ 'loadBalancerUrl' ]
262 abr
= int_or_none ( video
. get ( 'audioBitrate' ))
263 vbr
= int_or_none ( video
. get ( 'bitrate' ))
264 fps
= int_or_none ( video
. get ( 'videoFps' ))
265 width
= int_or_none ( video
. get ( 'videoWidth' ))
266 height
= int_or_none ( video
. get ( 'videoHeight' ))
267 thumbnail
= video
. get ( 'preview' )
269 rendition
= self
._ download
_ json
(
270 load_balancer_url
, video_id
, transform_source
= strip_jsonp
)
281 for format_id
, format_url
in rendition
[ 'redirect' ]. items ():
282 if format_id
== 'rtmp' :
286 'format_id' : format_id
,
289 elif determine_ext ( format_url
) == 'f4m' :
290 formats
. extend ( self
._ extract
_ f
4 m
_ formats
(
291 format_url
, video_id
, f4m_id
= format_id
))
292 elif determine_ext ( format_url
) == 'm3u8' :
293 formats
. extend ( self
._ extract
_ m
3u8_ formats
(
294 format_url
, video_id
, 'mp4' , m3u8_id
= format_id
))
297 self
._ sort
_ formats
( formats
)
299 title
= remove_end ( self
._ og
_ search
_ title
( webpage
), ' - iptv.ORF.at' )
300 description
= self
._ og
_ search
_ description
( webpage
)
301 upload_date
= unified_strdate ( self
._ html
_ search
_ meta
(
302 'dc.date' , webpage
, 'upload date' ))
307 'description' : description
,
308 'duration' : duration
,
309 'thumbnail' : thumbnail
,
310 'upload_date' : upload_date
,