]>
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, 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
(
25 r
'class=(?:"(?:mediaLink|wdrrPlayerPlayBtn|videoButton)\b[^"]*"[^>]+|"videoLink\b[^"]*"[\s]*>\n[^\n]*)data-extension="([^"]+)"',
26 webpage
, 'media link', default
=None, flags
=re
.MULTILINE
)
31 media_link_obj
= self
._parse
_json
(json_metadata
, display_id
,
32 transform_source
=js_to_json
)
33 jsonp_url
= media_link_obj
['mediaObj']['url']
35 metadata
= self
._download
_json
(
36 jsonp_url
, display_id
, transform_source
=strip_jsonp
)
38 metadata_tracker_data
= metadata
['trackerData']
39 metadata_media_resource
= metadata
['mediaResource']
43 # check if the metadata contains a direct URL to a file
44 for kind
, media_resource
in metadata_media_resource
.items():
45 if kind
not in ('dflt', 'alt'):
48 for tag_name
, medium_url
in media_resource
.items():
49 if tag_name
not in ('videoURL', 'audioURL'):
52 ext
= determine_ext(medium_url
)
54 formats
.extend(self
._extract
_m
3u8_formats
(
55 medium_url
, display_id
, 'mp4', 'm3u8_native',
58 manifest_url
= update_url_query(
59 medium_url
, {'hdcore': '3.2.0', 'plugin': 'aasp-3.2.0.77.18'})
60 formats
.extend(self
._extract
_f
4m
_formats
(
61 manifest_url
, display_id
, f4m_id
='hds', fatal
=False))
63 formats
.extend(self
._extract
_smil
_formats
(
64 medium_url
, 'stream', fatal
=False))
69 if ext
== 'unknown_video':
70 urlh
= self
._request
_webpage
(
71 medium_url
, display_id
, note
='Determining extension')
72 ext
= urlhandle_detect_ext(urlh
)
74 formats
.append(a_format
)
76 self
._sort
_formats
(formats
)
79 caption_url
= metadata_media_resource
.get('captionURL')
86 title
= metadata_tracker_data
['trackerClipTitle']
89 'id': metadata_tracker_data
.get('trackerClipId', display_id
),
90 'display_id': display_id
,
92 'alt_title': metadata_tracker_data
.get('trackerClipSubcategory'),
94 'subtitles': subtitles
,
95 'upload_date': unified_strdate(metadata_tracker_data
.get('trackerClipAirTime')),
99 class WDRIE(WDRBaseIE
):
100 _CURRENT_MAUS_URL
= r
'https?://(?:www\.)wdrmaus.de/(?:[^/]+/){1,2}[^/?#]+\.php5'
101 _PAGE_REGEX
= r
'/(?:mediathek/)?[^/]+/(?P<type>[^/]+)/(?P<display_id>.+)\.html'
102 _VALID_URL
= r
'(?P<page_url>https?://(?:www\d\.)?wdr\d?\.de)' + _PAGE_REGEX
+ '|' + _CURRENT_MAUS_URL
106 'url': 'http://www1.wdr.de/mediathek/video/sendungen/doku-am-freitag/video-geheimnis-aachener-dom-100.html',
107 # HDS download, MD5 is unstable
111 'display_id': 'doku-am-freitag/video-geheimnis-aachener-dom-100',
112 'title': 'Geheimnis Aachener Dom',
113 'alt_title': 'Doku am Freitag',
114 'upload_date': '20160304',
115 'description': 'md5:87be8ff14d8dfd7a7ee46f0299b52318',
117 'subtitles': {'de': [{
118 'url': 'http://ondemand-ww.wdr.de/medp/fsk0/105/1058683/1058683_12220974.xml',
124 'url': 'http://www1.wdr.de/mediathek/audio/wdr3/wdr3-gespraech-am-samstag/audio-schriftstellerin-juli-zeh-100.html',
125 'md5': 'f4c1f96d01cf285240f53ea4309663d8',
129 'display_id': 'wdr3-gespraech-am-samstag/audio-schriftstellerin-juli-zeh-100',
130 'title': 'Schriftstellerin Juli Zeh',
131 'alt_title': 'WDR 3 Gespräch am Samstag',
132 'upload_date': '20160312',
133 'description': 'md5:e127d320bc2b1f149be697ce044a3dd7',
139 'url': 'http://www1.wdr.de/mediathek/video/live/index.html',
143 'display_id': 'index',
144 'title': r
're:^WDR Fernsehen im Livestream [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$',
145 'alt_title': 'WDR Fernsehen Live',
147 'description': 'md5:ae2ff888510623bf8d4b115f95a9b7c9',
152 'skip_download': True, # m3u8 download
156 'url': 'http://www1.wdr.de/mediathek/video/sendungen/aktuelle-stunde/aktuelle-stunde-120.html',
157 'playlist_mincount': 8,
159 'id': 'aktuelle-stunde/aktuelle-stunde-120',
163 'url': 'http://www.wdrmaus.de/aktuelle-sendung/index.php5',
167 'upload_date': 're:^[0-9]{8}$',
168 'title': 're:^Die Sendung mit der Maus vom [0-9.]{10}$',
169 'description': 'Die Seite mit der Maus -',
171 'skip': 'The id changes from week to week because of the new episode'
174 'url': 'http://www.wdrmaus.de/filme/sachgeschichten/achterbahn.php5',
175 'md5': '803138901f6368ee497b4d195bb164f2',
179 'upload_date': '20130919',
180 'title': 'Sachgeschichte - Achterbahn ',
181 'description': 'Die Seite mit der Maus -',
185 'url': 'http://www1.wdr.de/radio/player/radioplayer116~_layout-popupVersion.html',
186 # Live stream, MD5 unstable
190 'title': 'COSMO Livestream',
191 'description': 'md5:2309992a6716c347891c045be50992e4',
192 'upload_date': '20160101',
197 def _real_extract(self
, url
):
198 mobj
= re
.match(self
._VALID
_URL
, url
)
199 url_type
= mobj
.group('type')
200 page_url
= mobj
.group('page_url')
201 display_id
= mobj
.group('display_id')
202 webpage
= self
._download
_webpage
(url
, display_id
)
204 info_dict
= self
._extract
_wdr
_video
(webpage
, display_id
)
208 self
.url_result(page_url
+ href
[0], 'WDR')
209 for href
in re
.findall(
210 r
'<a href="(%s)"[^>]+data-extension=' % self
._PAGE
_REGEX
,
214 if entries
: # Playlist page
215 return self
.playlist_result(entries
, playlist_id
=display_id
)
217 raise ExtractorError('No downloadable streams found', expected
=True)
219 is_live
= url_type
== 'live'
223 'title': self
._live
_title
(info_dict
['title']),
226 elif 'upload_date' not in info_dict
:
227 info_dict
['upload_date'] = unified_strdate(self
._html
_search
_meta
('DC.Date', webpage
, 'upload date'))
230 'description': self
._html
_search
_meta
('Description', webpage
),
237 class WDRMobileIE(InfoExtractor
):
238 _VALID_URL
= r
'''(?x)
239 https?://mobile-ondemand\.wdr\.de/
240 .*?/fsk(?P<age_limit>[0-9]+)
242 (?P<id>[0-9]+)_(?P<title>[0-9]+)'''
243 IE_NAME
= 'wdr:mobile'
245 'url': 'http://mobile-ondemand.wdr.de/CMS2010/mdb/ondemand/weltweit/fsk0/42/421735/421735_4283021.mp4',
252 'skip': 'Problems with loading data.'
255 def _real_extract(self
, url
):
256 mobj
= re
.match(self
._VALID
_URL
, url
)
258 'id': mobj
.group('id'),
259 'title': mobj
.group('title'),
260 'age_limit': int(mobj
.group('age_limit')),
263 'User-Agent': 'mobile',