]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/wdr.py
1 # -*- coding: utf-8 -*-
2 from __future__
import unicode_literals
7 from .common
import InfoExtractor
18 class WDRIE(InfoExtractor
):
19 _PLAYER_REGEX
= '-(?:video|audio)player(?:_size-[LMS])?'
20 _VALID_URL
= r
'(?P<url>https?://www\d?\.(?:wdr\d?|funkhauseuropa)\.de/)(?P<id>.+?)(?P<player>%s)?\.html' % _PLAYER_REGEX
24 'url': 'http://www1.wdr.de/mediathek/video/sendungen/servicezeit/videoservicezeit560-videoplayer_size-L.html',
28 'title': 'Servicezeit',
29 'description': 'md5:c8f43e5e815eeb54d0b96df2fba906cb',
30 'upload_date': '20140310',
34 'skip_download': True,
38 'url': 'http://www1.wdr.de/themen/av/videomargaspiegelisttot101-videoplayer.html',
42 'title': 'Marga Spiegel ist tot',
43 'description': 'md5:2309992a6716c347891c045be50992e4',
44 'upload_date': '20140311',
48 'skip_download': True,
52 'url': 'http://www1.wdr.de/themen/kultur/audioerlebtegeschichtenmargaspiegel100-audioplayer.html',
53 'md5': '83e9e8fefad36f357278759870805898',
57 'title': 'Erlebte Geschichten: Marga Spiegel (29.11.2009)',
58 'description': 'md5:2309992a6716c347891c045be50992e4',
59 'upload_date': '20091129',
64 'url': 'http://www.funkhauseuropa.de/av/audioflaviacoelhoamaramar100-audioplayer.html',
65 'md5': '99a1443ff29af19f6c52cf6f4dc1f4aa',
69 'title': 'Flavia Coelho: Amar é Amar',
70 'description': 'md5:7b29e97e10dfb6e265238b32fa35b23a',
71 'upload_date': '20140717',
76 'url': 'http://www1.wdr.de/mediathek/video/sendungen/quarks_und_co/filterseite-quarks-und-co100.html',
77 'playlist_mincount': 146,
79 'id': 'mediathek/video/sendungen/quarks_und_co/filterseite-quarks-und-co100',
83 'url': 'http://www1.wdr.de/mediathek/video/livestream/index.html',
86 'title': 're:^WDR Fernsehen [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$',
87 'description': 'md5:ae2ff888510623bf8d4b115f95a9b7c9',
89 'upload_date': '20150212',
93 'skip_download': True,
98 def _real_extract(self
, url
):
99 mobj
= re
.match(self
._VALID
_URL
, url
)
100 page_url
= mobj
.group('url')
101 page_id
= mobj
.group('id')
103 webpage
= self
._download
_webpage
(url
, page_id
)
105 if mobj
.group('player') is None:
107 self
.url_result(page_url
+ href
, 'WDR')
108 for href
in re
.findall(r
'<a href="/?(.+?%s\.html)" rel="nofollow"' % self
._PLAYER
_REGEX
, webpage
)
111 if entries
: # Playlist page
112 return self
.playlist_result(entries
, page_id
)
116 for page_num
in itertools
.count(2):
118 r
'<li class="mediathekvideo"\s*>\s*<img[^>]*>\s*<a href="(/mediathek/video/[^"]+)"',
121 self
.url_result(page_url
+ href
, 'WDR')
123 next_url_m
= re
.search(
124 r
'<li class="nextToLast">\s*<a href="([^"]+)"', webpage
)
127 next_url
= page_url
+ next_url_m
.group(1)
128 webpage
= self
._download
_webpage
(
130 note
='Downloading playlist page %d' % page_num
)
131 return self
.playlist_result(entries
, page_id
)
133 flashvars
= compat_parse_qs(
134 self
._html
_search
_regex
(r
'<param name="flashvars" value="([^"]+)"', webpage
, 'flashvars'))
136 page_id
= flashvars
['trackerClipId'][0]
137 video_url
= flashvars
['dslSrc'][0]
138 title
= flashvars
['trackerClipTitle'][0]
139 thumbnail
= flashvars
['startPicture'][0] if 'startPicture' in flashvars
else None
140 is_live
= flashvars
.get('isLive', ['0'])[0] == '1'
143 title
= self
._live
_title
(title
)
145 if 'trackerClipAirTime' in flashvars
:
146 upload_date
= flashvars
['trackerClipAirTime'][0]
148 upload_date
= self
._html
_search
_meta
('DC.Date', webpage
, 'upload date')
151 upload_date
= unified_strdate(upload_date
)
153 if video_url
.endswith('.f4m'):
154 video_url
+= '?hdcore=3.2.0&plugin=aasp-3.2.0.77.18'
156 elif video_url
.endswith('.smil'):
157 fmt
= self
._extract
_smil
_formats
(video_url
, page_id
)[0]
158 video_url
= fmt
['url']
159 sep
= '&' if '?' in video_url
else '?'
161 video_url
+= 'hdcore=3.3.0&plugin=aasp-3.3.0.99.43'
164 ext
= determine_ext(video_url
)
166 description
= self
._html
_search
_meta
('Description', webpage
, 'description')
173 'description': description
,
174 'thumbnail': thumbnail
,
175 'upload_date': upload_date
,
180 class WDRMobileIE(InfoExtractor
):
181 _VALID_URL
= r
'''(?x)
182 https?://mobile-ondemand\.wdr\.de/
183 .*?/fsk(?P<age_limit>[0-9]+)
185 (?P<id>[0-9]+)_(?P<title>[0-9]+)'''
186 IE_NAME
= 'wdr:mobile'
188 'url': 'http://mobile-ondemand.wdr.de/CMS2010/mdb/ondemand/weltweit/fsk0/42/421735/421735_4283021.mp4',
195 'skip': 'Problems with loading data.'
198 def _real_extract(self
, url
):
199 mobj
= re
.match(self
._VALID
_URL
, url
)
201 'id': mobj
.group('id'),
202 'title': mobj
.group('title'),
203 'age_limit': int(mobj
.group('age_limit')),
206 'User-Agent': 'mobile',
211 class WDRMausIE(InfoExtractor
):
212 _VALID_URL
= 'http://(?:www\.)?wdrmaus\.de/(?:[^/]+/){,2}(?P<id>[^/?#]+)(?:/index\.php5|(?<!index)\.php5|/(?:$|[?#]))'
213 IE_DESC
= 'Sendung mit der Maus'
215 'url': 'http://www.wdrmaus.de/aktuelle-sendung/index.php5',
217 'id': 'aktuelle-sendung',
219 'thumbnail': 're:^http://.+\.jpg',
220 'upload_date': 're:^[0-9]{8}$',
221 'title': 're:^[0-9.]{10} - Aktuelle Sendung$',
224 'url': 'http://www.wdrmaus.de/sachgeschichten/sachgeschichten/40_jahre_maus.php5',
225 'md5': '3b1227ca3ed28d73ec5737c65743b2a3',
227 'id': '40_jahre_maus',
229 'thumbnail': 're:^http://.+\.jpg',
230 'upload_date': '20131007',
231 'title': '12.03.2011 - 40 Jahre Maus',
235 def _real_extract(self
, url
):
236 video_id
= self
._match
_id
(url
)
238 webpage
= self
._download
_webpage
(url
, video_id
)
239 param_code
= self
._html
_search
_regex
(
240 r
'<a href="\?startVideo=1&([^"]+)"', webpage
, 'parameters')
242 title_date
= self
._search
_regex
(
243 r
'<div class="sendedatum"><p>Sendedatum:\s*([0-9\.]+)</p>',
245 title_str
= self
._html
_search
_regex
(
246 r
'<h1>(.*?)</h1>', webpage
, 'title')
247 title
= '%s - %s' % (title_date
, title_str
)
248 upload_date
= unified_strdate(
249 self
._html
_search
_meta
('dc.date', webpage
))
251 fields
= compat_parse_qs(param_code
)
252 video_url
= fields
['firstVideo'][0]
253 thumbnail
= compat_urlparse
.urljoin(url
, fields
['startPicture'][0])
260 jscode
= self
._download
_webpage
(
261 'http://www.wdrmaus.de/codebase/js/extended-medien.min.js',
262 video_id
, fatal
=False,
263 note
='Downloading URL translation table',
264 errnote
='Could not download URL translation table')
266 for m
in re
.finditer(
267 r
"stream:\s*'dslSrc=(?P<stream>[^']+)',\s*download:\s*'(?P<dl>[^']+)'\s*\}",
269 if video_url
.startswith(m
.group('stream')):
270 http_url
= video_url
.replace(
271 m
.group('stream'), m
.group('dl'))
278 self
._sort
_formats
(formats
)
284 'thumbnail': thumbnail
,
285 'upload_date': upload_date
,