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,
36 'skip': 'Page Not Found',
39 'url': 'http://www1.wdr.de/themen/av/videomargaspiegelisttot101-videoplayer.html',
43 'title': 'Marga Spiegel ist tot',
44 'description': 'md5:2309992a6716c347891c045be50992e4',
45 'upload_date': '20140311',
49 'skip_download': True,
51 'skip': 'Page Not Found',
54 'url': 'http://www1.wdr.de/themen/kultur/audioerlebtegeschichtenmargaspiegel100-audioplayer.html',
55 'md5': '83e9e8fefad36f357278759870805898',
59 'title': 'Erlebte Geschichten: Marga Spiegel (29.11.2009)',
60 'description': 'md5:2309992a6716c347891c045be50992e4',
61 'upload_date': '20091129',
66 'url': 'http://www.funkhauseuropa.de/av/audioflaviacoelhoamaramar100-audioplayer.html',
67 'md5': '99a1443ff29af19f6c52cf6f4dc1f4aa',
71 'title': 'Flavia Coelho: Amar é Amar',
72 'description': 'md5:7b29e97e10dfb6e265238b32fa35b23a',
73 'upload_date': '20140717',
76 'skip': 'Page Not Found',
79 'url': 'http://www1.wdr.de/mediathek/video/sendungen/quarks_und_co/filterseite-quarks-und-co100.html',
80 'playlist_mincount': 146,
82 'id': 'mediathek/video/sendungen/quarks_und_co/filterseite-quarks-und-co100',
86 'url': 'http://www1.wdr.de/mediathek/video/livestream/index.html',
89 'title': 're:^WDR Fernsehen Live [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$',
90 'description': 'md5:ae2ff888510623bf8d4b115f95a9b7c9',
92 'upload_date': '20150101',
96 'skip_download': True,
101 def _real_extract(self, url):
102 mobj = re.match(self._VALID_URL, url)
103 page_url = mobj.group('url')
104 page_id = mobj.group('id')
106 webpage = self._download_webpage(url, page_id)
108 if mobj.group('player') is None:
110 self.url_result(page_url + href, 'WDR')
111 for href in re.findall(r'<a href="/?(.+?%s\.html)" rel="nofollow"' % self._PLAYER_REGEX, webpage)
114 if entries: # Playlist page
115 return self.playlist_result(entries, page_id)
119 for page_num in itertools.count(2):
121 r'<li class="mediathekvideo"\s*>\s*<img[^>]*>\s*<a href="(/mediathek/video/[^"]+)"',
124 self.url_result(page_url + href, 'WDR')
126 next_url_m = re.search(
127 r'<li class="nextToLast">\s*<a href="([^"]+)"', webpage)
130 next_url = page_url + next_url_m.group(1)
131 webpage = self._download_webpage(
133 note='Downloading playlist page %d' % page_num)
134 return self.playlist_result(entries, page_id)
136 flashvars = compat_parse_qs(
137 self._html_search_regex(r'<param name="flashvars" value="([^"]+)"', webpage, 'flashvars'))
139 page_id = flashvars['trackerClipId'][0]
140 video_url = flashvars['dslSrc'][0]
141 title = flashvars['trackerClipTitle'][0]
142 thumbnail = flashvars['startPicture'][0] if 'startPicture' in flashvars else None
143 is_live = flashvars.get('isLive', ['0'])[0] == '1'
146 title = self._live_title(title)
148 if 'trackerClipAirTime' in flashvars:
149 upload_date = flashvars['trackerClipAirTime'][0]
151 upload_date = self._html_search_meta('DC.Date', webpage, 'upload date')
154 upload_date = unified_strdate(upload_date)
157 preference = qualities(['S', 'M', 'L', 'XL'])
159 if video_url.endswith('.f4m'):
160 formats.extend(self._extract_f4m_formats(video_url + '?hdcore=3.2.0&plugin=aasp-3.2.0.77.18', page_id, f4m_id='hds', fatal=False))
161 elif video_url.endswith('.smil'):
162 formats.extend(self._extract_smil_formats(video_url, page_id, False, {
164 'plugin': 'aasp-3.3.0.99.43',
170 'User-Agent': 'mobile',
174 m3u8_url = self._search_regex(r'rel="adaptiv"[^>]+href="([^"]+)"', webpage, 'm3u8 url', default=None)
176 formats.extend(self._extract_m3u8_formats(m3u8_url, page_id, 'mp4', 'm3u8_native', m3u8_id='hls', fatal=False))
178 direct_urls = re.findall(r'rel="web(S|M|L|XL)"[^>]+href="([^"]+)"', webpage)
180 for quality, video_url in direct_urls:
183 'preference': preference(quality),
185 'User-Agent': 'mobile',
189 self._sort_formats(formats)
191 description = self._html_search_meta('Description', webpage, 'description')
197 'description': description,
198 'thumbnail': thumbnail,
199 'upload_date': upload_date,
204 class WDRMobileIE(InfoExtractor):
205 _VALID_URL = r'''(?x)
206 https?://mobile-ondemand\.wdr\.de/
207 .*?/fsk(?P<age_limit>[0-9]+)
209 (?P<id>[0-9]+)_(?P<title>[0-9]+)'''
210 IE_NAME = 'wdr:mobile'
212 'url': 'http://mobile-ondemand.wdr.de/CMS2010/mdb/ondemand/weltweit/fsk0/42/421735/421735_4283021.mp4',
219 'skip': 'Problems with loading data.'
222 def _real_extract(self, url):
223 mobj = re.match(self._VALID_URL, url)
225 'id': mobj.group('id'),
226 'title': mobj.group('title'),
227 'age_limit': int(mobj.group('age_limit')),
230 'User-Agent': 'mobile',
235 class WDRMausIE(InfoExtractor):
236 _VALID_URL = 'http://(?:www\.)?wdrmaus\.de/(?:[^/]+/){,2}(?P<id>[^/?#]+)(?:/index\.php5|(?<!index)\.php5|/(?:$|[?#]))'
237 IE_DESC = 'Sendung mit der Maus'
239 'url': 'http://www.wdrmaus.de/aktuelle-sendung/index.php5',
241 'id': 'aktuelle-sendung',
243 'thumbnail': 're:^http://.+\.jpg',
244 'upload_date': 're:^[0-9]{8}$',
245 'title': 're:^[0-9.]{10} - Aktuelle Sendung$',
248 'url': 'http://www.wdrmaus.de/sachgeschichten/sachgeschichten/40_jahre_maus.php5',
249 'md5': '3b1227ca3ed28d73ec5737c65743b2a3',
251 'id': '40_jahre_maus',
253 'thumbnail': 're:^http://.+\.jpg',
254 'upload_date': '20131007',
255 'title': '12.03.2011 - 40 Jahre Maus',
259 def _real_extract(self, url):
260 video_id = self._match_id(url)
262 webpage = self._download_webpage(url, video_id)
263 param_code = self._html_search_regex(
264 r'<a href="\?startVideo=1&([^"]+)"', webpage, 'parameters')
266 title_date = self._search_regex(
267 r'<div class="sendedatum"><p>Sendedatum:\s*([0-9\.]+)</p>',
269 title_str = self._html_search_regex(
270 r'<h1>(.*?)</h1>', webpage, 'title')
271 title = '%s - %s' % (title_date, title_str)
272 upload_date = unified_strdate(
273 self._html_search_meta('dc.date', webpage))
275 fields = compat_parse_qs(param_code)
276 video_url = fields['firstVideo'][0]
277 thumbnail = compat_urlparse.urljoin(url, fields['startPicture'][0])
284 jscode = self._download_webpage(
285 'http://www.wdrmaus.de/codebase/js/extended-medien.min.js',
286 video_id, fatal=False,
287 note='Downloading URL translation table',
288 errnote='Could not download URL translation table')
290 for m in re.finditer(
291 r"stream:\s*'dslSrc=(?P<stream>[^']+)',\s*download:\s*'(?P<dl>[^']+)'\s*\}",
293 if video_url.startswith(m.group('stream')):
294 http_url = video_url.replace(
295 m.group('stream'), m.group('dl'))
302 self._sort_formats(formats)
308 'thumbnail': thumbnail,
309 'upload_date': upload_date,