2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
18 class WDRBaseIE(InfoExtractor
):
19 def _extract_wdr_video(self
, webpage
, display_id
):
20 # for wdr.de the data-extension is in a tag with the class "mediaLink"
21 # for wdr.de radio players, in a tag with the class "wdrrPlayerPlayBtn"
22 # for wdrmaus, in a tag with the class "videoButton" (previously a link
23 # to the page in a multiline "videoLink"-tag)
24 json_metadata
= self
._html
_search
_regex
(
27 (["\'])(?
:mediaLink|wdrrPlayerPlayBtn|videoButton
)\b.*?\
1[^
>]+|
28 (["\'])videoLink\b.*?\2[\s]*>\n[^\n]*
29 )data-extension=(["\'])(?P
<data
>(?
:(?
!\
3).)+)\
3
31 webpage, 'media link', default=None, group='data')
36 media_link_obj = self._parse_json(json_metadata, display_id,
37 transform_source=js_to_json)
38 jsonp_url = media_link_obj['mediaObj']['url']
40 metadata = self._download_json(
41 jsonp_url, display_id, transform_source=strip_jsonp)
43 metadata_tracker_data = metadata['trackerData']
44 metadata_media_resource = metadata['mediaResource']
48 # check if the metadata contains a direct URL to a file
49 for kind, media_resource in metadata_media_resource.items():
50 if kind not in ('dflt', 'alt'):
53 for tag_name, medium_url in media_resource.items():
54 if tag_name not in ('videoURL', 'audioURL'):
57 ext = determine_ext(medium_url)
59 formats.extend(self._extract_m3u8_formats(
60 medium_url, display_id, 'mp4', 'm3u8_native',
63 manifest_url = update_url_query(
64 medium_url, {'hdcore': '3.2.0', 'plugin': 'aasp-3.2.0.77.18'})
65 formats.extend(self._extract_f4m_formats(
66 manifest_url, display_id, f4m_id='hds', fatal=False))
68 formats.extend(self._extract_smil_formats(
69 medium_url, 'stream', fatal=False))
74 if ext == 'unknown_video':
75 urlh = self._request_webpage(
76 medium_url, display_id, note='Determining extension')
77 ext = urlhandle_detect_ext(urlh)
79 formats.append(a_format)
81 self._sort_formats(formats)
84 caption_url = metadata_media_resource.get('captionURL')
91 title = metadata_tracker_data['trackerClipTitle']
94 'id': metadata_tracker_data.get('trackerClipId', display_id),
95 'display_id': display_id,
97 'alt_title': metadata_tracker_data.get('trackerClipSubcategory'),
99 'subtitles': subtitles,
100 'upload_date': unified_strdate(metadata_tracker_data.get('trackerClipAirTime')),
104 class WDRIE(WDRBaseIE):
105 _CURRENT_MAUS_URL = r'https?://(?:www\.)wdrmaus.de/(?:[^/]+/){1,2}[^/?#]+\.php5'
106 _PAGE_REGEX = r'/(?:mediathek/)?[^/]+/(?P<type>[^/]+)/(?P<display_id>.+)\.html'
107 _VALID_URL = r'(?P<page_url>https?://(?:www\d\.)?wdr\d?\.de)' + _PAGE_REGEX + '|' + _CURRENT_MAUS_URL
111 'url': 'http://www1.wdr.de/mediathek/video/sendungen/doku-am-freitag/video-geheimnis-aachener-dom-100.html',
112 # HDS download, MD5 is unstable
116 'display_id': 'doku-am-freitag/video-geheimnis-aachener-dom-100',
117 'title': 'Geheimnis Aachener Dom',
118 'alt_title': 'Doku am Freitag',
119 'upload_date': '20160304',
120 'description': 'md5:87be8ff14d8dfd7a7ee46f0299b52318',
122 'subtitles': {'de': [{
123 'url': 'http://ondemand-ww.wdr.de/medp/fsk0/105/1058683/1058683_12220974.xml',
129 'url': 'http://www1.wdr.de/mediathek/audio/wdr3/wdr3-gespraech-am-samstag/audio-schriftstellerin-juli-zeh-100.html',
130 'md5': 'f4c1f96d01cf285240f53ea4309663d8',
134 'display_id': 'wdr3-gespraech-am-samstag/audio-schriftstellerin-juli-zeh-100',
135 'title': 'Schriftstellerin Juli Zeh',
136 'alt_title': 'WDR 3 Gespräch am Samstag',
137 'upload_date': '20160312',
138 'description': 'md5:e127d320bc2b1f149be697ce044a3dd7',
144 'url': 'http://www1.wdr.de/mediathek/video/live/index.html',
148 'display_id': 'index',
149 'title': r're:^WDR Fernsehen im Livestream [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$',
150 'alt_title': 'WDR Fernsehen Live',
152 'description': 'md5:ae2ff888510623bf8d4b115f95a9b7c9',
157 'skip_download': True, # m3u8 download
161 'url': 'http://www1.wdr.de/mediathek/video/sendungen/aktuelle-stunde/aktuelle-stunde-120.html',
162 'playlist_mincount': 8,
164 'id': 'aktuelle-stunde/aktuelle-stunde-120',
168 'url': 'http://www.wdrmaus.de/aktuelle-sendung/index.php5',
172 'upload_date': 're:^[0-9]{8}$',
173 'title': 're:^Die Sendung mit der Maus vom [0-9.]{10}$',
174 'description': 'Die Seite mit der Maus -',
176 'skip': 'The id changes from week to week because of the new episode'
179 'url': 'http://www.wdrmaus.de/filme/sachgeschichten/achterbahn.php5',
180 'md5': '803138901f6368ee497b4d195bb164f2',
184 'upload_date': '20130919',
185 'title': 'Sachgeschichte - Achterbahn ',
186 'description': 'Die Seite mit der Maus -',
190 'url': 'http://www1.wdr.de/radio/player/radioplayer116~_layout-popupVersion.html',
191 # Live stream, MD5 unstable
195 'title': 'COSMO Livestream',
196 'description': 'md5:2309992a6716c347891c045be50992e4',
197 'upload_date': '20160101',
202 def _real_extract(self, url):
203 mobj = re.match(self._VALID_URL, url)
204 url_type = mobj.group('type')
205 page_url = mobj.group('page_url')
206 display_id = mobj.group('display_id')
207 webpage = self._download_webpage(url, display_id)
209 info_dict = self._extract_wdr_video(webpage, display_id)
213 self.url_result(page_url + href[0], 'WDR')
214 for href in re.findall(
215 r'<a href="(%s)"[^>]+data-extension=' % self._PAGE_REGEX,
219 if entries: # Playlist page
220 return self.playlist_result(entries, playlist_id=display_id)
222 raise ExtractorError('No downloadable streams found', expected=True)
224 is_live = url_type == 'live'
228 'title': self._live_title(info_dict['title']),
231 elif 'upload_date' not in info_dict:
232 info_dict['upload_date'] = unified_strdate(self._html_search_meta('DC.Date', webpage, 'upload date'))
235 'description': self._html_search_meta('Description', webpage),
242 class WDRMobileIE(InfoExtractor):
243 _VALID_URL = r'''(?x
)
244 https?
://mobile
-ondemand\
.wdr\
.de
/
245 .*?
/fsk(?P
<age_limit
>[0-9]+)
247 (?P
<id>[0-9]+)_(?P
<title
>[0-9]+)'''
248 IE_NAME = 'wdr:mobile'
250 'url': 'http://mobile-ondemand.wdr.de/CMS2010/mdb/ondemand/weltweit/fsk0/42/421735/421735_4283021.mp4',
257 'skip': 'Problems with loading data.'
260 def _real_extract(self, url):
261 mobj = re.match(self._VALID_URL, url)
263 'id': mobj.group('id'),
264 'title': mobj.group('title'),
265 'age_limit': int(mobj.group('age_limit')),
268 'User-Agent': 'mobile',