]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/ndr.py
2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
16 class NDRBaseIE(InfoExtractor
):
17 def _real_extract(self
, url
):
18 mobj
= self
._match
_valid
_url
(url
)
19 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
, id)
25 class NDRIE(NDRBaseIE
):
27 IE_DESC
= 'NDR.de - Norddeutscher Rundfunk'
28 _VALID_URL
= r
'https?://(?:www\.)?(?:daserste\.)?ndr\.de/(?:[^/]+/)*(?P<display_id>[^/?#]+),(?P<id>[\da-z]+)\.html'
30 'url': 'http://www.ndr.de/fernsehen/Party-Poette-und-Parade,hafengeburtstag988.html',
32 'id': 'hafengeburtstag988',
34 'title': 'Party, Pötte und Parade',
35 'thumbnail': 'https://www.ndr.de/fernsehen/hafengeburtstag990_v-contentxl.jpg',
36 'description': 'md5:ad14f9d2f91d3040b6930c697e5f6b4c',
38 'channel': 'NDR Fernsehen',
39 'upload_date': '20150508',
43 'url': 'https://www.ndr.de/sport/fussball/Rostocks-Matchwinner-Froede-Ein-Hansa-Debuet-wie-im-Maerchen,hansa10312.html',
46 'url': 'https://www.ndr.de/nachrichten/niedersachsen/kommunalwahl_niedersachsen_2021/Grosse-Parteien-zufrieden-mit-Ergebnissen-der-Kommunalwahl,kommunalwahl1296.html',
48 'id': 'kommunalwahl1296',
50 'title': 'Die Spitzenrunde: Die Wahl aus Sicht der Landespolitik',
51 'thumbnail': 'https://www.ndr.de/fernsehen/screenshot1194912_v-contentxl.jpg',
52 'description': 'md5:5c6e2ad744cef499135735a1036d7aa7',
53 'series': 'Hallo Niedersachsen',
54 'channel': 'NDR Fernsehen',
55 'upload_date': '20210913',
59 'url': 'https://www.ndr.de/fernsehen/sendungen/extra_3/extra-3-Satiremagazin-mit-Christian-Ehring,sendung1091858.html',
61 'id': 'sendung1091858',
63 'title': 'Extra 3 vom 11.11.2020 mit Christian Ehring',
64 'thumbnail': 'https://www.ndr.de/fernsehen/screenshot983938_v-contentxl.jpg',
65 'description': 'md5:700f6de264010585012a72f97b0ac0c9',
67 'channel': 'NDR Fernsehen',
68 'upload_date': '20201111',
72 'url': 'http://www.ndr.de/info/La-Valette-entgeht-der-Hinrichtung,audio51535.html',
76 'title': 'La Valette entgeht der Hinrichtung',
77 'thumbnail': 'https://www.ndr.de/mediathek/mediathekbild140_v-podcast.jpg',
78 'description': 'md5:22f9541913a40fe50091d5cdd7c9f536',
79 'upload_date': '20140729',
82 'expected_warnings': ['unable to extract json url'],
85 def _extract_embed(self
, webpage
, display_id
, id):
87 base_url
= 'https://www.ndr.de'
88 json_url
= self
._search
_regex
(r
'<iframe[^>]+src=\"([^\"]+)_theme-ndrde[^\.]*\.html\"', webpage
,
89 'json url', fatal
=False)
91 data_json
= self
._download
_json
(base_url
+ json_url
.replace('ardplayer_image', 'ardjson_image') + '.json',
93 info_json
= data_json
.get('_info', {})
94 media_json
= try_get(data_json
, lambda x
: x
['_mediaArray'][0]['_mediaStreamArray'])
95 for media
in media_json
:
96 if media
.get('_quality') == 'auto':
97 formats
.extend(self
._extract
_m
3u8_formats
(media
['_stream'], id))
99 sub_url
= data_json
.get('_subtitleUrl')
101 subtitles
.setdefault('de', []).append({
102 'url': base_url
+ sub_url
,
104 self
._sort
_formats
(formats
)
107 'title': info_json
.get('clipTitle'),
108 'thumbnail': base_url
+ data_json
.get('_previewImage'),
109 'description': info_json
.get('clipDescription'),
110 'series': info_json
.get('seriesTitle') or None,
111 'channel': info_json
.get('channelTitle'),
112 'upload_date': unified_strdate(info_json
.get('clipDate')),
113 'duration': data_json
.get('_duration'),
115 'subtitles': subtitles
,
118 json_url
= base_url
+ self
._search
_regex
(r
'apiUrl\s?=\s?\'([^
\']+)\'', webpage, 'json url
').replace(
119 '_belongsToPodcast
-', '')
120 data_json = self._download_json(json_url, id, fatal=False)
123 'title
': data_json.get('title
'),
124 'thumbnail
': base_url + data_json.get('poster
'),
125 'description
': data_json.get('summary
'),
126 'upload_date
': unified_strdate(data_json.get('publicationDate
')),
127 'duration
': parse_duration(data_json.get('duration
')),
129 'url
': try_get(data_json, (lambda x: x['audio
'][0]['url
'], lambda x: x['files
'][0]['url
'])),
136 class NJoyIE(NDRBaseIE):
139 _VALID_URL = r'https?
://(?
:www\
.)?n
-joy\
.de
/(?
:[^
/]+/)*(?
:(?P
<display_id
>[^
/?
#]+),)?(?P<id>[\da-z]+)\.html'
141 # httpVideo, same content id
142 'url': 'http://www.n-joy.de/entertainment/comedy/comedy_contest/Benaissa-beim-NDR-Comedy-Contest,comedycontest2480.html',
143 'md5': 'cb63be60cd6f9dd75218803146d8dc67',
145 'id': 'comedycontest2480',
146 'display_id': 'Benaissa-beim-NDR-Comedy-Contest',
148 'title': 'Benaissa beim NDR Comedy Contest',
149 'description': 'md5:f057a6c4e1c728b10d33b5ffd36ddc39',
151 'upload_date': '20141129',
155 'skip_download': True,
158 # httpVideo, different content id
159 'url': 'http://www.n-joy.de/musik/Das-frueheste-DJ-Set-des-Nordens-live-mit-Felix-Jaehn-,felixjaehn168.html',
160 'md5': '417660fffa90e6df2fda19f1b40a64d8',
162 'id': 'dockville882',
163 'display_id': 'Das-frueheste-DJ-Set-des-Nordens-live-mit-Felix-Jaehn-',
165 'title': '"Ich hab noch nie" mit Felix Jaehn',
166 'description': 'md5:85dd312d53be1b99e1f998a16452a2f3',
168 'upload_date': '20150822',
172 'skip_download': True,
175 'url': 'http://www.n-joy.de/radio/webradio/morningshow209.html',
176 'only_matching': True,
179 def _extract_embed(self
, webpage
, display_id
, id):
180 video_id
= self
._search
_regex
(
181 r
'<iframe[^>]+id="pp_([\da-z]+)"', webpage
, 'embed id')
182 description
= self
._search
_regex
(
183 r
'<div[^>]+class="subline"[^>]*>[^<]+</div>\s*<p>([^<]+)</p>',
184 webpage
, 'description', fatal
=False)
186 '_type': 'url_transparent',
187 'ie_key': 'NDREmbedBase',
188 'url': 'ndr:%s' % video_id
,
189 'display_id': display_id
,
190 'description': description
,
194 class NDREmbedBaseIE(InfoExtractor
):
195 IE_NAME
= 'ndr:embed:base'
196 _VALID_URL
= r
'(?:ndr:(?P<id_s>[\da-z]+)|https?://www\.ndr\.de/(?P<id>[\da-z]+)-ppjson\.json)'
198 'url': 'ndr:soundcheck3366',
199 'only_matching': True,
201 'url': 'http://www.ndr.de/soundcheck3366-ppjson.json',
202 'only_matching': True,
205 def _real_extract(self
, url
):
206 mobj
= self
._match
_valid
_url
(url
)
207 video_id
= mobj
.group('id') or mobj
.group('id_s')
209 ppjson
= self
._download
_json
(
210 'http://www.ndr.de/%s-ppjson.json' % video_id
, video_id
)
212 playlist
= ppjson
['playlist']
215 quality_key
= qualities(('xs', 's', 'm', 'l', 'xl'))
217 for format_id
, f
in playlist
.items():
221 ext
= determine_ext(src
, None)
223 formats
.extend(self
._extract
_f
4m
_formats
(
224 src
+ '?hdcore=3.7.0&plugin=aasp-3.7.0.39.44', video_id
,
225 f4m_id
='hds', fatal
=False))
227 formats
.extend(self
._extract
_m
3u8_formats
(
228 src
, video_id
, 'mp4', m3u8_id
='hls',
229 entry_protocol
='m3u8_native', fatal
=False))
231 quality
= f
.get('quality')
234 'format_id': quality
or format_id
,
235 'quality': quality_key(quality
),
237 type_
= f
.get('type')
238 if type_
and type_
.split('/')[0] == 'audio':
239 ff
['vcodec'] = 'none'
240 ff
['ext'] = ext
or 'mp3'
242 self
._sort
_formats
(formats
)
244 config
= playlist
['config']
246 live
= playlist
.get('config', {}).get('streamType') in ['httpVideoLive', 'httpAudioLive']
247 title
= config
['title']
248 uploader
= ppjson
.get('config', {}).get('branding')
249 upload_date
= ppjson
.get('config', {}).get('publicationDate')
250 duration
= int_or_none(config
.get('duration'))
253 poster
= try_get(config
, lambda x
: x
['poster'], dict) or {}
254 for thumbnail_id
, thumbnail
in poster
.items():
255 thumbnail_url
= urljoin(url
, thumbnail
.get('src'))
256 if not thumbnail_url
:
259 'id': thumbnail
.get('quality') or thumbnail_id
,
260 'url': thumbnail_url
,
261 'preference': quality_key(thumbnail
.get('quality')),
265 tracks
= config
.get('tracks')
266 if tracks
and isinstance(tracks
, list):
268 if not isinstance(track
, dict):
270 track_url
= urljoin(url
, track
.get('src'))
273 subtitles
.setdefault(track
.get('srclang') or 'de', []).append({
282 'uploader': uploader
if uploader
!= '-' else None,
283 'upload_date': upload_date
[0:8] if upload_date
else None,
284 'duration': duration
,
285 'thumbnails': thumbnails
,
287 'subtitles': subtitles
,
291 class NDREmbedIE(NDREmbedBaseIE
):
292 IE_NAME
= 'ndr:embed'
293 _VALID_URL
= r
'https?://(?:www\.)?(?:daserste\.)?ndr\.de/(?:[^/]+/)*(?P<id>[\da-z]+)-(?:player|externalPlayer)\.html'
295 'url': 'http://www.ndr.de/fernsehen/sendungen/ndr_aktuell/ndraktuell28488-player.html',
296 'md5': '8b9306142fe65bbdefb5ce24edb6b0a9',
298 'id': 'ndraktuell28488',
300 'title': 'Norddeutschland begrüßt Flüchtlinge',
303 'upload_date': '20150907',
307 'url': 'http://www.ndr.de/ndr2/events/soundcheck/soundcheck3366-player.html',
308 'md5': '002085c44bae38802d94ae5802a36e78',
310 'id': 'soundcheck3366',
312 'title': 'Ella Henderson braucht Vergleiche nicht zu scheuen',
315 'upload_date': '20150912',
319 'skip_download': True,
322 'url': 'http://www.ndr.de/info/audio51535-player.html',
323 'md5': 'bb3cd38e24fbcc866d13b50ca59307b8',
327 'title': 'La Valette entgeht der Hinrichtung',
329 'uploader': 'ndrinfo',
330 'upload_date': '20140729',
334 'skip_download': True,
337 'url': 'http://www.ndr.de/fernsehen/sendungen/visite/visite11010-externalPlayer.html',
338 'md5': 'ae57f80511c1e1f2fd0d0d3d31aeae7c',
342 'title': 'Visite - die ganze Sendung',
345 'upload_date': '20150902',
349 'skip_download': True,
353 'url': 'http://www.ndr.de/fernsehen/livestream/livestream217-externalPlayer.html',
355 'id': 'livestream217',
357 'title': r
're:^NDR Fernsehen Niedersachsen \d{4}-\d{2}-\d{2} \d{2}:\d{2}$',
359 'upload_date': '20150910',
362 'skip_download': True,
365 'url': 'http://www.ndr.de/ndrkultur/audio255020-player.html',
366 'only_matching': True,
368 'url': 'http://www.ndr.de/fernsehen/sendungen/nordtour/nordtour7124-player.html',
369 'only_matching': True,
371 'url': 'http://www.ndr.de/kultur/film/videos/videoimport10424-player.html',
372 'only_matching': True,
374 'url': 'http://www.ndr.de/fernsehen/sendungen/hamburg_journal/hamj43006-player.html',
375 'only_matching': True,
377 'url': 'http://www.ndr.de/fernsehen/sendungen/weltbilder/weltbilder4518-player.html',
378 'only_matching': True,
380 'url': 'http://www.ndr.de/fernsehen/doku952-player.html',
381 'only_matching': True,
385 class NJoyEmbedIE(NDREmbedBaseIE
):
386 IE_NAME
= 'njoy:embed'
387 _VALID_URL
= r
'https?://(?:www\.)?n-joy\.de/(?:[^/]+/)*(?P<id>[\da-z]+)-(?:player|externalPlayer)_[^/]+\.html'
390 'url': 'http://www.n-joy.de/events/reeperbahnfestival/doku948-player_image-bc168e87-5263-4d6d-bd27-bb643005a6de_theme-n-joy.html',
391 'md5': '8483cbfe2320bd4d28a349d62d88bd74',
395 'title': 'Zehn Jahre Reeperbahn Festival - die Doku',
397 'upload_date': '20150807',
402 'url': 'http://www.n-joy.de/news_wissen/stefanrichter100-player_image-d5e938b1-f21a-4b9a-86b8-aaba8bca3a13_theme-n-joy.html',
403 'md5': 'd989f80f28ac954430f7b8a48197188a',
405 'id': 'stefanrichter100',
407 'title': 'Interview mit einem Augenzeugen',
410 'upload_date': '20150909',
414 'skip_download': True,
417 # httpAudioLive, no explicit ext
418 'url': 'http://www.n-joy.de/news_wissen/webradioweltweit100-player_image-3fec0484-2244-4565-8fb8-ed25fd28b173_theme-n-joy.html',
420 'id': 'webradioweltweit100',
422 'title': r
're:^N-JOY Weltweit \d{4}-\d{2}-\d{2} \d{2}:\d{2}$',
425 'upload_date': '20150810',
428 'skip_download': True,
431 'url': 'http://www.n-joy.de/musik/dockville882-player_image-3905259e-0803-4764-ac72-8b7de077d80a_theme-n-joy.html',
432 'only_matching': True,
434 'url': 'http://www.n-joy.de/radio/sendungen/morningshow/urlaubsfotos190-player_image-066a5df1-5c95-49ec-a323-941d848718db_theme-n-joy.html',
435 'only_matching': True,
437 'url': 'http://www.n-joy.de/entertainment/comedy/krudetv290-player_image-ab261bfe-51bf-4bf3-87ba-c5122ee35b3d_theme-n-joy.html',
438 'only_matching': True,