5 from .common
import InfoExtractor
6 from ..compat
import compat_str
21 class NRKBaseIE(InfoExtractor
):
22 _GEO_COUNTRIES
= ['NO']
23 _CDN_REPL_REGEX
= r
'''(?x)://
25 nrkod\d{1,2}-httpcache0-47115-cacheod0\.dna\.ip-only\.net/47115-cacheod0|
26 nrk-od-no\.telenorcdn\.net|
27 minicdn-od\.nrk\.no/od/nrkhd-osl-rr\.netwerk\.no/no
30 def _extract_nrk_formats(self
, asset_url
, video_id
):
31 if re
.match(r
'https?://[^/]+\.akamaihd\.net/i/', asset_url
):
32 return self
._extract
_akamai
_formats
(asset_url
, video_id
)
33 asset_url
= re
.sub(r
'(?:bw_(?:low|high)=\d+|no_audio_only)&?', '', asset_url
)
34 formats
= self
._extract
_m
3u8_formats
(
35 asset_url
, video_id
, 'mp4', 'm3u8_native', fatal
=False)
36 if not formats
and re
.search(self
._CDN
_REPL
_REGEX
, asset_url
):
37 formats
= self
._extract
_m
3u8_formats
(
38 re
.sub(self
._CDN
_REPL
_REGEX
, '://nrk-od-%02d.akamaized.net/no/' % random
.randint(0, 99), asset_url
),
39 video_id
, 'mp4', 'm3u8_native', fatal
=False)
42 def _raise_error(self
, data
):
44 'ProgramRightsAreNotReady': 'Du kan dessverre ikke se eller høre programmet',
45 'ProgramRightsHasExpired': 'Programmet har gått ut',
46 'NoProgramRights': 'Ikke tilgjengelig',
47 'ProgramIsGeoBlocked': 'NRK har ikke rettigheter til å vise dette programmet utenfor Norge',
49 message_type
= data
.get('messageType', '')
50 # Can be ProgramIsGeoBlocked or ChannelIsGeoBlocked*
51 if 'IsGeoBlocked' in message_type
or try_get(data
, lambda x
: x
['usageRights']['isGeoBlocked']) is True:
52 self
.raise_geo_restricted(
53 msg
=MESSAGES
.get('ProgramIsGeoBlocked'),
54 countries
=self
._GEO
_COUNTRIES
)
55 message
= data
.get('endUserMessage') or MESSAGES
.get(message_type
, message_type
)
56 raise ExtractorError('%s said: %s' % (self
.IE_NAME
, message
), expected
=True)
58 def _call_api(self
, path
, video_id
, item
=None, note
=None, fatal
=True, query
=None):
59 return self
._download
_json
(
60 urljoin('https://psapi.nrk.no/', path
),
61 video_id
, note
or 'Downloading %s JSON' % item
,
62 fatal
=fatal
, query
=query
,
63 headers
={'Accept-Encoding': 'gzip, deflate, br'}
)
66 class NRKIE(NRKBaseIE
):
72 (?:www\.)?nrk\.no/video/(?:PS\*|[^_]+_)|
73 v8[-.]psapi\.nrk\.no/mediaelement/
81 'url': 'http://www.nrk.no/video/PS*150533',
82 'md5': 'f46be075326e23ad0e524edfcb06aeb6',
86 'title': 'Dompap og andre fugler i Piip-Show',
87 'description': 'md5:d9261ba34c43b61c812cb6b0269a5c8f',
92 'url': 'http://www.nrk.no/video/PS*154915',
97 'title': 'Slik høres internett ut når du er blind',
98 'description': 'md5:a621f5cc1bd75c8d5104cb048c6b8568',
102 'url': 'nrk:ecc1b952-96dc-4a98-81b9-5296dc7a98d9',
103 'only_matching': True,
105 'url': 'nrk:clip/7707d5a3-ebe7-434a-87d5-a3ebe7a34a70',
106 'only_matching': True,
108 'url': 'https://v8-psapi.nrk.no/mediaelement/ecc1b952-96dc-4a98-81b9-5296dc7a98d9',
109 'only_matching': True,
111 'url': 'https://www.nrk.no/video/dompap-og-andre-fugler-i-piip-show_150533',
112 'only_matching': True,
114 'url': 'https://www.nrk.no/video/humor/kommentatorboksen-reiser-til-sjos_d1fda11f-a4ad-437a-a374-0398bc84e999',
115 'only_matching': True,
118 'url': 'nrk:l_96f4f1b0-de54-4e6a-b4f1-b0de54fe6af8',
119 'only_matching': True,
121 'url': 'nrk:podcast/l_96f4f1b0-de54-4e6a-b4f1-b0de54fe6af8',
122 'only_matching': True,
126 'only_matching': True,
128 'url': 'nrk:clip/150533',
129 'only_matching': True,
132 'url': 'nrk:MDDP12000117',
133 'only_matching': True,
135 'url': 'nrk:program/ENRK10100318',
136 'only_matching': True,
140 'only_matching': True,
142 'url': 'nrk:channel/nrk1',
143 'only_matching': True,
146 def _real_extract(self
, url
):
147 video_id
= self
._match
_id
(url
).split('/')[-1]
149 def call_playback_api(item
, query
=None):
151 return self
._call
_api
(f
'playback/{item}/program/{video_id}', video_id
, item
, query
=query
)
152 except ExtractorError
as e
:
153 if isinstance(e
.cause
, compat_HTTPError
) and e
.cause
.code
== 400:
154 return self
._call
_api
(f
'playback/{item}/{video_id}', video_id
, item
, query
=query
)
157 # known values for preferredCdn: akamai, iponly, minicdn and telenor
158 manifest
= call_playback_api('manifest', {'preferredCdn': 'akamai'}
)
160 video_id
= try_get(manifest
, lambda x
: x
['id'], compat_str
) or video_id
162 if manifest
.get('playability') == 'nonPlayable':
163 self
._raise
_error
(manifest
['nonPlayable'])
165 playable
= manifest
['playable']
168 for asset
in playable
['assets']:
169 if not isinstance(asset
, dict):
171 if asset
.get('encrypted'):
173 format_url
= url_or_none(asset
.get('url'))
176 asset_format
= (asset
.get('format') or '').lower()
177 if asset_format
== 'hls' or determine_ext(format_url
) == 'm3u8':
178 formats
.extend(self
._extract
_nrk
_formats
(format_url
, video_id
))
179 elif asset_format
== 'mp3':
182 'format_id': asset_format
,
185 self
._sort
_formats
(formats
)
187 data
= call_playback_api('metadata')
189 preplay
= data
['preplay']
190 titles
= preplay
['titles']
191 title
= titles
['title']
192 alt_title
= titles
.get('subtitle')
194 description
= try_get(preplay
, lambda x
: x
['description'].replace('\r', '\n'))
195 duration
= parse_duration(playable
.get('duration')) or parse_duration(data
.get('duration'))
198 for image
in try_get(
199 preplay
, lambda x
: x
['poster']['images'], list) or []:
200 if not isinstance(image
, dict):
202 image_url
= url_or_none(image
.get('url'))
207 'width': int_or_none(image
.get('pixelWidth')),
208 'height': int_or_none(image
.get('pixelHeight')),
212 for sub
in try_get(playable
, lambda x
: x
['subtitles'], list) or []:
213 if not isinstance(sub
, dict):
215 sub_url
= url_or_none(sub
.get('webVtt'))
218 sub_key
= str_or_none(sub
.get('language')) or 'nb'
219 sub_type
= str_or_none(sub
.get('type'))
221 sub_key
+= '-%s' % sub_type
222 subtitles
.setdefault(sub_key
, []).append({
227 data
, lambda x
: x
['legalAge']['body']['rating']['code'], compat_str
)
228 # https://en.wikipedia.org/wiki/Norwegian_Media_Authority
233 elif legal_age
.isdigit():
234 age_limit
= int_or_none(legal_age
)
236 is_series
= try_get(data
, lambda x
: x
['_links']['series']['name']) == 'series'
241 'alt_title': alt_title
,
242 'description': description
,
243 'duration': duration
,
244 'thumbnails': thumbnails
,
245 'age_limit': age_limit
,
247 'subtitles': subtitles
,
248 'timestamp': parse_iso8601(try_get(manifest
, lambda x
: x
['availability']['onDemand']['from'], str))
252 series
= season_id
= season_number
= episode
= episode_number
= None
253 programs
= self
._call
_api
(
254 'programs/%s' % video_id
, video_id
, 'programs', fatal
=False)
255 if programs
and isinstance(programs
, dict):
256 series
= str_or_none(programs
.get('seriesTitle'))
257 season_id
= str_or_none(programs
.get('seasonId'))
258 season_number
= int_or_none(programs
.get('seasonNumber'))
259 episode
= str_or_none(programs
.get('episodeTitle'))
260 episode_number
= int_or_none(programs
.get('episodeNumber'))
264 title
+= ' - %s' % alt_title
265 if not season_number
:
266 season_number
= int_or_none(self
._search
_regex
(
267 r
'Sesong\s+(\d+)', description
or '', 'season number',
270 episode
= alt_title
if is_series
else None
271 if not episode_number
:
272 episode_number
= int_or_none(self
._search
_regex
(
273 r
'^(\d+)\.', episode
or '', 'episode number',
275 if not episode_number
:
276 episode_number
= int_or_none(self
._search
_regex
(
277 r
'\((\d+)\s*:\s*\d+\)', description
or '',
278 'episode number', default
=None))
282 'season_id': season_id
,
283 'season_number': season_number
,
285 'episode_number': episode_number
,
291 class NRKTVIE(InfoExtractor
):
292 IE_DESC
= 'NRK TV and NRK Radio'
293 _EPISODE_RE
= r
'(?P<id>[a-zA-Z]{4}\d{8})'
294 _VALID_URL
= r
'https?://(?:tv|radio)\.nrk(?:super)?\.no/(?:[^/]+/)*%s' % _EPISODE_RE
296 'url': 'https://tv.nrk.no/program/MDDP12000117',
297 'md5': 'c4a5960f1b00b40d47db65c1064e0ab1',
299 'id': 'MDDP12000117',
301 'title': 'Alarm Trolltunga',
302 'description': 'md5:46923a6e6510eefcce23d5ef2a58f2ce',
315 'url': 'https://tv.nrk.no/serie/20-spoersmaal-tv/MUHH48000314/23-05-2014',
316 'md5': '8d40dab61cea8ab0114e090b029a0565',
318 'id': 'MUHH48000314',
320 'title': '20 spørsmål - 23. mai 2014',
321 'alt_title': '23. mai 2014',
322 'description': 'md5:bdea103bc35494c143c6a9acdd84887a',
324 'series': '20 spørsmål',
325 'episode': '23. mai 2014',
329 'url': 'https://tv.nrk.no/program/mdfp15000514',
331 'id': 'MDFP15000514',
333 'title': 'Kunnskapskanalen - Grunnlovsjubiléet - Stor ståhei for ingenting',
334 'description': 'md5:89290c5ccde1b3a24bb8050ab67fe1db',
336 'series': 'Kunnskapskanalen',
337 'episode': 'Grunnlovsjubiléet - Stor ståhei for ingenting',
341 'skip_download': True,
344 # single playlist video
345 'url': 'https://tv.nrk.no/serie/tour-de-ski/MSPO40010515/06-01-2015#del=2',
347 'id': 'MSPO40010515',
349 'title': 'Sprint fri teknikk, kvinner og menn 06.01.2015',
350 'description': 'md5:c03aba1e917561eface5214020551b7a',
354 'skip_download': True,
356 'expected_warnings': ['Failed to download m3u8 information'],
357 'skip': 'particular part is not supported currently',
359 'url': 'https://tv.nrk.no/serie/tour-de-ski/MSPO40010515/06-01-2015',
361 'id': 'MSPO40010515',
363 'title': 'Sprint fri teknikk, kvinner og menn 06.01.2015',
364 'description': 'md5:c03aba1e917561eface5214020551b7a',
367 'expected_warnings': ['Failed to download m3u8 information'],
368 'skip': 'Ikke tilgjengelig utenfor Norge',
370 'url': 'https://tv.nrk.no/serie/anno/KMTE50001317/sesong-3/episode-13',
372 'id': 'KMTE50001317',
374 'title': 'Anno - 13. episode',
375 'description': 'md5:11d9613661a8dbe6f9bef54e3a4cbbfa',
378 'episode': '13. episode',
380 'episode_number': 13,
384 'skip_download': True,
387 'url': 'https://tv.nrk.no/serie/nytt-paa-nytt/MUHH46000317/27-01-2017',
389 'id': 'MUHH46000317',
391 'title': 'Nytt på Nytt 27.01.2017',
392 'description': 'md5:5358d6388fba0ea6f0b6d11c48b9eb4b',
394 'series': 'Nytt på nytt',
395 'episode': '27.01.2017',
399 'skip_download': True,
401 'skip': 'ProgramRightsHasExpired',
403 'url': 'https://radio.nrk.no/serie/dagsnytt/NPUB21019315/12-07-2015#',
404 'only_matching': True,
406 'url': 'https://tv.nrk.no/serie/lindmo/2018/MUHU11006318/avspiller',
407 'only_matching': True,
409 'url': 'https://radio.nrk.no/serie/dagsnytt/sesong/201507/NPUB21019315',
410 'only_matching': True,
413 def _real_extract(self
, url
):
414 video_id
= self
._match
_id
(url
)
415 return self
.url_result(
416 'nrk:%s' % video_id
, ie
=NRKIE
.ie_key(), video_id
=video_id
)
419 class NRKTVEpisodeIE(InfoExtractor
):
420 _VALID_URL
= r
'https?://tv\.nrk\.no/serie/(?P<id>[^/]+/sesong/(?P<season_number>\d+)/episode/(?P<episode_number>\d+))'
422 'url': 'https://tv.nrk.no/serie/hellums-kro/sesong/1/episode/2',
424 'id': 'MUHH36005220',
426 'title': 'Hellums kro - 2. Kro, krig og kjærlighet',
427 'description': 'md5:ad92ddffc04cea8ce14b415deef81787',
429 'series': 'Hellums kro',
432 'episode': '2. Kro, krig og kjærlighet',
436 'skip_download': True,
439 'url': 'https://tv.nrk.no/serie/backstage/sesong/1/episode/8',
441 'id': 'MSUI14000816',
443 'title': 'Backstage - 8. episode',
444 'description': 'md5:de6ca5d5a2d56849e4021f2bf2850df4',
446 'series': 'Backstage',
449 'episode': '8. episode',
453 'skip_download': True,
455 'skip': 'ProgramRightsHasExpired',
458 def _real_extract(self
, url
):
459 display_id
, season_number
, episode_number
= self
._match
_valid
_url
(url
).groups()
461 webpage
= self
._download
_webpage
(url
, display_id
)
463 info
= self
._search
_json
_ld
(webpage
, display_id
, default
={})
464 nrk_id
= info
.get('@id') or self
._html
_search
_meta
(
465 'nrk:program-id', webpage
, default
=None) or self
._search
_regex
(
466 r
'data-program-id=["\'](%s)' % NRKTVIE._EPISODE_RE, webpage,
468 assert re.match(NRKTVIE._EPISODE_RE, nrk_id)
473 'url
': 'nrk
:%s' % nrk_id,
474 'ie_key
': NRKIE.ie_key(),
475 'season_number
': int(season_number),
476 'episode_number
': int(episode_number),
481 class NRKTVSerieBaseIE(NRKBaseIE):
482 def _extract_entries(self, entry_list):
483 if not isinstance(entry_list, list):
486 for episode in entry_list:
487 nrk_id = episode.get('prfId
') or episode.get('episodeId
')
488 if not nrk_id or not isinstance(nrk_id, compat_str):
490 entries.append(self.url_result(
491 'nrk
:%s' % nrk_id, ie=NRKIE.ie_key(), video_id=nrk_id))
494 _ASSETS_KEYS = ('episodes
', 'instalments
',)
496 def _extract_assets_key(self, embedded):
497 for asset_key in self._ASSETS_KEYS:
498 if embedded.get(asset_key):
502 def _catalog_name(serie_kind):
503 return 'podcast
' if serie_kind in ('podcast
', 'podkast
') else 'series
'
505 def _entries(self, data, display_id):
506 for page_num in itertools.count(1):
507 embedded = data.get('_embedded
') or data
508 if not isinstance(embedded, dict):
510 assets_key = self._extract_assets_key(embedded)
516 (lambda x: x[assets_key]['_embedded
'][assets_key],
517 lambda x: x[assets_key]),
519 for e in self._extract_entries(entries):
522 next_url_path = try_get(
524 (lambda x: x['_links
']['next
']['href
'],
525 lambda x: x['_embedded
'][assets_key]['_links
']['next
']['href
']),
527 if not next_url_path:
529 data = self._call_api(
530 next_url_path, display_id,
531 note='Downloading
%s JSON page
%d' % (assets_key, page_num),
537 class NRKTVSeasonIE(NRKTVSerieBaseIE):
538 _VALID_URL = r'''(?x)
540 (?P<domain>tv|radio)\.nrk\.no/
541 (?P<serie_kind>serie|pod[ck]ast)/
544 (?:sesong/)?(?P<id>\d+)|
545 sesong/(?P<id_2>[^/?#&]+)
549 'url
': 'https
://tv
.nrk
.no
/serie
/backstage
/sesong
/1',
554 'playlist_mincount
': 30,
556 # no /sesong/ in path
557 'url
': 'https
://tv
.nrk
.no
/serie
/lindmo
/2016',
562 'playlist_mincount
': 29,
564 # weird nested _embedded in catalog JSON response
565 'url
': 'https
://radio
.nrk
.no
/serie
/dickie
-dick
-dickens
/sesong
/1',
567 'id': 'dickie
-dick
-dickens
/1',
570 'playlist_mincount
': 11,
572 # 841 entries, multi page
573 'url
': 'https
://radio
.nrk
.no
/serie
/dagsnytt
/sesong
/201509',
575 'id': 'dagsnytt
/201509',
576 'title
': 'September
2015',
578 'playlist_mincount
': 841,
580 # 180 entries, single page
581 'url
': 'https
://tv
.nrk
.no
/serie
/spangas
/sesong
/1',
582 'only_matching
': True,
584 'url
': 'https
://radio
.nrk
.no
/podkast
/hele_historien
/sesong
/diagnose
-kverulant
',
586 'id': 'hele_historien
/diagnose
-kverulant
',
587 'title
': 'Diagnose kverulant
',
589 'playlist_mincount
': 3,
591 'url
': 'https
://radio
.nrk
.no
/podkast
/loerdagsraadet
/sesong
/202101',
592 'only_matching
': True,
596 def suitable(cls, url):
597 return (False if NRKTVIE.suitable(url) or NRKTVEpisodeIE.suitable(url) or NRKRadioPodkastIE.suitable(url)
598 else super(NRKTVSeasonIE, cls).suitable(url))
600 def _real_extract(self, url):
601 mobj = self._match_valid_url(url)
602 domain = mobj.group('domain
')
603 serie_kind = mobj.group('serie_kind
')
604 serie = mobj.group('serie
')
605 season_id = mobj.group('id') or mobj.group('id_2
')
606 display_id = '%s/%s' % (serie, season_id)
608 data = self._call_api(
609 '%s/catalog
/%s/%s/seasons
/%s'
610 % (domain, self._catalog_name(serie_kind), serie, season_id),
611 display_id, 'season
', query={'pageSize': 50})
613 title = try_get(data, lambda x: x['titles
']['title
'], compat_str) or display_id
614 return self.playlist_result(
615 self._entries(data, display_id),
619 class NRKTVSeriesIE(NRKTVSerieBaseIE):
620 _VALID_URL = r'https?
://(?P
<domain
>(?
:tv|radio
)\
.nrk|
(?
:tv\
.)?nrksuper
)\
.no
/(?P
<serie_kind
>serie|pod
[ck
]ast
)/(?P
<id>[^
/]+)'
622 # new layout, instalments
623 'url
': 'https
://tv
.nrk
.no
/serie
/groenn
-glede
',
625 'id': 'groenn
-glede
',
626 'title
': 'Grønn glede
',
627 'description
': 'md5
:7576e92ae7f65da6993cf90ee29e4608
',
629 'playlist_mincount
': 90,
631 # new layout, instalments, more entries
632 'url
': 'https
://tv
.nrk
.no
/serie
/lindmo
',
633 'only_matching
': True,
635 'url
': 'https
://tv
.nrk
.no
/serie
/blank
',
639 'description
': 'md5
:7664b4e7e77dc6810cd3bca367c25b6e
',
641 'playlist_mincount
': 30,
643 # new layout, seasons
644 'url
': 'https
://tv
.nrk
.no
/serie
/backstage
',
647 'title
': 'Backstage
',
648 'description
': 'md5
:63692ceb96813d9a207e9910483d948b
',
650 'playlist_mincount
': 60,
653 'url
': 'https
://tv
.nrksuper
.no
/serie
/labyrint
',
657 'description
': 'I Daidalos sin undersjøiske Labyrint venter spennende oppgaver
, skumle robotskapninger og slim
.',
659 'playlist_mincount
': 3,
661 'url
': 'https
://tv
.nrk
.no
/serie
/broedrene
-dal
-og
-spektralsteinene
',
662 'only_matching
': True,
664 'url
': 'https
://tv
.nrk
.no
/serie
/saving
-the
-human
-race
',
665 'only_matching
': True,
667 'url
': 'https
://tv
.nrk
.no
/serie
/postmann
-pat
',
668 'only_matching
': True,
670 'url
': 'https
://radio
.nrk
.no
/serie
/dickie
-dick
-dickens
',
672 'id': 'dickie
-dick
-dickens
',
673 'title
': 'Dickie Dick Dickens
',
674 'description
': 'md5
:19e67411ffe57f7dce08a943d7a0b91f
',
676 'playlist_mincount
': 8,
678 'url
': 'https
://nrksuper
.no
/serie
/labyrint
',
679 'only_matching
': True,
681 'url
': 'https
://radio
.nrk
.no
/podkast
/ulrikkes_univers
',
683 'id': 'ulrikkes_univers
',
685 'playlist_mincount
': 10,
687 'url
': 'https
://radio
.nrk
.no
/podkast
/ulrikkes_univers
/nrkno
-poddkast
-26588-134079-05042018030000',
688 'only_matching
': True,
692 def suitable(cls, url):
694 False if any(ie.suitable(url)
695 for ie in (NRKTVIE, NRKTVEpisodeIE, NRKRadioPodkastIE, NRKTVSeasonIE))
696 else super(NRKTVSeriesIE, cls).suitable(url))
698 def _real_extract(self, url):
699 site, serie_kind, series_id = self._match_valid_url(url).groups()
700 is_radio = site == 'radio
.nrk
'
701 domain = 'radio
' if is_radio else 'tv
'
703 size_prefix = 'p
' if is_radio else 'embeddedInstalmentsP
'
704 series = self._call_api(
706 % (domain, self._catalog_name(serie_kind), series_id),
707 series_id, 'serie
', query={size_prefix + 'ageSize': 50})
708 titles = try_get(series, [
709 lambda x: x['titles
'],
710 lambda x: x[x['type']]['titles
'],
711 lambda x: x[x['seriesType
']]['titles
'],
715 entries.extend(self._entries(series, series_id))
716 embedded = series.get('_embedded
') or {}
717 linked_seasons = try_get(series, lambda x: x['_links
']['seasons
']) or []
718 embedded_seasons = embedded.get('seasons
') or []
719 if len(linked_seasons) > len(embedded_seasons):
720 for season in linked_seasons:
721 season_url = urljoin(url, season.get('href
'))
723 season_name = season.get('name
')
724 if season_name and isinstance(season_name, compat_str):
725 season_url = 'https
://%s.nrk
.no
/serie
/%s/sesong
/%s' % (domain, series_id, season_name)
727 entries.append(self.url_result(
728 season_url, ie=NRKTVSeasonIE.ie_key(),
729 video_title=season.get('title
')))
731 for season in embedded_seasons:
732 entries.extend(self._entries(season, series_id))
733 entries.extend(self._entries(
734 embedded.get('extraMaterial
') or {}, series_id))
736 return self.playlist_result(
737 entries, series_id, titles.get('title
'), titles.get('subtitle
'))
740 class NRKTVDirekteIE(NRKTVIE):
741 IE_DESC = 'NRK TV Direkte
and NRK Radio Direkte
'
742 _VALID_URL = r'https?
://(?
:tv|radio
)\
.nrk\
.no
/direkte
/(?P
<id>[^
/?
#&]+)'
745 'url': 'https://tv.nrk.no/direkte/nrk1',
746 'only_matching': True,
748 'url': 'https://radio.nrk.no/direkte/p1_oslo_akershus',
749 'only_matching': True,
753 class NRKRadioPodkastIE(InfoExtractor
):
754 _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})'
757 'url': 'https://radio.nrk.no/podkast/ulrikkes_univers/l_96f4f1b0-de54-4e6a-b4f1-b0de54fe6af8',
758 'md5': '8d40dab61cea8ab0114e090b029a0565',
760 'id': 'MUHH48000314AA',
762 'title': '20 spørsmål 23.05.2014',
763 'description': 'md5:bdea103bc35494c143c6a9acdd84887a',
765 'series': '20 spørsmål',
766 'episode': '23.05.2014',
769 'url': 'https://radio.nrk.no/podcast/ulrikkes_univers/l_96f4f1b0-de54-4e6a-b4f1-b0de54fe6af8',
770 'only_matching': True,
772 'url': 'https://radio.nrk.no/podkast/ulrikkes_univers/sesong/1/l_96f4f1b0-de54-4e6a-b4f1-b0de54fe6af8',
773 'only_matching': True,
775 'url': 'https://radio.nrk.no/podkast/hele_historien/sesong/bortfoert-i-bergen/l_774d1a2c-7aa7-4965-8d1a-2c7aa7d9652c',
776 'only_matching': True,
779 def _real_extract(self
, url
):
780 video_id
= self
._match
_id
(url
)
781 return self
.url_result(
782 'nrk:%s' % video_id
, ie
=NRKIE
.ie_key(), video_id
=video_id
)
785 class NRKPlaylistBaseIE(InfoExtractor
):
786 def _extract_description(self
, webpage
):
789 def _real_extract(self
, url
):
790 playlist_id
= self
._match
_id
(url
)
792 webpage
= self
._download
_webpage
(url
, playlist_id
)
795 self
.url_result('nrk:%s' % video_id
, NRKIE
.ie_key())
796 for video_id
in re
.findall(self
._ITEM
_RE
, webpage
)
799 playlist_title
= self
._extract
_title
(webpage
)
800 playlist_description
= self
._extract
_description
(webpage
)
802 return self
.playlist_result(
803 entries
, playlist_id
, playlist_title
, playlist_description
)
806 class NRKPlaylistIE(NRKPlaylistBaseIE
):
807 _VALID_URL
= r
'https?://(?:www\.)?nrk\.no/(?!video|skole)(?:[^/]+/)+(?P<id>[^/]+)'
808 _ITEM_RE
= r
'class="[^"]*\brich\b[^"]*"[^>]+data-video-id="([^"]+)"'
810 'url': 'http://www.nrk.no/troms/gjenopplev-den-historiske-solformorkelsen-1.12270763',
812 'id': 'gjenopplev-den-historiske-solformorkelsen-1.12270763',
813 'title': 'Gjenopplev den historiske solformørkelsen',
814 'description': 'md5:c2df8ea3bac5654a26fc2834a542feed',
818 'url': 'http://www.nrk.no/kultur/bok/rivertonprisen-til-karin-fossum-1.12266449',
820 'id': 'rivertonprisen-til-karin-fossum-1.12266449',
821 'title': 'Rivertonprisen til Karin Fossum',
822 'description': 'Første kvinne på 15 år til å vinne krimlitteraturprisen.',
827 def _extract_title(self
, webpage
):
828 return self
._og
_search
_title
(webpage
, fatal
=False)
830 def _extract_description(self
, webpage
):
831 return self
._og
_search
_description
(webpage
)
834 class NRKTVEpisodesIE(NRKPlaylistBaseIE
):
835 _VALID_URL
= r
'https?://tv\.nrk\.no/program/[Ee]pisodes/[^/]+/(?P<id>\d+)'
836 _ITEM_RE
= r
'data-episode=["\']%s' % NRKTVIE._EPISODE_RE
838 'url
': 'https
://tv
.nrk
.no
/program
/episodes
/nytt
-paa
-nytt
/69031',
841 'title
': 'Nytt på nytt
, sesong
: 201210',
846 def _extract_title(self, webpage):
847 return self._html_search_regex(
848 r'<h1
>([^
<]+)</h1
>', webpage, 'title
', fatal=False)
851 class NRKSkoleIE(InfoExtractor):
852 IE_DESC = 'NRK Skole
'
853 _VALID_URL = r'https?
://(?
:www\
.)?nrk\
.no
/skole
/?
\?.*\bmediaId
=(?P
<id>\d
+)'
856 'url
': 'https
://www
.nrk
.no
/skole
/?page
=search
&q
=&mediaId
=14099',
857 'md5
': '18c12c3d071953c3bf8d54ef6b2587b7
',
861 'title
': 'Genetikk og eneggede tvillinger
',
862 'description
': 'md5
:3aca25dcf38ec30f0363428d2b265f8d
',
866 'url
': 'https
://www
.nrk
.no
/skole
/?page
=objectives
&subject
=naturfag
&objective
=K15114
&mediaId
=19355',
867 'only_matching
': True,
870 def _real_extract(self, url):
871 video_id = self._match_id(url)
873 nrk_id = self._download_json(
874 'https
://nrkno
-skole
-prod
.kube
.nrk
.no
/skole
/api
/media
/%s' % video_id,
877 return self.url_result('nrk
:%s' % nrk_id)