]>
Commit | Line | Data |
---|---|---|
7807ee66 | 1 | # -*- coding: utf-8 -*- |
b461641f S |
2 | from __future__ import unicode_literals |
3 | ||
4 | import re | |
5 | ||
6 | from .common import InfoExtractor | |
7 | from ..utils import ( | |
cd7481a3 | 8 | compat_parse_qs, |
b461641f S |
9 | compat_urlparse, |
10 | determine_ext, | |
cd7481a3 | 11 | unified_strdate, |
b461641f S |
12 | ) |
13 | ||
14 | ||
15 | class WDRIE(InfoExtractor): | |
16 | _PLAYER_REGEX = '-(?:video|audio)player(?:_size-[LMS])?' | |
17 | _VALID_URL = r'(?P<url>https?://www\d?\.(?:wdr\d?|funkhauseuropa)\.de/)(?P<id>.+?)(?P<player>%s)?\.html' % _PLAYER_REGEX | |
18 | ||
19 | _TESTS = [ | |
20 | { | |
21 | 'url': 'http://www1.wdr.de/mediathek/video/sendungen/servicezeit/videoservicezeit560-videoplayer_size-L.html', | |
22 | 'info_dict': { | |
23 | 'id': 'mdb-362427', | |
24 | 'ext': 'flv', | |
25 | 'title': 'Servicezeit', | |
26 | 'description': 'md5:c8f43e5e815eeb54d0b96df2fba906cb', | |
27 | 'upload_date': '20140310', | |
28 | }, | |
29 | 'params': { | |
30 | 'skip_download': True, | |
31 | }, | |
32 | }, | |
33 | { | |
34 | 'url': 'http://www1.wdr.de/themen/av/videomargaspiegelisttot101-videoplayer.html', | |
35 | 'info_dict': { | |
36 | 'id': 'mdb-363194', | |
37 | 'ext': 'flv', | |
38 | 'title': 'Marga Spiegel ist tot', | |
87a29e6f | 39 | 'description': 'md5:2309992a6716c347891c045be50992e4', |
b461641f S |
40 | 'upload_date': '20140311', |
41 | }, | |
42 | 'params': { | |
43 | 'skip_download': True, | |
44 | }, | |
45 | }, | |
46 | { | |
47 | 'url': 'http://www1.wdr.de/themen/kultur/audioerlebtegeschichtenmargaspiegel100-audioplayer.html', | |
48 | 'md5': '83e9e8fefad36f357278759870805898', | |
49 | 'info_dict': { | |
50 | 'id': 'mdb-194332', | |
51 | 'ext': 'mp3', | |
52 | 'title': 'Erlebte Geschichten: Marga Spiegel (29.11.2009)', | |
87a29e6f | 53 | 'description': 'md5:2309992a6716c347891c045be50992e4', |
b461641f S |
54 | 'upload_date': '20091129', |
55 | }, | |
56 | }, | |
57 | { | |
ff1956e0 PH |
58 | 'url': 'http://www.funkhauseuropa.de/av/audioflaviacoelhoamaramar100-audioplayer.html', |
59 | 'md5': '99a1443ff29af19f6c52cf6f4dc1f4aa', | |
b461641f | 60 | 'info_dict': { |
ff1956e0 | 61 | 'id': 'mdb-478135', |
b461641f | 62 | 'ext': 'mp3', |
ff1956e0 | 63 | 'title': 'Flavia Coelho: Amar é Amar', |
87a29e6f | 64 | 'description': 'md5:7b29e97e10dfb6e265238b32fa35b23a', |
ff1956e0 | 65 | 'upload_date': '20140717', |
b461641f S |
66 | }, |
67 | }, | |
68 | ] | |
69 | ||
70 | def _real_extract(self, url): | |
71 | mobj = re.match(self._VALID_URL, url) | |
72 | page_url = mobj.group('url') | |
73 | page_id = mobj.group('id') | |
74 | ||
75 | webpage = self._download_webpage(url, page_id) | |
76 | ||
77 | if mobj.group('player') is None: | |
78 | entries = [ | |
79 | self.url_result(page_url + href, 'WDR') | |
80 | for href in re.findall(r'<a href="/?(.+?%s\.html)" rel="nofollow"' % self._PLAYER_REGEX, webpage) | |
81 | ] | |
82 | return self.playlist_result(entries, page_id) | |
83 | ||
84 | flashvars = compat_urlparse.parse_qs( | |
85 | self._html_search_regex(r'<param name="flashvars" value="([^"]+)"', webpage, 'flashvars')) | |
86 | ||
87 | page_id = flashvars['trackerClipId'][0] | |
88 | video_url = flashvars['dslSrc'][0] | |
89 | title = flashvars['trackerClipTitle'][0] | |
90 | thumbnail = flashvars['startPicture'][0] if 'startPicture' in flashvars else None | |
91 | ||
92 | if 'trackerClipAirTime' in flashvars: | |
93 | upload_date = flashvars['trackerClipAirTime'][0] | |
94 | else: | |
95 | upload_date = self._html_search_meta('DC.Date', webpage, 'upload date') | |
96 | ||
97 | if upload_date: | |
98 | upload_date = unified_strdate(upload_date) | |
99 | ||
100 | if video_url.endswith('.f4m'): | |
101 | video_url += '?hdcore=3.2.0&plugin=aasp-3.2.0.77.18' | |
102 | ext = 'flv' | |
103 | else: | |
104 | ext = determine_ext(video_url) | |
105 | ||
106 | description = self._html_search_meta('Description', webpage, 'description') | |
107 | ||
108 | return { | |
109 | 'id': page_id, | |
110 | 'url': video_url, | |
111 | 'ext': ext, | |
112 | 'title': title, | |
113 | 'description': description, | |
114 | 'thumbnail': thumbnail, | |
115 | 'upload_date': upload_date, | |
cd7481a3 PH |
116 | } |
117 | ||
118 | ||
e4cbb5f3 PH |
119 | class WDRMobileIE(InfoExtractor): |
120 | _VALID_URL = r'''(?x) | |
121 | https?://mobile-ondemand\.wdr\.de/ | |
122 | .*?/fsk(?P<age_limit>[0-9]+) | |
123 | /[0-9]+/[0-9]+/ | |
124 | (?P<id>[0-9]+)_(?P<title>[0-9]+)''' | |
125 | IE_NAME = 'wdr:mobile' | |
126 | _TEST = { | |
127 | 'url': 'http://mobile-ondemand.wdr.de/CMS2010/mdb/ondemand/weltweit/fsk0/42/421735/421735_4283021.mp4', | |
128 | 'info_dict': { | |
129 | 'title': '4283021', | |
130 | 'id': '421735', | |
7807ee66 | 131 | 'ext': 'mp4', |
e4cbb5f3 PH |
132 | 'age_limit': 0, |
133 | }, | |
7807ee66 | 134 | 'skip': 'Problems with loading data.' |
e4cbb5f3 PH |
135 | } |
136 | ||
137 | def _real_extract(self, url): | |
138 | mobj = re.match(self._VALID_URL, url) | |
139 | return { | |
140 | 'id': mobj.group('id'), | |
141 | 'title': mobj.group('title'), | |
142 | 'age_limit': int(mobj.group('age_limit')), | |
143 | 'url': url, | |
7807ee66 | 144 | 'ext': determine_ext(url), |
e4cbb5f3 PH |
145 | 'user_agent': 'mobile', |
146 | } | |
147 | ||
148 | ||
cd7481a3 | 149 | class WDRMausIE(InfoExtractor): |
9a7b072e | 150 | _VALID_URL = 'http://(?:www\.)?wdrmaus\.de/(?:[^/]+/){,2}(?P<id>[^/?#]+)(?:/index\.php5|(?<!index)\.php5|/(?:$|[?#]))' |
cd7481a3 PH |
151 | IE_DESC = 'Sendung mit der Maus' |
152 | _TESTS = [{ | |
153 | 'url': 'http://www.wdrmaus.de/aktuelle-sendung/index.php5', | |
154 | 'info_dict': { | |
155 | 'id': 'aktuelle-sendung', | |
156 | 'ext': 'mp4', | |
157 | 'thumbnail': 're:^http://.+\.jpg', | |
158 | 'upload_date': 're:^[0-9]{8}$', | |
159 | 'title': 're:^[0-9.]{10} - Aktuelle Sendung$', | |
160 | } | |
161 | }, { | |
162 | 'url': 'http://www.wdrmaus.de/sachgeschichten/sachgeschichten/40_jahre_maus.php5', | |
163 | 'md5': '3b1227ca3ed28d73ec5737c65743b2a3', | |
164 | 'info_dict': { | |
165 | 'id': '40_jahre_maus', | |
166 | 'ext': 'mp4', | |
167 | 'thumbnail': 're:^http://.+\.jpg', | |
168 | 'upload_date': '20131007', | |
169 | 'title': '12.03.2011 - 40 Jahre Maus', | |
170 | } | |
171 | }] | |
172 | ||
173 | def _real_extract(self, url): | |
174 | mobj = re.match(self._VALID_URL, url) | |
175 | video_id = mobj.group('id') | |
176 | ||
177 | webpage = self._download_webpage(url, video_id) | |
178 | param_code = self._html_search_regex( | |
179 | r'<a href="\?startVideo=1&([^"]+)"', webpage, 'parameters') | |
180 | ||
181 | title_date = self._search_regex( | |
182 | r'<div class="sendedatum"><p>Sendedatum:\s*([0-9\.]+)</p>', | |
183 | webpage, 'air date') | |
184 | title_str = self._html_search_regex( | |
185 | r'<h1>(.*?)</h1>', webpage, 'title') | |
186 | title = '%s - %s' % (title_date, title_str) | |
187 | upload_date = unified_strdate( | |
188 | self._html_search_meta('dc.date', webpage)) | |
189 | ||
190 | fields = compat_parse_qs(param_code) | |
191 | video_url = fields['firstVideo'][0] | |
192 | thumbnail = compat_urlparse.urljoin(url, fields['startPicture'][0]) | |
193 | ||
194 | formats = [{ | |
195 | 'format_id': 'rtmp', | |
196 | 'url': video_url, | |
197 | }] | |
198 | ||
199 | jscode = self._download_webpage( | |
200 | 'http://www.wdrmaus.de/codebase/js/extended-medien.min.js', | |
201 | video_id, fatal=False, | |
202 | note='Downloading URL translation table', | |
203 | errnote='Could not download URL translation table') | |
204 | if jscode: | |
205 | for m in re.finditer( | |
206 | r"stream:\s*'dslSrc=(?P<stream>[^']+)',\s*download:\s*'(?P<dl>[^']+)'\s*\}", | |
207 | jscode): | |
208 | if video_url.startswith(m.group('stream')): | |
209 | http_url = video_url.replace( | |
210 | m.group('stream'), m.group('dl')) | |
211 | formats.append({ | |
212 | 'format_id': 'http', | |
213 | 'url': http_url, | |
214 | }) | |
215 | break | |
216 | ||
217 | self._sort_formats(formats) | |
218 | ||
219 | return { | |
220 | 'id': video_id, | |
221 | 'title': title, | |
222 | 'formats': formats, | |
223 | 'thumbnail': thumbnail, | |
224 | 'upload_date': upload_date, | |
225 | } | |
226 | ||
227 | # TODO test _1 |