]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/wdr.py
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 its in a link to the page in a multiline "videoLink"-tag
23 json_metadata
= self
._html
_search
_regex
(
24 r
'class=(?:"(?:mediaLink|wdrrPlayerPlayBtn)\b[^"]*"[^>]+|"videoLink\b[^"]*"[\s]*>\n[^\n]*)data-extension="([^"]+)"',
25 webpage
, 'media link', default
=None, flags
=re
.MULTILINE
)
30 media_link_obj
= self
._parse
_json
(json_metadata
, display_id
,
31 transform_source
=js_to_json
)
32 jsonp_url
= media_link_obj
['mediaObj']['url']
34 metadata
= self
._download
_json
(
35 jsonp_url
, 'metadata', transform_source
=strip_jsonp
)
37 metadata_tracker_data
= metadata
['trackerData']
38 metadata_media_resource
= metadata
['mediaResource']
42 # check if the metadata contains a direct URL to a file
43 for kind
, media_resource
in metadata_media_resource
.items():
44 if kind
not in ('dflt', 'alt'):
47 for tag_name
, medium_url
in media_resource
.items():
48 if tag_name
not in ('videoURL', 'audioURL'):
51 ext
= determine_ext(medium_url
)
53 formats
.extend(self
._extract
_m
3u8_formats
(
54 medium_url
, display_id
, 'mp4', 'm3u8_native',
57 manifest_url
= update_url_query(
58 medium_url
, {'hdcore': '3.2.0', 'plugin': 'aasp-3.2.0.77.18'})
59 formats
.extend(self
._extract
_f
4m
_formats
(
60 manifest_url
, display_id
, f4m_id
='hds', fatal
=False))
62 formats
.extend(self
._extract
_smil
_formats
(
63 medium_url
, 'stream', fatal
=False))
68 if ext
== 'unknown_video':
69 urlh
= self
._request
_webpage
(
70 medium_url
, display_id
, note
='Determining extension')
71 ext
= urlhandle_detect_ext(urlh
)
73 formats
.append(a_format
)
75 self
._sort
_formats
(formats
)
78 caption_url
= metadata_media_resource
.get('captionURL')
85 title
= metadata_tracker_data
['trackerClipTitle']
88 'id': metadata_tracker_data
.get('trackerClipId', display_id
),
89 'display_id': display_id
,
91 'alt_title': metadata_tracker_data
.get('trackerClipSubcategory'),
93 'subtitles': subtitles
,
94 'upload_date': unified_strdate(metadata_tracker_data
.get('trackerClipAirTime')),
98 class WDRIE(WDRBaseIE
):
99 _CURRENT_MAUS_URL
= r
'https?://(?:www\.)wdrmaus.de/(?:[^/]+/){1,2}[^/?#]+\.php5'
100 _PAGE_REGEX
= r
'/(?:mediathek/)?[^/]+/(?P<type>[^/]+)/(?P<display_id>.+)\.html'
101 _VALID_URL
= r
'(?P<page_url>https?://(?:www\d\.)?wdr\d?\.de)' + _PAGE_REGEX
+ '|' + _CURRENT_MAUS_URL
105 'url': 'http://www1.wdr.de/mediathek/video/sendungen/doku-am-freitag/video-geheimnis-aachener-dom-100.html',
106 # HDS download, MD5 is unstable
110 'display_id': 'doku-am-freitag/video-geheimnis-aachener-dom-100',
111 'title': 'Geheimnis Aachener Dom',
112 'alt_title': 'Doku am Freitag',
113 'upload_date': '20160304',
114 'description': 'md5:87be8ff14d8dfd7a7ee46f0299b52318',
116 'subtitles': {'de': [{
117 'url': 'http://ondemand-ww.wdr.de/medp/fsk0/105/1058683/1058683_12220974.xml',
123 'url': 'http://www1.wdr.de/mediathek/audio/wdr3/wdr3-gespraech-am-samstag/audio-schriftstellerin-juli-zeh-100.html',
124 'md5': 'f4c1f96d01cf285240f53ea4309663d8',
128 'display_id': 'wdr3-gespraech-am-samstag/audio-schriftstellerin-juli-zeh-100',
129 'title': 'Schriftstellerin Juli Zeh',
130 'alt_title': 'WDR 3 Gespräch am Samstag',
131 'upload_date': '20160312',
132 'description': 'md5:e127d320bc2b1f149be697ce044a3dd7',
138 'url': 'http://www1.wdr.de/mediathek/video/live/index.html',
142 'display_id': 'index',
143 'title': r
're:^WDR Fernsehen im Livestream [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$',
144 'alt_title': 'WDR Fernsehen Live',
146 'description': 'md5:ae2ff888510623bf8d4b115f95a9b7c9',
151 'skip_download': True, # m3u8 download
155 'url': 'http://www1.wdr.de/mediathek/video/sendungen/aktuelle-stunde/aktuelle-stunde-120.html',
156 'playlist_mincount': 8,
158 'id': 'aktuelle-stunde/aktuelle-stunde-120',
162 'url': 'http://www.wdrmaus.de/aktuelle-sendung/index.php5',
166 'upload_date': 're:^[0-9]{8}$',
167 'title': 're:^Die Sendung mit der Maus vom [0-9.]{10}$',
168 'description': '- Die Sendung mit der Maus -',
170 'skip': 'The id changes from week to week because of the new episode'
173 'url': 'http://www.wdrmaus.de/sachgeschichten/sachgeschichten/achterbahn.php5',
174 'md5': '803138901f6368ee497b4d195bb164f2',
178 'upload_date': '20130919',
179 'title': 'Sachgeschichte - Achterbahn ',
180 'description': '- Die Sendung mit der Maus -',
184 'url': 'http://www1.wdr.de/radio/player/radioplayer116~_layout-popupVersion.html',
185 # Live stream, MD5 unstable
189 'title': 'Funkhaus Europa Livestream',
190 'description': 'md5:2309992a6716c347891c045be50992e4',
191 'upload_date': '20160101',
196 def _real_extract(self
, url
):
197 mobj
= re
.match(self
._VALID
_URL
, url
)
198 url_type
= mobj
.group('type')
199 page_url
= mobj
.group('page_url')
200 display_id
= mobj
.group('display_id')
201 webpage
= self
._download
_webpage
(url
, display_id
)
203 info_dict
= self
._extract
_wdr
_video
(webpage
, display_id
)
207 self
.url_result(page_url
+ href
[0], 'WDR')
208 for href
in re
.findall(
209 r
'<a href="(%s)"[^>]+data-extension=' % self
._PAGE
_REGEX
,
213 if entries
: # Playlist page
214 return self
.playlist_result(entries
, playlist_id
=display_id
)
216 raise ExtractorError('No downloadable streams found', expected
=True)
218 is_live
= url_type
== 'live'
222 'title': self
._live
_title
(info_dict
['title']),
225 elif 'upload_date' not in info_dict
:
226 info_dict
['upload_date'] = unified_strdate(self
._html
_search
_meta
('DC.Date', webpage
, 'upload date'))
229 'description': self
._html
_search
_meta
('Description', webpage
),
236 class WDRMobileIE(InfoExtractor
):
237 _VALID_URL
= r
'''(?x)
238 https?://mobile-ondemand\.wdr\.de/
239 .*?/fsk(?P<age_limit>[0-9]+)
241 (?P<id>[0-9]+)_(?P<title>[0-9]+)'''
242 IE_NAME
= 'wdr:mobile'
244 'url': 'http://mobile-ondemand.wdr.de/CMS2010/mdb/ondemand/weltweit/fsk0/42/421735/421735_4283021.mp4',
251 'skip': 'Problems with loading data.'
254 def _real_extract(self
, url
):
255 mobj
= re
.match(self
._VALID
_URL
, url
)
257 'id': mobj
.group('id'),
258 'title': mobj
.group('title'),
259 'age_limit': int(mobj
.group('age_limit')),
262 'User-Agent': 'mobile',