]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/ndr.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
17 class NDRBaseIE(InfoExtractor
):
18 def _real_extract(self
, url
):
19 mobj
= re
.match(self
._VALID
_URL
, url
)
20 display_id
= next(group
for group
in mobj
.groups() if group
)
21 webpage
= self
._download
_webpage
(url
, display_id
)
22 return self
._extract
_embed
(webpage
, display_id
)
25 class NDRIE(NDRBaseIE
):
27 IE_DESC
= 'NDR.de - Norddeutscher Rundfunk'
28 _VALID_URL
= r
'https?://(?:www\.)?ndr\.de/(?:[^/]+/)*(?P<id>[^/?#]+),[\da-z]+\.html'
30 # httpVideo, same content id
31 'url': 'http://www.ndr.de/fernsehen/Party-Poette-und-Parade,hafengeburtstag988.html',
32 'md5': '6515bc255dc5c5f8c85bbc38e035a659',
34 'id': 'hafengeburtstag988',
35 'display_id': 'Party-Poette-und-Parade',
37 'title': 'Party, Pötte und Parade',
38 'description': 'md5:ad14f9d2f91d3040b6930c697e5f6b4c',
40 'timestamp': 1431108900,
41 'upload_date': '20150510',
45 'skip_download': True,
48 # httpVideo, different content id
49 'url': 'http://www.ndr.de/sport/fussball/40-Osnabrueck-spielt-sich-in-einen-Rausch,osna270.html',
50 'md5': '1043ff203eab307f0c51702ec49e9a71',
53 'display_id': '40-Osnabrueck-spielt-sich-in-einen-Rausch',
55 'title': 'Osnabrück - Wehen Wiesbaden: Die Highlights',
56 'description': 'md5:32e9b800b3d2d4008103752682d5dc01',
58 'timestamp': 1442059200,
59 'upload_date': '20150912',
63 'skip_download': True,
66 # httpAudio, same content id
67 'url': 'http://www.ndr.de/info/La-Valette-entgeht-der-Hinrichtung,audio51535.html',
68 'md5': 'bb3cd38e24fbcc866d13b50ca59307b8',
71 'display_id': 'La-Valette-entgeht-der-Hinrichtung',
73 'title': 'La Valette entgeht der Hinrichtung',
74 'description': 'md5:22f9541913a40fe50091d5cdd7c9f536',
75 'uploader': 'ndrinfo',
76 'timestamp': 1290626100,
77 'upload_date': '20140729',
81 'skip_download': True,
84 'url': 'https://www.ndr.de/Fettes-Brot-Ferris-MC-und-Thees-Uhlmann-live-on-stage,festivalsommer116.html',
85 'only_matching': True,
88 def _extract_embed(self
, webpage
, display_id
):
89 embed_url
= self
._html
_search
_meta
(
90 'embedURL', webpage
, 'embed URL', fatal
=True)
91 description
= self
._search
_regex
(
92 r
'<p[^>]+itemprop="description">([^<]+)</p>',
93 webpage
, 'description', default
=None) or self
._og
_search
_description
(webpage
)
94 timestamp
= parse_iso8601(
96 r
'<span[^>]+itemprop="(?:datePublished|uploadDate)"[^>]+content="([^"]+)"',
97 webpage
, 'upload date', fatal
=False))
99 '_type': 'url_transparent',
101 'display_id': display_id
,
102 'description': description
,
103 'timestamp': timestamp
,
107 class NJoyIE(NDRBaseIE
):
110 _VALID_URL
= r
'https?://(?:www\.)?n-joy\.de/(?:[^/]+/)*(?:(?P<display_id>[^/?#]+),)?(?P<id>[\da-z]+)\.html'
112 # httpVideo, same content id
113 'url': 'http://www.n-joy.de/entertainment/comedy/comedy_contest/Benaissa-beim-NDR-Comedy-Contest,comedycontest2480.html',
114 'md5': 'cb63be60cd6f9dd75218803146d8dc67',
116 'id': 'comedycontest2480',
117 'display_id': 'Benaissa-beim-NDR-Comedy-Contest',
119 'title': 'Benaissa beim NDR Comedy Contest',
120 'description': 'md5:f057a6c4e1c728b10d33b5ffd36ddc39',
122 'upload_date': '20141129',
126 'skip_download': True,
129 # httpVideo, different content id
130 'url': 'http://www.n-joy.de/musik/Das-frueheste-DJ-Set-des-Nordens-live-mit-Felix-Jaehn-,felixjaehn168.html',
131 'md5': '417660fffa90e6df2fda19f1b40a64d8',
133 'id': 'dockville882',
134 'display_id': 'Das-frueheste-DJ-Set-des-Nordens-live-mit-Felix-Jaehn-',
136 'title': '"Ich hab noch nie" mit Felix Jaehn',
137 'description': 'md5:85dd312d53be1b99e1f998a16452a2f3',
139 'upload_date': '20150822',
143 'skip_download': True,
146 'url': 'http://www.n-joy.de/radio/webradio/morningshow209.html',
147 'only_matching': True,
150 def _extract_embed(self
, webpage
, display_id
):
151 video_id
= self
._search
_regex
(
152 r
'<iframe[^>]+id="pp_([\da-z]+)"', webpage
, 'embed id')
153 description
= self
._search
_regex
(
154 r
'<div[^>]+class="subline"[^>]*>[^<]+</div>\s*<p>([^<]+)</p>',
155 webpage
, 'description', fatal
=False)
157 '_type': 'url_transparent',
158 'ie_key': 'NDREmbedBase',
159 'url': 'ndr:%s' % video_id
,
160 'display_id': display_id
,
161 'description': description
,
165 class NDREmbedBaseIE(InfoExtractor
):
166 IE_NAME
= 'ndr:embed:base'
167 _VALID_URL
= r
'(?:ndr:(?P<id_s>[\da-z]+)|https?://www\.ndr\.de/(?P<id>[\da-z]+)-ppjson\.json)'
169 'url': 'ndr:soundcheck3366',
170 'only_matching': True,
172 'url': 'http://www.ndr.de/soundcheck3366-ppjson.json',
173 'only_matching': True,
176 def _real_extract(self
, url
):
177 mobj
= re
.match(self
._VALID
_URL
, url
)
178 video_id
= mobj
.group('id') or mobj
.group('id_s')
180 ppjson
= self
._download
_json
(
181 'http://www.ndr.de/%s-ppjson.json' % video_id
, video_id
)
183 playlist
= ppjson
['playlist']
186 quality_key
= qualities(('xs', 's', 'm', 'l', 'xl'))
188 for format_id
, f
in playlist
.items():
192 ext
= determine_ext(src
, None)
194 formats
.extend(self
._extract
_f
4m
_formats
(
195 src
+ '?hdcore=3.7.0&plugin=aasp-3.7.0.39.44', video_id
,
196 f4m_id
='hds', fatal
=False))
198 formats
.extend(self
._extract
_m
3u8_formats
(
199 src
, video_id
, 'mp4', m3u8_id
='hls',
200 entry_protocol
='m3u8_native', fatal
=False))
202 quality
= f
.get('quality')
205 'format_id': quality
or format_id
,
206 'quality': quality_key(quality
),
208 type_
= f
.get('type')
209 if type_
and type_
.split('/')[0] == 'audio':
210 ff
['vcodec'] = 'none'
211 ff
['ext'] = ext
or 'mp3'
213 self
._sort
_formats
(formats
)
215 config
= playlist
['config']
217 live
= playlist
.get('config', {}).get('streamType') in ['httpVideoLive', 'httpAudioLive']
218 title
= config
['title']
220 title
= self
._live
_title
(title
)
221 uploader
= ppjson
.get('config', {}).get('branding')
222 upload_date
= ppjson
.get('config', {}).get('publicationDate')
223 duration
= int_or_none(config
.get('duration'))
226 poster
= try_get(config
, lambda x
: x
['poster'], dict) or {}
227 for thumbnail_id
, thumbnail
in poster
.items():
228 thumbnail_url
= urljoin(url
, thumbnail
.get('src'))
229 if not thumbnail_url
:
232 'id': thumbnail
.get('quality') or thumbnail_id
,
233 'url': thumbnail_url
,
234 'preference': quality_key(thumbnail
.get('quality')),
241 'uploader': uploader
if uploader
!= '-' else None,
242 'upload_date': upload_date
[0:8] if upload_date
else None,
243 'duration': duration
,
244 'thumbnails': thumbnails
,
249 class NDREmbedIE(NDREmbedBaseIE
):
250 IE_NAME
= 'ndr:embed'
251 _VALID_URL
= r
'https?://(?:www\.)?ndr\.de/(?:[^/]+/)*(?P<id>[\da-z]+)-(?:player|externalPlayer)\.html'
253 'url': 'http://www.ndr.de/fernsehen/sendungen/ndr_aktuell/ndraktuell28488-player.html',
254 'md5': '8b9306142fe65bbdefb5ce24edb6b0a9',
256 'id': 'ndraktuell28488',
258 'title': 'Norddeutschland begrüßt Flüchtlinge',
261 'upload_date': '20150907',
265 'url': 'http://www.ndr.de/ndr2/events/soundcheck/soundcheck3366-player.html',
266 'md5': '002085c44bae38802d94ae5802a36e78',
268 'id': 'soundcheck3366',
270 'title': 'Ella Henderson braucht Vergleiche nicht zu scheuen',
273 'upload_date': '20150912',
277 'skip_download': True,
280 'url': 'http://www.ndr.de/info/audio51535-player.html',
281 'md5': 'bb3cd38e24fbcc866d13b50ca59307b8',
285 'title': 'La Valette entgeht der Hinrichtung',
287 'uploader': 'ndrinfo',
288 'upload_date': '20140729',
292 'skip_download': True,
295 'url': 'http://www.ndr.de/fernsehen/sendungen/visite/visite11010-externalPlayer.html',
296 'md5': 'ae57f80511c1e1f2fd0d0d3d31aeae7c',
300 'title': 'Visite - die ganze Sendung',
303 'upload_date': '20150902',
307 'skip_download': True,
311 'url': 'http://www.ndr.de/fernsehen/livestream/livestream217-externalPlayer.html',
313 'id': 'livestream217',
315 'title': r
're:^NDR Fernsehen Niedersachsen \d{4}-\d{2}-\d{2} \d{2}:\d{2}$',
317 'upload_date': '20150910',
320 'skip_download': True,
323 'url': 'http://www.ndr.de/ndrkultur/audio255020-player.html',
324 'only_matching': True,
326 'url': 'http://www.ndr.de/fernsehen/sendungen/nordtour/nordtour7124-player.html',
327 'only_matching': True,
329 'url': 'http://www.ndr.de/kultur/film/videos/videoimport10424-player.html',
330 'only_matching': True,
332 'url': 'http://www.ndr.de/fernsehen/sendungen/hamburg_journal/hamj43006-player.html',
333 'only_matching': True,
335 'url': 'http://www.ndr.de/fernsehen/sendungen/weltbilder/weltbilder4518-player.html',
336 'only_matching': True,
338 'url': 'http://www.ndr.de/fernsehen/doku952-player.html',
339 'only_matching': True,
343 class NJoyEmbedIE(NDREmbedBaseIE
):
344 IE_NAME
= 'njoy:embed'
345 _VALID_URL
= r
'https?://(?:www\.)?n-joy\.de/(?:[^/]+/)*(?P<id>[\da-z]+)-(?:player|externalPlayer)_[^/]+\.html'
348 'url': 'http://www.n-joy.de/events/reeperbahnfestival/doku948-player_image-bc168e87-5263-4d6d-bd27-bb643005a6de_theme-n-joy.html',
349 'md5': '8483cbfe2320bd4d28a349d62d88bd74',
353 'title': 'Zehn Jahre Reeperbahn Festival - die Doku',
355 'upload_date': '20150807',
360 'url': 'http://www.n-joy.de/news_wissen/stefanrichter100-player_image-d5e938b1-f21a-4b9a-86b8-aaba8bca3a13_theme-n-joy.html',
361 'md5': 'd989f80f28ac954430f7b8a48197188a',
363 'id': 'stefanrichter100',
365 'title': 'Interview mit einem Augenzeugen',
368 'upload_date': '20150909',
372 'skip_download': True,
375 # httpAudioLive, no explicit ext
376 'url': 'http://www.n-joy.de/news_wissen/webradioweltweit100-player_image-3fec0484-2244-4565-8fb8-ed25fd28b173_theme-n-joy.html',
378 'id': 'webradioweltweit100',
380 'title': r
're:^N-JOY Weltweit \d{4}-\d{2}-\d{2} \d{2}:\d{2}$',
383 'upload_date': '20150810',
386 'skip_download': True,
389 'url': 'http://www.n-joy.de/musik/dockville882-player_image-3905259e-0803-4764-ac72-8b7de077d80a_theme-n-joy.html',
390 'only_matching': True,
392 'url': 'http://www.n-joy.de/radio/sendungen/morningshow/urlaubsfotos190-player_image-066a5df1-5c95-49ec-a323-941d848718db_theme-n-joy.html',
393 'only_matching': True,
395 'url': 'http://www.n-joy.de/entertainment/comedy/krudetv290-player_image-ab261bfe-51bf-4bf3-87ba-c5122ee35b3d_theme-n-joy.html',
396 'only_matching': True,