]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/orf.py
2 from __future__
import unicode_literals
9 from . common
import InfoExtractor
17 class ORFTVthekIE ( InfoExtractor
):
18 IE_NAME
= 'orf:tvthek'
19 IE_DESC
= 'ORF TVthek'
20 _VALID_URL
= r
'https?://tvthek\.orf\.at/(?:programs/.+?/episodes|topics?/.+?|program/[^/]+)/(?P<id>\d+)'
23 'url' : 'http://tvthek.orf.at/program/Aufgetischt/2745173/Aufgetischt-Mit-der-Steirischen-Tafelrunde/8891389' ,
25 'md5' : '2942210346ed779588f428a92db88712' ,
29 'title' : 'Aufgetischt: Mit der Steirischen Tafelrunde' ,
30 'description' : 'md5:c1272f0245537812d4e36419c207b67d' ,
32 'upload_date' : '20141208' ,
35 'skip' : 'Blocked outside of Austria / Germany' ,
37 'url' : 'http://tvthek.orf.at/topic/Im-Wandel-der-Zeit/8002126/Best-of-Ingrid-Thurnher/7982256' ,
39 'md5' : '68f543909aea49d621dfc7703a11cfaf' ,
43 'title' : 'Best of Ingrid Thurnher' ,
44 'upload_date' : '20140527' ,
45 '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".' ,
48 '_skip' : 'Blocked outside of Austria / Germany' ,
51 def _real_extract ( self
, url
):
52 playlist_id
= self
._ match
_ id
( url
)
53 webpage
= self
._ download
_ webpage
( url
, playlist_id
)
55 data_json
= self
._ search
_ regex
(
56 r
'initializeAdworx\((.+?)\);\n' , webpage
, 'video info' )
57 all_data
= json
. loads ( data_json
)
59 def get_segments ( all_data
):
62 'Tracker::EPISODE_DETAIL_PAGE_OVER_PROGRAM' ,
63 'Tracker::EPISODE_DETAIL_PAGE_OVER_TOPIC' ):
64 return data
[ 'values' ][ 'segments' ]
66 sdata
= get_segments ( all_data
)
68 raise ExtractorError ( 'Unable to extract segments' )
70 def quality_to_int ( s
):
71 m
= re
. search ( '([0-9]+)' , s
)
74 return int ( m
. group ( 1 ))
80 'preference' : - 10 if fd
[ 'delivery' ] == 'hls' else None ,
81 'format_id' : ' %s-%s-%s ' % (
82 fd
[ 'delivery' ], fd
[ 'quality' ], fd
[ 'quality_string' ]),
84 'protocol' : fd
[ 'protocol' ],
85 'quality' : quality_to_int ( fd
[ 'quality' ]),
86 } for fd
in sd
[ 'playlist_item_array' ][ 'sources' ]]
88 # Check for geoblocking.
89 # There is a property is_geoprotection, but that's always false
90 geo_str
= sd
. get ( 'geoprotection_string' )
96 if re
. match ( r
'^https?://.*\.mp4$' , f
[ 'url' ]))
100 req
= HEADRequest ( http_url
)
101 self
._ request
_ webpage
(
103 note
= 'Testing for geoblocking' ,
105 'This video seems to be blocked outside of %s . '
106 'You may want to try the streaming-* formats.' )
110 self
._ sort
_ formats
( formats
)
112 upload_date
= unified_strdate ( sd
[ 'created_date' ])
116 'title' : sd
[ 'header' ],
118 'description' : sd
. get ( 'description' ),
119 'duration' : int ( sd
[ 'duration_in_seconds' ]),
120 'upload_date' : upload_date
,
121 'thumbnail' : sd
. get ( 'image_full_url' ),
131 class ORFOE1IE ( InfoExtractor
):
133 IE_DESC
= 'Radio Österreich 1'
134 _VALID_URL
= r
'http://oe1\.orf\.at/(?:programm/|konsole.*?#\?track_id=)(?P<id>[0-9]+)'
136 # Audios on ORF radio are only available for 7 days, so we can't add tests.
138 'url' : 'http://oe1.orf.at/konsole?show=on_demand#?track_id=394211' ,
139 'only_matching' : True ,
142 def _real_extract ( self
, url
):
143 show_id
= self
._ match
_ id
( url
)
144 data
= self
._ download
_ json
(
145 'http://oe1.orf.at/programm/ %s /konsole' % show_id
,
149 timestamp
= datetime
. datetime
. strptime ( ' %s %s ' % (
150 data
[ 'item' ][ 'day_label' ],
153 unix_timestamp
= calendar
. timegm ( timestamp
. utctimetuple ())
157 'title' : data
[ 'item' ][ 'title' ],
158 'url' : data
[ 'item' ][ 'url_stream' ],
160 'description' : data
[ 'item' ]. get ( 'info' ),
161 'timestamp' : unix_timestamp
165 class ORFFM4IE ( InfoExtractor
):
167 IE_DESC
= 'radio FM4'
168 _VALID_URL
= r
'http://fm4\.orf\.at/7tage/?#(?P<date>[0-9]+)/(?P<show>\w+)'
170 def _real_extract ( self
, url
):
171 mobj
= re
. match ( self
._ VALID
_U RL
, url
)
172 show_date
= mobj
. group ( 'date' )
173 show_id
= mobj
. group ( 'show' )
175 data
= self
._ download
_ json
(
176 'http://audioapi.orf.at/fm4/json/2.0/broadcasts/ %s /4 %s ' % ( show_date
, show_id
),
180 def extract_entry_dict ( info
, title
, subtitle
):
182 'id' : info
[ 'loopStreamId' ]. replace ( '.mp3' , '' ),
183 'url' : 'http://loopstream01.apa.at/?channel=fm4&id= %s ' % info
[ 'loopStreamId' ],
185 'description' : subtitle
,
186 'duration' : ( info
[ 'end' ] - info
[ 'start' ]) / 1000 ,
187 'timestamp' : info
[ 'start' ] / 1000 ,
191 entries
= [ extract_entry_dict ( t
, data
[ 'title' ], data
[ 'subtitle' ]) for t
in data
[ 'streams' ]]
196 'title' : data
[ 'title' ],
197 'description' : data
[ 'subtitle' ],