5 from .common
import InfoExtractor
6 from ..compat
import compat_HTTPError
, compat_str
20 class NRKBaseIE(InfoExtractor
):
21 _GEO_COUNTRIES
= ['NO']
22 _CDN_REPL_REGEX
= r
'''(?x)://
24 nrkod\d{1,2}-httpcache0-47115-cacheod0\.dna\.ip-only\.net/47115-cacheod0|
25 nrk-od-no\.telenorcdn\.net|
26 minicdn-od\.nrk\.no/od/nrkhd-osl-rr\.netwerk\.no/no
29 def _extract_nrk_formats(self
, asset_url
, video_id
):
30 if re
.match(r
'https?://[^/]+\.akamaihd\.net/i/', asset_url
):
31 return self
._extract
_akamai
_formats
(asset_url
, video_id
)
32 asset_url
= re
.sub(r
'(?:bw_(?:low|high)=\d+|no_audio_only)&?', '', asset_url
)
33 formats
= self
._extract
_m
3u8_formats
(
34 asset_url
, video_id
, 'mp4', 'm3u8_native', fatal
=False)
35 if not formats
and re
.search(self
._CDN
_REPL
_REGEX
, asset_url
):
36 formats
= self
._extract
_m
3u8_formats
(
37 re
.sub(self
._CDN
_REPL
_REGEX
, '://nrk-od-%02d.akamaized.net/no/' % random
.randint(0, 99), asset_url
),
38 video_id
, 'mp4', 'm3u8_native', fatal
=False)
41 def _raise_error(self
, data
):
43 'ProgramRightsAreNotReady': 'Du kan dessverre ikke se eller høre programmet',
44 'ProgramRightsHasExpired': 'Programmet har gått ut',
45 'NoProgramRights': 'Ikke tilgjengelig',
46 'ProgramIsGeoBlocked': 'NRK har ikke rettigheter til å vise dette programmet utenfor Norge',
48 message_type
= data
.get('messageType', '')
49 # Can be ProgramIsGeoBlocked or ChannelIsGeoBlocked*
50 if 'IsGeoBlocked' in message_type
or try_get(data
, lambda x
: x
['usageRights']['isGeoBlocked']) is True:
51 self
.raise_geo_restricted(
52 msg
=MESSAGES
.get('ProgramIsGeoBlocked'),
53 countries
=self
._GEO
_COUNTRIES
)
54 message
= data
.get('endUserMessage') or MESSAGES
.get(message_type
, message_type
)
55 raise ExtractorError('%s said: %s' % (self
.IE_NAME
, message
), expected
=True)
57 def _call_api(self
, path
, video_id
, item
=None, note
=None, fatal
=True, query
=None):
58 return self
._download
_json
(
59 urljoin('https://psapi.nrk.no/', path
),
60 video_id
, note
or 'Downloading %s JSON' % item
,
61 fatal
=fatal
, query
=query
,
62 headers
={'Accept-Encoding': 'gzip, deflate, br'}
)
65 class NRKIE(NRKBaseIE
):
71 (?:www\.)?nrk\.no/video/(?:PS\*|[^_]+_)|
72 v8[-.]psapi\.nrk\.no/mediaelement/
80 'url': 'http://www.nrk.no/video/PS*150533',
81 'md5': 'f46be075326e23ad0e524edfcb06aeb6',
85 'title': 'Dompap og andre fugler i Piip-Show',
86 'description': 'md5:d9261ba34c43b61c812cb6b0269a5c8f',
91 'url': 'http://www.nrk.no/video/PS*154915',
96 'title': 'Slik høres internett ut når du er blind',
97 'description': 'md5:a621f5cc1bd75c8d5104cb048c6b8568',
101 'url': 'nrk:ecc1b952-96dc-4a98-81b9-5296dc7a98d9',
102 'only_matching': True,
104 'url': 'nrk:clip/7707d5a3-ebe7-434a-87d5-a3ebe7a34a70',
105 'only_matching': True,
107 'url': 'https://v8-psapi.nrk.no/mediaelement/ecc1b952-96dc-4a98-81b9-5296dc7a98d9',
108 'only_matching': True,
110 'url': 'https://www.nrk.no/video/dompap-og-andre-fugler-i-piip-show_150533',
111 'only_matching': True,
113 'url': 'https://www.nrk.no/video/humor/kommentatorboksen-reiser-til-sjos_d1fda11f-a4ad-437a-a374-0398bc84e999',
114 'only_matching': True,
117 'url': 'nrk:l_96f4f1b0-de54-4e6a-b4f1-b0de54fe6af8',
118 'only_matching': True,
120 'url': 'nrk:podcast/l_96f4f1b0-de54-4e6a-b4f1-b0de54fe6af8',
121 'only_matching': True,
125 'only_matching': True,
127 'url': 'nrk:clip/150533',
128 'only_matching': True,
131 'url': 'nrk:MDDP12000117',
132 'only_matching': True,
134 'url': 'nrk:program/ENRK10100318',
135 'only_matching': True,
139 'only_matching': True,
141 'url': 'nrk:channel/nrk1',
142 'only_matching': True,
145 def _real_extract(self
, url
):
146 video_id
= self
._match
_id
(url
).split('/')[-1]
148 def call_playback_api(item
, query
=None):
150 return self
._call
_api
(f
'playback/{item}/program/{video_id}', video_id
, item
, query
=query
)
151 except ExtractorError
as e
:
152 if isinstance(e
.cause
, compat_HTTPError
) and e
.cause
.code
== 400:
153 return self
._call
_api
(f
'playback/{item}/{video_id}', video_id
, item
, query
=query
)
156 # known values for preferredCdn: akamai, iponly, minicdn and telenor
157 manifest
= call_playback_api('manifest', {'preferredCdn': 'akamai'}
)
159 video_id
= try_get(manifest
, lambda x
: x
['id'], compat_str
) or video_id
161 if manifest
.get('playability') == 'nonPlayable':
162 self
._raise
_error
(manifest
['nonPlayable'])
164 playable
= manifest
['playable']
167 for asset
in playable
['assets']:
168 if not isinstance(asset
, dict):
170 if asset
.get('encrypted'):
172 format_url
= url_or_none(asset
.get('url'))
175 asset_format
= (asset
.get('format') or '').lower()
176 if asset_format
== 'hls' or determine_ext(format_url
) == 'm3u8':
177 formats
.extend(self
._extract
_nrk
_formats
(format_url
, video_id
))
178 elif asset_format
== 'mp3':
181 'format_id': asset_format
,
184 self
._sort
_formats
(formats
)
186 data
= call_playback_api('metadata')
188 preplay
= data
['preplay']
189 titles
= preplay
['titles']
190 title
= titles
['title']
191 alt_title
= titles
.get('subtitle')
193 description
= try_get(preplay
, lambda x
: x
['description'].replace('\r', '\n'))
194 duration
= parse_duration(playable
.get('duration')) or parse_duration(data
.get('duration'))
197 for image
in try_get(
198 preplay
, lambda x
: x
['poster']['images'], list) or []:
199 if not isinstance(image
, dict):
201 image_url
= url_or_none(image
.get('url'))
206 'width': int_or_none(image
.get('pixelWidth')),
207 'height': int_or_none(image
.get('pixelHeight')),
211 for sub
in try_get(playable
, lambda x
: x
['subtitles'], list) or []:
212 if not isinstance(sub
, dict):
214 sub_url
= url_or_none(sub
.get('webVtt'))
217 sub_key
= str_or_none(sub
.get('language')) or 'nb'
218 sub_type
= str_or_none(sub
.get('type'))
220 sub_key
+= '-%s' % sub_type
221 subtitles
.setdefault(sub_key
, []).append({
226 data
, lambda x
: x
['legalAge']['body']['rating']['code'], compat_str
)
227 # https://en.wikipedia.org/wiki/Norwegian_Media_Authority
232 elif legal_age
.isdigit():
233 age_limit
= int_or_none(legal_age
)
235 is_series
= try_get(data
, lambda x
: x
['_links']['series']['name']) == 'series'
240 'alt_title': alt_title
,
241 'description': description
,
242 'duration': duration
,
243 'thumbnails': thumbnails
,
244 'age_limit': age_limit
,
246 'subtitles': subtitles
,
247 'timestamp': parse_iso8601(try_get(manifest
, lambda x
: x
['availability']['onDemand']['from'], str))
251 series
= season_id
= season_number
= episode
= episode_number
= None
252 programs
= self
._call
_api
(
253 'programs/%s' % video_id
, video_id
, 'programs', fatal
=False)
254 if programs
and isinstance(programs
, dict):
255 series
= str_or_none(programs
.get('seriesTitle'))
256 season_id
= str_or_none(programs
.get('seasonId'))
257 season_number
= int_or_none(programs
.get('seasonNumber'))
258 episode
= str_or_none(programs
.get('episodeTitle'))
259 episode_number
= int_or_none(programs
.get('episodeNumber'))
263 title
+= ' - %s' % alt_title
264 if not season_number
:
265 season_number
= int_or_none(self
._search
_regex
(
266 r
'Sesong\s+(\d+)', description
or '', 'season number',
269 episode
= alt_title
if is_series
else None
270 if not episode_number
:
271 episode_number
= int_or_none(self
._search
_regex
(
272 r
'^(\d+)\.', episode
or '', 'episode number',
274 if not episode_number
:
275 episode_number
= int_or_none(self
._search
_regex
(
276 r
'\((\d+)\s*:\s*\d+\)', description
or '',
277 'episode number', default
=None))
281 'season_id': season_id
,
282 'season_number': season_number
,
284 'episode_number': episode_number
,
290 class NRKTVIE(InfoExtractor
):
291 IE_DESC
= 'NRK TV and NRK Radio'
292 _EPISODE_RE
= r
'(?P<id>[a-zA-Z]{4}\d{8})'
293 _VALID_URL
= r
'https?://(?:tv|radio)\.nrk(?:super)?\.no/(?:[^/]+/)*%s' % _EPISODE_RE
295 'url': 'https://tv.nrk.no/program/MDDP12000117',
296 'md5': 'c4a5960f1b00b40d47db65c1064e0ab1',
298 'id': 'MDDP12000117',
300 'title': 'Alarm Trolltunga',
301 'description': 'md5:46923a6e6510eefcce23d5ef2a58f2ce',
314 'url': 'https://tv.nrk.no/serie/20-spoersmaal-tv/MUHH48000314/23-05-2014',
315 'md5': '8d40dab61cea8ab0114e090b029a0565',
317 'id': 'MUHH48000314',
319 'title': '20 spørsmål - 23. mai 2014',
320 'alt_title': '23. mai 2014',
321 'description': 'md5:bdea103bc35494c143c6a9acdd84887a',
323 'series': '20 spørsmål',
324 'episode': '23. mai 2014',
328 'url': 'https://tv.nrk.no/program/mdfp15000514',
330 'id': 'MDFP15000514',
332 'title': 'Kunnskapskanalen - Grunnlovsjubiléet - Stor ståhei for ingenting',
333 'description': 'md5:89290c5ccde1b3a24bb8050ab67fe1db',
335 'series': 'Kunnskapskanalen',
336 'episode': 'Grunnlovsjubiléet - Stor ståhei for ingenting',
340 'skip_download': True,
343 # single playlist video
344 'url': 'https://tv.nrk.no/serie/tour-de-ski/MSPO40010515/06-01-2015#del=2',
346 'id': 'MSPO40010515',
348 'title': 'Sprint fri teknikk, kvinner og menn 06.01.2015',
349 'description': 'md5:c03aba1e917561eface5214020551b7a',
353 'skip_download': True,
355 'expected_warnings': ['Failed to download m3u8 information'],
356 'skip': 'particular part is not supported currently',
358 'url': 'https://tv.nrk.no/serie/tour-de-ski/MSPO40010515/06-01-2015',
360 'id': 'MSPO40010515',
362 'title': 'Sprint fri teknikk, kvinner og menn 06.01.2015',
363 'description': 'md5:c03aba1e917561eface5214020551b7a',
366 'expected_warnings': ['Failed to download m3u8 information'],
367 'skip': 'Ikke tilgjengelig utenfor Norge',
369 'url': 'https://tv.nrk.no/serie/anno/KMTE50001317/sesong-3/episode-13',
371 'id': 'KMTE50001317',
373 'title': 'Anno - 13. episode',
374 'description': 'md5:11d9613661a8dbe6f9bef54e3a4cbbfa',
377 'episode': '13. episode',
379 'episode_number': 13,
383 'skip_download': True,
386 'url': 'https://tv.nrk.no/serie/nytt-paa-nytt/MUHH46000317/27-01-2017',
388 'id': 'MUHH46000317',
390 'title': 'Nytt på Nytt 27.01.2017',
391 'description': 'md5:5358d6388fba0ea6f0b6d11c48b9eb4b',
393 'series': 'Nytt på nytt',
394 'episode': '27.01.2017',
398 'skip_download': True,
400 'skip': 'ProgramRightsHasExpired',
402 'url': 'https://radio.nrk.no/serie/dagsnytt/NPUB21019315/12-07-2015#',
403 'only_matching': True,
405 'url': 'https://tv.nrk.no/serie/lindmo/2018/MUHU11006318/avspiller',
406 'only_matching': True,
408 'url': 'https://radio.nrk.no/serie/dagsnytt/sesong/201507/NPUB21019315',
409 'only_matching': True,
412 def _real_extract(self
, url
):
413 video_id
= self
._match
_id
(url
)
414 return self
.url_result(
415 'nrk:%s' % video_id
, ie
=NRKIE
.ie_key(), video_id
=video_id
)
418 class NRKTVEpisodeIE(InfoExtractor
):
419 _VALID_URL
= r
'https?://tv\.nrk\.no/serie/(?P<id>[^/]+/sesong/(?P<season_number>\d+)/episode/(?P<episode_number>\d+))'
421 'url': 'https://tv.nrk.no/serie/hellums-kro/sesong/1/episode/2',
423 'id': 'MUHH36005220',
425 'title': 'Hellums kro - 2. Kro, krig og kjærlighet',
426 'description': 'md5:ad92ddffc04cea8ce14b415deef81787',
428 'series': 'Hellums kro',
431 'episode': '2. Kro, krig og kjærlighet',
435 'skip_download': True,
438 'url': 'https://tv.nrk.no/serie/backstage/sesong/1/episode/8',
440 'id': 'MSUI14000816',
442 'title': 'Backstage - 8. episode',
443 'description': 'md5:de6ca5d5a2d56849e4021f2bf2850df4',
445 'series': 'Backstage',
448 'episode': '8. episode',
452 'skip_download': True,
454 'skip': 'ProgramRightsHasExpired',
457 def _real_extract(self
, url
):
458 display_id
, season_number
, episode_number
= self
._match
_valid
_url
(url
).groups()
460 webpage
= self
._download
_webpage
(url
, display_id
)
462 info
= self
._search
_json
_ld
(webpage
, display_id
, default
={})
463 nrk_id
= info
.get('@id') or self
._html
_search
_meta
(
464 'nrk:program-id', webpage
, default
=None) or self
._search
_regex
(
465 r
'data-program-id=["\'](%s)' % NRKTVIE._EPISODE_RE, webpage,
467 assert re.match(NRKTVIE._EPISODE_RE, nrk_id)
472 'url
': 'nrk
:%s' % nrk_id,
473 'ie_key
': NRKIE.ie_key(),
474 'season_number
': int(season_number),
475 'episode_number
': int(episode_number),
480 class NRKTVSerieBaseIE(NRKBaseIE):
481 def _extract_entries(self, entry_list):
482 if not isinstance(entry_list, list):
485 for episode in entry_list:
486 nrk_id = episode.get('prfId
') or episode.get('episodeId
')
487 if not nrk_id or not isinstance(nrk_id, compat_str):
489 entries.append(self.url_result(
490 'nrk
:%s' % nrk_id, ie=NRKIE.ie_key(), video_id=nrk_id))
493 _ASSETS_KEYS = ('episodes
', 'instalments
',)
495 def _extract_assets_key(self, embedded):
496 for asset_key in self._ASSETS_KEYS:
497 if embedded.get(asset_key):
501 def _catalog_name(serie_kind):
502 return 'podcast
' if serie_kind in ('podcast
', 'podkast
') else 'series
'
504 def _entries(self, data, display_id):
505 for page_num in itertools.count(1):
506 embedded = data.get('_embedded
') or data
507 if not isinstance(embedded, dict):
509 assets_key = self._extract_assets_key(embedded)
515 (lambda x: x[assets_key]['_embedded
'][assets_key],
516 lambda x: x[assets_key]),
518 for e in self._extract_entries(entries):
521 next_url_path = try_get(
523 (lambda x: x['_links
']['next
']['href
'],
524 lambda x: x['_embedded
'][assets_key]['_links
']['next
']['href
']),
526 if not next_url_path:
528 data = self._call_api(
529 next_url_path, display_id,
530 note='Downloading
%s JSON page
%d' % (assets_key, page_num),
536 class NRKTVSeasonIE(NRKTVSerieBaseIE):
537 _VALID_URL = r'''(?x)
539 (?P<domain>tv|radio)\.nrk\.no/
540 (?P<serie_kind>serie|pod[ck]ast)/
543 (?:sesong/)?(?P<id>\d+)|
544 sesong/(?P<id_2>[^/?#&]+)
548 'url
': 'https
://tv
.nrk
.no
/serie
/backstage
/sesong
/1',
553 'playlist_mincount
': 30,
555 # no /sesong/ in path
556 'url
': 'https
://tv
.nrk
.no
/serie
/lindmo
/2016',
561 'playlist_mincount
': 29,
563 # weird nested _embedded in catalog JSON response
564 'url
': 'https
://radio
.nrk
.no
/serie
/dickie
-dick
-dickens
/sesong
/1',
566 'id': 'dickie
-dick
-dickens
/1',
569 'playlist_mincount
': 11,
571 # 841 entries, multi page
572 'url
': 'https
://radio
.nrk
.no
/serie
/dagsnytt
/sesong
/201509',
574 'id': 'dagsnytt
/201509',
575 'title
': 'September
2015',
577 'playlist_mincount
': 841,
579 # 180 entries, single page
580 'url
': 'https
://tv
.nrk
.no
/serie
/spangas
/sesong
/1',
581 'only_matching
': True,
583 'url
': 'https
://radio
.nrk
.no
/podkast
/hele_historien
/sesong
/diagnose
-kverulant
',
585 'id': 'hele_historien
/diagnose
-kverulant
',
586 'title
': 'Diagnose kverulant
',
588 'playlist_mincount
': 3,
590 'url
': 'https
://radio
.nrk
.no
/podkast
/loerdagsraadet
/sesong
/202101',
591 'only_matching
': True,
595 def suitable(cls, url):
596 return (False if NRKTVIE.suitable(url) or NRKTVEpisodeIE.suitable(url) or NRKRadioPodkastIE.suitable(url)
597 else super(NRKTVSeasonIE, cls).suitable(url))
599 def _real_extract(self, url):
600 mobj = self._match_valid_url(url)
601 domain = mobj.group('domain
')
602 serie_kind = mobj.group('serie_kind
')
603 serie = mobj.group('serie
')
604 season_id = mobj.group('id') or mobj.group('id_2
')
605 display_id = '%s/%s' % (serie, season_id)
607 data = self._call_api(
608 '%s/catalog
/%s/%s/seasons
/%s'
609 % (domain, self._catalog_name(serie_kind), serie, season_id),
610 display_id, 'season
', query={'pageSize': 50})
612 title = try_get(data, lambda x: x['titles
']['title
'], compat_str) or display_id
613 return self.playlist_result(
614 self._entries(data, display_id),
618 class NRKTVSeriesIE(NRKTVSerieBaseIE):
619 _VALID_URL = r'https?
://(?P
<domain
>(?
:tv|radio
)\
.nrk|
(?
:tv\
.)?nrksuper
)\
.no
/(?P
<serie_kind
>serie|pod
[ck
]ast
)/(?P
<id>[^
/]+)'
621 # new layout, instalments
622 'url
': 'https
://tv
.nrk
.no
/serie
/groenn
-glede
',
624 'id': 'groenn
-glede
',
625 'title
': 'Grønn glede
',
626 'description
': 'md5
:7576e92ae7f65da6993cf90ee29e4608
',
628 'playlist_mincount
': 90,
630 # new layout, instalments, more entries
631 'url
': 'https
://tv
.nrk
.no
/serie
/lindmo
',
632 'only_matching
': True,
634 'url
': 'https
://tv
.nrk
.no
/serie
/blank
',
638 'description
': 'md5
:7664b4e7e77dc6810cd3bca367c25b6e
',
640 'playlist_mincount
': 30,
642 # new layout, seasons
643 'url
': 'https
://tv
.nrk
.no
/serie
/backstage
',
646 'title
': 'Backstage
',
647 'description
': 'md5
:63692ceb96813d9a207e9910483d948b
',
649 'playlist_mincount
': 60,
652 'url
': 'https
://tv
.nrksuper
.no
/serie
/labyrint
',
656 'description
': 'I Daidalos sin undersjøiske Labyrint venter spennende oppgaver
, skumle robotskapninger og slim
.',
658 'playlist_mincount
': 3,
660 'url
': 'https
://tv
.nrk
.no
/serie
/broedrene
-dal
-og
-spektralsteinene
',
661 'only_matching
': True,
663 'url
': 'https
://tv
.nrk
.no
/serie
/saving
-the
-human
-race
',
664 'only_matching
': True,
666 'url
': 'https
://tv
.nrk
.no
/serie
/postmann
-pat
',
667 'only_matching
': True,
669 'url
': 'https
://radio
.nrk
.no
/serie
/dickie
-dick
-dickens
',
671 'id': 'dickie
-dick
-dickens
',
672 'title
': 'Dickie Dick Dickens
',
673 'description
': 'md5
:19e67411ffe57f7dce08a943d7a0b91f
',
675 'playlist_mincount
': 8,
677 'url
': 'https
://nrksuper
.no
/serie
/labyrint
',
678 'only_matching
': True,
680 'url
': 'https
://radio
.nrk
.no
/podkast
/ulrikkes_univers
',
682 'id': 'ulrikkes_univers
',
684 'playlist_mincount
': 10,
686 'url
': 'https
://radio
.nrk
.no
/podkast
/ulrikkes_univers
/nrkno
-poddkast
-26588-134079-05042018030000',
687 'only_matching
': True,
691 def suitable(cls, url):
693 False if any(ie.suitable(url)
694 for ie in (NRKTVIE, NRKTVEpisodeIE, NRKRadioPodkastIE, NRKTVSeasonIE))
695 else super(NRKTVSeriesIE, cls).suitable(url))
697 def _real_extract(self, url):
698 site, serie_kind, series_id = self._match_valid_url(url).groups()
699 is_radio = site == 'radio
.nrk
'
700 domain = 'radio
' if is_radio else 'tv
'
702 size_prefix = 'p
' if is_radio else 'embeddedInstalmentsP
'
703 series = self._call_api(
705 % (domain, self._catalog_name(serie_kind), series_id),
706 series_id, 'serie
', query={size_prefix + 'ageSize': 50})
707 titles = try_get(series, [
708 lambda x: x['titles
'],
709 lambda x: x[x['type']]['titles
'],
710 lambda x: x[x['seriesType
']]['titles
'],
714 entries.extend(self._entries(series, series_id))
715 embedded = series.get('_embedded
') or {}
716 linked_seasons = try_get(series, lambda x: x['_links
']['seasons
']) or []
717 embedded_seasons = embedded.get('seasons
') or []
718 if len(linked_seasons) > len(embedded_seasons):
719 for season in linked_seasons:
720 season_url = urljoin(url, season.get('href
'))
722 season_name = season.get('name
')
723 if season_name and isinstance(season_name, compat_str):
724 season_url = 'https
://%s.nrk
.no
/serie
/%s/sesong
/%s' % (domain, series_id, season_name)
726 entries.append(self.url_result(
727 season_url, ie=NRKTVSeasonIE.ie_key(),
728 video_title=season.get('title
')))
730 for season in embedded_seasons:
731 entries.extend(self._entries(season, series_id))
732 entries.extend(self._entries(
733 embedded.get('extraMaterial
') or {}, series_id))
735 return self.playlist_result(
736 entries, series_id, titles.get('title
'), titles.get('subtitle
'))
739 class NRKTVDirekteIE(NRKTVIE):
740 IE_DESC = 'NRK TV Direkte
and NRK Radio Direkte
'
741 _VALID_URL = r'https?
://(?
:tv|radio
)\
.nrk\
.no
/direkte
/(?P
<id>[^
/?
#&]+)'
744 'url': 'https://tv.nrk.no/direkte/nrk1',
745 'only_matching': True,
747 'url': 'https://radio.nrk.no/direkte/p1_oslo_akershus',
748 'only_matching': True,
752 class NRKRadioPodkastIE(InfoExtractor
):
753 _VALID_URL
= r
'https?://radio\.nrk\.no/pod[ck]ast/(?:[^/]+/)+(?P<id>l_[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12})'
756 'url': 'https://radio.nrk.no/podkast/ulrikkes_univers/l_96f4f1b0-de54-4e6a-b4f1-b0de54fe6af8',
757 'md5': '8d40dab61cea8ab0114e090b029a0565',
759 'id': 'MUHH48000314AA',
761 'title': '20 spørsmål 23.05.2014',
762 'description': 'md5:bdea103bc35494c143c6a9acdd84887a',
764 'series': '20 spørsmål',
765 'episode': '23.05.2014',
768 'url': 'https://radio.nrk.no/podcast/ulrikkes_univers/l_96f4f1b0-de54-4e6a-b4f1-b0de54fe6af8',
769 'only_matching': True,
771 'url': 'https://radio.nrk.no/podkast/ulrikkes_univers/sesong/1/l_96f4f1b0-de54-4e6a-b4f1-b0de54fe6af8',
772 'only_matching': True,
774 'url': 'https://radio.nrk.no/podkast/hele_historien/sesong/bortfoert-i-bergen/l_774d1a2c-7aa7-4965-8d1a-2c7aa7d9652c',
775 'only_matching': True,
778 def _real_extract(self
, url
):
779 video_id
= self
._match
_id
(url
)
780 return self
.url_result(
781 'nrk:%s' % video_id
, ie
=NRKIE
.ie_key(), video_id
=video_id
)
784 class NRKPlaylistBaseIE(InfoExtractor
):
785 def _extract_description(self
, webpage
):
788 def _real_extract(self
, url
):
789 playlist_id
= self
._match
_id
(url
)
791 webpage
= self
._download
_webpage
(url
, playlist_id
)
794 self
.url_result('nrk:%s' % video_id
, NRKIE
.ie_key())
795 for video_id
in re
.findall(self
._ITEM
_RE
, webpage
)
798 playlist_title
= self
._extract
_title
(webpage
)
799 playlist_description
= self
._extract
_description
(webpage
)
801 return self
.playlist_result(
802 entries
, playlist_id
, playlist_title
, playlist_description
)
805 class NRKPlaylistIE(NRKPlaylistBaseIE
):
806 _VALID_URL
= r
'https?://(?:www\.)?nrk\.no/(?!video|skole)(?:[^/]+/)+(?P<id>[^/]+)'
807 _ITEM_RE
= r
'class="[^"]*\brich\b[^"]*"[^>]+data-video-id="([^"]+)"'
809 'url': 'http://www.nrk.no/troms/gjenopplev-den-historiske-solformorkelsen-1.12270763',
811 'id': 'gjenopplev-den-historiske-solformorkelsen-1.12270763',
812 'title': 'Gjenopplev den historiske solformørkelsen',
813 'description': 'md5:c2df8ea3bac5654a26fc2834a542feed',
817 'url': 'http://www.nrk.no/kultur/bok/rivertonprisen-til-karin-fossum-1.12266449',
819 'id': 'rivertonprisen-til-karin-fossum-1.12266449',
820 'title': 'Rivertonprisen til Karin Fossum',
821 'description': 'Første kvinne på 15 år til å vinne krimlitteraturprisen.',
826 def _extract_title(self
, webpage
):
827 return self
._og
_search
_title
(webpage
, fatal
=False)
829 def _extract_description(self
, webpage
):
830 return self
._og
_search
_description
(webpage
)
833 class NRKTVEpisodesIE(NRKPlaylistBaseIE
):
834 _VALID_URL
= r
'https?://tv\.nrk\.no/program/[Ee]pisodes/[^/]+/(?P<id>\d+)'
835 _ITEM_RE
= r
'data-episode=["\']%s' % NRKTVIE._EPISODE_RE
837 'url
': 'https
://tv
.nrk
.no
/program
/episodes
/nytt
-paa
-nytt
/69031',
840 'title
': 'Nytt på nytt
, sesong
: 201210',
845 def _extract_title(self, webpage):
846 return self._html_search_regex(
847 r'<h1
>([^
<]+)</h1
>', webpage, 'title
', fatal=False)
850 class NRKSkoleIE(InfoExtractor):
851 IE_DESC = 'NRK Skole
'
852 _VALID_URL = r'https?
://(?
:www\
.)?nrk\
.no
/skole
/?
\?.*\bmediaId
=(?P
<id>\d
+)'
855 'url
': 'https
://www
.nrk
.no
/skole
/?page
=search
&q
=&mediaId
=14099',
856 'md5
': '18c12c3d071953c3bf8d54ef6b2587b7
',
860 'title
': 'Genetikk og eneggede tvillinger
',
861 'description
': 'md5
:3aca25dcf38ec30f0363428d2b265f8d
',
865 'url
': 'https
://www
.nrk
.no
/skole
/?page
=objectives
&subject
=naturfag
&objective
=K15114
&mediaId
=19355',
866 'only_matching
': True,
869 def _real_extract(self, url):
870 video_id = self._match_id(url)
872 nrk_id = self._download_json(
873 'https
://nrkno
-skole
-prod
.kube
.nrk
.no
/skole
/api
/media
/%s' % video_id,
876 return self.url_result('nrk
:%s' % nrk_id)