2 from __future__ import unicode_literals
8 from .common import InfoExtractor
9 from ..compat import compat_str
22 class NRKBaseIE(InfoExtractor):
23 _GEO_COUNTRIES = ['NO']
24 _CDN_REPL_REGEX = r'''(?x)://
26 nrkod\d{1,2}-httpcache0-47115-cacheod0\.dna\.ip-only\.net/47115-cacheod0|
27 nrk-od-no\.telenorcdn\.net|
28 minicdn-od\.nrk\.no/od/nrkhd-osl-rr\.netwerk\.no/no
31 def _extract_nrk_formats(self, asset_url, video_id):
32 if re.match(r'https?://[^/]+\.akamaihd\.net/i/', asset_url):
33 return self._extract_akamai_formats(asset_url, video_id)
34 asset_url = re.sub(r'(?:bw_(?:low|high)=\d+|no_audio_only)&?', '', asset_url)
35 formats = self._extract_m3u8_formats(
36 asset_url, video_id, 'mp4', 'm3u8_native', fatal=False)
37 if not formats and re.search(self._CDN_REPL_REGEX, asset_url):
38 formats = self._extract_m3u8_formats(
39 re.sub(self._CDN_REPL_REGEX, '://nrk-od-%02d.akamaized.net/no/' % random.randint(0, 99), asset_url),
40 video_id, 'mp4', 'm3u8_native', fatal=False)
43 def _raise_error(self, data):
45 'ProgramRightsAreNotReady': 'Du kan dessverre ikke se eller høre programmet',
46 'ProgramRightsHasExpired': 'Programmet har gått ut',
47 'NoProgramRights': 'Ikke tilgjengelig',
48 'ProgramIsGeoBlocked': 'NRK har ikke rettigheter til å vise dette programmet utenfor Norge',
50 message_type = data.get('messageType', '')
51 # Can be ProgramIsGeoBlocked or ChannelIsGeoBlocked*
52 if 'IsGeoBlocked' in message_type or try_get(data, lambda x: x['usageRights']['isGeoBlocked']) is True:
53 self.raise_geo_restricted(
54 msg=MESSAGES.get('ProgramIsGeoBlocked'),
55 countries=self._GEO_COUNTRIES)
56 message = data.get('endUserMessage') or MESSAGES.get(message_type, message_type)
57 raise ExtractorError('%s said: %s' % (self.IE_NAME, message), expected=True)
59 def _call_api(self, path, video_id, item=None, note=None, fatal=True, query=None):
60 return self._download_json(
61 urljoin('http://psapi.nrk.no/', path),
62 video_id, note or 'Downloading %s JSON' % item,
63 fatal=fatal, query=query,
64 headers={'Accept-Encoding': 'gzip, deflate, br'})
67 class NRKIE(NRKBaseIE):
73 (?:www\.)?nrk\.no/video/(?:PS\*|[^_]+_)|
74 v8[-.]psapi\.nrk\.no/mediaelement/
82 'url': 'http://www.nrk.no/video/PS*150533',
83 'md5': 'f46be075326e23ad0e524edfcb06aeb6',
87 'title': 'Dompap og andre fugler i Piip-Show',
88 'description': 'md5:d9261ba34c43b61c812cb6b0269a5c8f',
93 'url': 'http://www.nrk.no/video/PS*154915',
98 'title': 'Slik høres internett ut når du er blind',
99 'description': 'md5:a621f5cc1bd75c8d5104cb048c6b8568',
103 'url': 'nrk:ecc1b952-96dc-4a98-81b9-5296dc7a98d9',
104 'only_matching': True,
106 'url': 'nrk:clip/7707d5a3-ebe7-434a-87d5-a3ebe7a34a70',
107 'only_matching': True,
109 'url': 'https://v8-psapi.nrk.no/mediaelement/ecc1b952-96dc-4a98-81b9-5296dc7a98d9',
110 'only_matching': True,
112 'url': 'https://www.nrk.no/video/dompap-og-andre-fugler-i-piip-show_150533',
113 'only_matching': True,
115 'url': 'https://www.nrk.no/video/humor/kommentatorboksen-reiser-til-sjos_d1fda11f-a4ad-437a-a374-0398bc84e999',
116 'only_matching': True,
119 'url': 'nrk:l_96f4f1b0-de54-4e6a-b4f1-b0de54fe6af8',
120 'only_matching': True,
122 'url': 'nrk:podcast/l_96f4f1b0-de54-4e6a-b4f1-b0de54fe6af8',
123 'only_matching': True,
127 'only_matching': True,
129 'url': 'nrk:clip/150533',
130 'only_matching': True,
133 'url': 'nrk:MDDP12000117',
134 'only_matching': True,
136 'url': 'nrk:program/ENRK10100318',
137 'only_matching': True,
141 'only_matching': True,
143 'url': 'nrk:channel/nrk1',
144 'only_matching': True,
147 def _real_extract(self, url):
148 video_id = self._match_id(url).split('/')[-1]
150 path_templ = 'playback/%s/' + video_id
152 def call_playback_api(item, query=None):
153 return self._call_api(path_templ % item, video_id, item, query=query)
154 # known values for preferredCdn: akamai, iponly, minicdn and telenor
155 manifest = call_playback_api('manifest', {'preferredCdn': 'akamai'})
157 video_id = try_get(manifest, lambda x: x['id'], compat_str) or video_id
159 if manifest.get('playability') == 'nonPlayable':
160 self._raise_error(manifest['nonPlayable'])
162 playable = manifest['playable']
165 for asset in playable['assets']:
166 if not isinstance(asset, dict):
168 if asset.get('encrypted'):
170 format_url = url_or_none(asset.get('url'))
173 asset_format = (asset.get('format') or '').lower()
174 if asset_format == 'hls' or determine_ext(format_url) == 'm3u8':
175 formats.extend(self._extract_nrk_formats(format_url, video_id))
176 elif asset_format == 'mp3':
179 'format_id': asset_format,
182 self._sort_formats(formats)
184 data = call_playback_api('metadata')
186 preplay = data['preplay']
187 titles = preplay['titles']
188 title = titles['title']
189 alt_title = titles.get('subtitle')
191 description = preplay.get('description')
192 duration = parse_duration(playable.get('duration')) or parse_duration(data.get('duration'))
195 for image in try_get(
196 preplay, lambda x: x['poster']['images'], list) or []:
197 if not isinstance(image, dict):
199 image_url = url_or_none(image.get('url'))
204 'width': int_or_none(image.get('pixelWidth')),
205 'height': int_or_none(image.get('pixelHeight')),
209 for sub in try_get(playable, lambda x: x['subtitles'], list) or []:
210 if not isinstance(sub, dict):
212 sub_url = url_or_none(sub.get('webVtt'))
215 sub_key = str_or_none(sub.get('language')) or 'nb'
216 sub_type = str_or_none(sub.get('type'))
218 sub_key += '-%s' % sub_type
219 subtitles.setdefault(sub_key, []).append({
223 age_limit = int_or_none(try_get(
224 data, lambda x: x['legalAge']['body']['rating']['code']))
226 is_series = try_get(data, lambda x: x['_links']['series']['name']) == 'series'
231 'alt_title': alt_title,
232 'description': description,
233 'duration': duration,
234 'thumbnails': thumbnails,
235 'age_limit': age_limit,
237 'subtitles': subtitles,
243 title += ' - %s' % alt_title
244 season_number = int_or_none(self._search_regex(
245 r'Sesong\s+(\d+)', description or '', 'season number',
247 episode = alt_title if is_series else None
248 episode_number = int_or_none(self._search_regex(
249 r'^(\d+)\.', episode or '', 'episode number',
251 if not episode_number:
252 episode_number = int_or_none(self._search_regex(
253 r'\((\d+)\s*:\s*\d+\)', description or '',
254 'episode number', default=None))
258 'season_number': season_number,
260 'episode_number': episode_number,
266 class NRKTVIE(InfoExtractor):
267 IE_DESC = 'NRK TV and NRK Radio'
268 _EPISODE_RE = r'(?P<id>[a-zA-Z]{4}\d{8})'
269 _VALID_URL = r'https?://(?:tv|radio)\.nrk(?:super)?\.no/(?:[^/]+/)*%s' % _EPISODE_RE
271 'url': 'https://tv.nrk.no/program/MDDP12000117',
272 'md5': 'c4a5960f1b00b40d47db65c1064e0ab1',
274 'id': 'MDDP12000117',
276 'title': 'Alarm Trolltunga',
277 'description': 'md5:46923a6e6510eefcce23d5ef2a58f2ce',
282 'url': 'https://tv.nrk.no/serie/20-spoersmaal-tv/MUHH48000314/23-05-2014',
283 'md5': '8d40dab61cea8ab0114e090b029a0565',
285 'id': 'MUHH48000314',
287 'title': '20 spørsmål - 23. mai 2014',
288 'alt_title': '23. mai 2014',
289 'description': 'md5:bdea103bc35494c143c6a9acdd84887a',
291 'series': '20 spørsmål',
292 'episode': '23. mai 2014',
295 'url': 'https://tv.nrk.no/program/mdfp15000514',
297 'id': 'MDFP15000514',
299 'title': 'Kunnskapskanalen - Grunnlovsjubiléet - Stor ståhei for ingenting',
300 'description': 'md5:89290c5ccde1b3a24bb8050ab67fe1db',
302 'series': 'Kunnskapskanalen',
303 'episode': 'Grunnlovsjubiléet - Stor ståhei for ingenting',
306 'skip_download': True,
309 # single playlist video
310 'url': 'https://tv.nrk.no/serie/tour-de-ski/MSPO40010515/06-01-2015#del=2',
312 'id': 'MSPO40010515',
314 'title': 'Sprint fri teknikk, kvinner og menn 06.01.2015',
315 'description': 'md5:c03aba1e917561eface5214020551b7a',
318 'skip_download': True,
320 'expected_warnings': ['Failed to download m3u8 information'],
321 'skip': 'particular part is not supported currently',
323 'url': 'https://tv.nrk.no/serie/tour-de-ski/MSPO40010515/06-01-2015',
325 'id': 'MSPO40010515',
327 'title': 'Sprint fri teknikk, kvinner og menn 06.01.2015',
328 'description': 'md5:c03aba1e917561eface5214020551b7a',
330 'expected_warnings': ['Failed to download m3u8 information'],
331 'skip': 'Ikke tilgjengelig utenfor Norge',
333 'url': 'https://tv.nrk.no/serie/anno/KMTE50001317/sesong-3/episode-13',
335 'id': 'KMTE50001317',
337 'title': 'Anno - 13. episode',
338 'description': 'md5:11d9613661a8dbe6f9bef54e3a4cbbfa',
341 'episode': '13. episode',
343 'episode_number': 13,
346 'skip_download': True,
349 'url': 'https://tv.nrk.no/serie/nytt-paa-nytt/MUHH46000317/27-01-2017',
351 'id': 'MUHH46000317',
353 'title': 'Nytt på Nytt 27.01.2017',
354 'description': 'md5:5358d6388fba0ea6f0b6d11c48b9eb4b',
356 'series': 'Nytt på nytt',
357 'episode': '27.01.2017',
360 'skip_download': True,
362 'skip': 'ProgramRightsHasExpired',
364 'url': 'https://radio.nrk.no/serie/dagsnytt/NPUB21019315/12-07-2015#',
365 'only_matching': True,
367 'url': 'https://tv.nrk.no/serie/lindmo/2018/MUHU11006318/avspiller',
368 'only_matching': True,
370 'url': 'https://radio.nrk.no/serie/dagsnytt/sesong/201507/NPUB21019315',
371 'only_matching': True,
374 def _real_extract(self, url):
375 video_id = self._match_id(url)
376 return self.url_result(
377 'nrk:%s' % video_id, ie=NRKIE.ie_key(), video_id=video_id)
380 class NRKTVEpisodeIE(InfoExtractor):
381 _VALID_URL = r'https?://tv\.nrk\.no/serie/(?P<id>[^/]+/sesong/(?P<season_number>\d+)/episode/(?P<episode_number>\d+))'
383 'url': 'https://tv.nrk.no/serie/hellums-kro/sesong/1/episode/2',
385 'id': 'MUHH36005220',
387 'title': 'Hellums kro - 2. Kro, krig og kjærlighet',
388 'description': 'md5:ad92ddffc04cea8ce14b415deef81787',
390 'series': 'Hellums kro',
391 # 'season_number': 1,
393 'episode': '2. Kro, krig og kjærlighet',
397 'skip_download': True,
400 'url': 'https://tv.nrk.no/serie/backstage/sesong/1/episode/8',
402 'id': 'MSUI14000816',
404 'title': 'Backstage - 8. episode',
405 'description': 'md5:de6ca5d5a2d56849e4021f2bf2850df4',
407 'series': 'Backstage',
410 'episode': '8. episode',
413 'skip_download': True,
415 'skip': 'ProgramRightsHasExpired',
418 def _real_extract(self, url):
419 display_id, season_number, episode_number = re.match(self._VALID_URL, url).groups()
421 webpage = self._download_webpage(url, display_id)
423 info = self._search_json_ld(webpage, display_id, default={})
424 nrk_id = info.get('@id') or self._html_search_meta(
425 'nrk:program-id', webpage, default=None) or self._search_regex(
426 r'data-program-id=["\'](%s)' % NRKTVIE._EPISODE_RE, webpage,
428 assert re.match(NRKTVIE._EPISODE_RE, nrk_id)
433 'url': 'nrk:%s' % nrk_id,
434 'ie_key': NRKIE.ie_key(),
435 'season_number': int(season_number),
436 'episode_number': int(episode_number),
441 class NRKTVSerieBaseIE(NRKBaseIE):
442 def _extract_entries(self, entry_list):
443 if not isinstance(entry_list, list):
446 for episode in entry_list:
447 nrk_id = episode.get('prfId') or episode.get('episodeId')
448 if not nrk_id or not isinstance(nrk_id, compat_str):
450 entries.append(self.url_result(
451 'nrk:%s' % nrk_id, ie=NRKIE.ie_key(), video_id=nrk_id))
454 _ASSETS_KEYS = ('episodes', 'instalments',)
456 def _extract_assets_key(self, embedded):
457 for asset_key in self._ASSETS_KEYS:
458 if embedded.get(asset_key):
462 def _catalog_name(serie_kind):
463 return 'podcast' if serie_kind in ('podcast', 'podkast') else 'series'
465 def _entries(self, data, display_id):
466 for page_num in itertools.count(1):
467 embedded = data.get('_embedded') or data
468 if not isinstance(embedded, dict):
470 assets_key = self._extract_assets_key(embedded)
476 (lambda x: x[assets_key]['_embedded'][assets_key],
477 lambda x: x[assets_key]),
479 for e in self._extract_entries(entries):
482 next_url_path = try_get(
484 (lambda x: x['_links']['next']['href'],
485 lambda x: x['_embedded'][assets_key]['_links']['next']['href']),
487 if not next_url_path:
489 data = self._call_api(
490 next_url_path, display_id,
491 note='Downloading %s JSON page %d' % (assets_key, page_num),
497 class NRKTVSeasonIE(NRKTVSerieBaseIE):
498 _VALID_URL = r'''(?x)
500 (?P<domain>tv|radio)\.nrk\.no/
501 (?P<serie_kind>serie|pod[ck]ast)/
504 (?:sesong/)?(?P<id>\d+)|
505 sesong/(?P<id_2>[^/?#&]+)
509 'url': 'https://tv.nrk.no/serie/backstage/sesong/1',
514 'playlist_mincount': 30,
516 # no /sesong/ in path
517 'url': 'https://tv.nrk.no/serie/lindmo/2016',
522 'playlist_mincount': 29,
524 # weird nested _embedded in catalog JSON response
525 'url': 'https://radio.nrk.no/serie/dickie-dick-dickens/sesong/1',
527 'id': 'dickie-dick-dickens/1',
530 'playlist_mincount': 11,
532 # 841 entries, multi page
533 'url': 'https://radio.nrk.no/serie/dagsnytt/sesong/201509',
535 'id': 'dagsnytt/201509',
536 'title': 'September 2015',
538 'playlist_mincount': 841,
540 # 180 entries, single page
541 'url': 'https://tv.nrk.no/serie/spangas/sesong/1',
542 'only_matching': True,
544 'url': 'https://radio.nrk.no/podkast/hele_historien/sesong/diagnose-kverulant',
546 'id': 'hele_historien/diagnose-kverulant',
547 'title': 'Diagnose kverulant',
549 'playlist_mincount': 3,
551 'url': 'https://radio.nrk.no/podkast/loerdagsraadet/sesong/202101',
552 'only_matching': True,
556 def suitable(cls, url):
557 return (False if NRKTVIE.suitable(url) or NRKTVEpisodeIE.suitable(url) or NRKRadioPodkastIE.suitable(url)
558 else super(NRKTVSeasonIE, cls).suitable(url))
560 def _real_extract(self, url):
561 mobj = re.match(self._VALID_URL, url)
562 domain = mobj.group('domain')
563 serie_kind = mobj.group('serie_kind')
564 serie = mobj.group('serie')
565 season_id = mobj.group('id') or mobj.group('id_2')
566 display_id = '%s/%s' % (serie, season_id)
568 data = self._call_api(
569 '%s/catalog/%s/%s/seasons/%s'
570 % (domain, self._catalog_name(serie_kind), serie, season_id),
571 display_id, 'season', query={'pageSize': 50})
573 title = try_get(data, lambda x: x['titles']['title'], compat_str) or display_id
574 return self.playlist_result(
575 self._entries(data, display_id),
579 class NRKTVSeriesIE(NRKTVSerieBaseIE):
580 _VALID_URL = r'https?://(?P<domain>(?:tv|radio)\.nrk|(?:tv\.)?nrksuper)\.no/(?P<serie_kind>serie|pod[ck]ast)/(?P<id>[^/]+)'
582 # new layout, instalments
583 'url': 'https://tv.nrk.no/serie/groenn-glede',
585 'id': 'groenn-glede',
586 'title': 'Grønn glede',
587 'description': 'md5:7576e92ae7f65da6993cf90ee29e4608',
589 'playlist_mincount': 90,
591 # new layout, instalments, more entries
592 'url': 'https://tv.nrk.no/serie/lindmo',
593 'only_matching': True,
595 'url': 'https://tv.nrk.no/serie/blank',
599 'description': 'md5:7664b4e7e77dc6810cd3bca367c25b6e',
601 'playlist_mincount': 30,
603 # new layout, seasons
604 'url': 'https://tv.nrk.no/serie/backstage',
607 'title': 'Backstage',
608 'description': 'md5:63692ceb96813d9a207e9910483d948b',
610 'playlist_mincount': 60,
613 'url': 'https://tv.nrksuper.no/serie/labyrint',
617 'description': 'I Daidalos sin undersjøiske Labyrint venter spennende oppgaver, skumle robotskapninger og slim.',
619 'playlist_mincount': 3,
621 'url': 'https://tv.nrk.no/serie/broedrene-dal-og-spektralsteinene',
622 'only_matching': True,
624 'url': 'https://tv.nrk.no/serie/saving-the-human-race',
625 'only_matching': True,
627 'url': 'https://tv.nrk.no/serie/postmann-pat',
628 'only_matching': True,
630 'url': 'https://radio.nrk.no/serie/dickie-dick-dickens',
632 'id': 'dickie-dick-dickens',
633 'title': 'Dickie Dick Dickens',
634 'description': 'md5:19e67411ffe57f7dce08a943d7a0b91f',
636 'playlist_mincount': 8,
638 'url': 'https://nrksuper.no/serie/labyrint',
639 'only_matching': True,
641 'url': 'https://radio.nrk.no/podkast/ulrikkes_univers',
643 'id': 'ulrikkes_univers',
645 'playlist_mincount': 10,
647 'url': 'https://radio.nrk.no/podkast/ulrikkes_univers/nrkno-poddkast-26588-134079-05042018030000',
648 'only_matching': True,
652 def suitable(cls, url):
654 False if any(ie.suitable(url)
655 for ie in (NRKTVIE, NRKTVEpisodeIE, NRKRadioPodkastIE, NRKTVSeasonIE))
656 else super(NRKTVSeriesIE, cls).suitable(url))
658 def _real_extract(self, url):
659 site, serie_kind, series_id = re.match(self._VALID_URL, url).groups()
660 is_radio = site == 'radio.nrk'
661 domain = 'radio' if is_radio else 'tv'
663 size_prefix = 'p' if is_radio else 'embeddedInstalmentsP'
664 series = self._call_api(
666 % (domain, self._catalog_name(serie_kind), series_id),
667 series_id, 'serie', query={size_prefix + 'ageSize': 50})
668 titles = try_get(series, [
669 lambda x: x['titles'],
670 lambda x: x[x['type']]['titles'],
671 lambda x: x[x['seriesType']]['titles'],
675 entries.extend(self._entries(series, series_id))
676 embedded = series.get('_embedded') or {}
677 linked_seasons = try_get(series, lambda x: x['_links']['seasons']) or []
678 embedded_seasons = embedded.get('seasons') or []
679 if len(linked_seasons) > len(embedded_seasons):
680 for season in linked_seasons:
681 season_url = urljoin(url, season.get('href'))
683 season_name = season.get('name')
684 if season_name and isinstance(season_name, compat_str):
685 season_url = 'https://%s.nrk.no/serie/%s/sesong/%s' % (domain, series_id, season_name)
687 entries.append(self.url_result(
688 season_url, ie=NRKTVSeasonIE.ie_key(),
689 video_title=season.get('title')))
691 for season in embedded_seasons:
692 entries.extend(self._entries(season, series_id))
693 entries.extend(self._entries(
694 embedded.get('extraMaterial') or {}, series_id))
696 return self.playlist_result(
697 entries, series_id, titles.get('title'), titles.get('subtitle'))
700 class NRKTVDirekteIE(NRKTVIE):
701 IE_DESC = 'NRK TV Direkte and NRK Radio Direkte'
702 _VALID_URL = r'https?://(?:tv|radio)\.nrk\.no/direkte/(?P<id>[^/?#&]+)'
705 'url': 'https://tv.nrk.no/direkte/nrk1',
706 'only_matching': True,
708 'url': 'https://radio.nrk.no/direkte/p1_oslo_akershus',
709 'only_matching': True,
713 class NRKRadioPodkastIE(InfoExtractor):
714 _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})'
717 'url': 'https://radio.nrk.no/podkast/ulrikkes_univers/l_96f4f1b0-de54-4e6a-b4f1-b0de54fe6af8',
718 'md5': '8d40dab61cea8ab0114e090b029a0565',
720 'id': 'MUHH48000314AA',
722 'title': '20 spørsmål 23.05.2014',
723 'description': 'md5:bdea103bc35494c143c6a9acdd84887a',
725 'series': '20 spørsmål',
726 'episode': '23.05.2014',
729 'url': 'https://radio.nrk.no/podcast/ulrikkes_univers/l_96f4f1b0-de54-4e6a-b4f1-b0de54fe6af8',
730 'only_matching': True,
732 'url': 'https://radio.nrk.no/podkast/ulrikkes_univers/sesong/1/l_96f4f1b0-de54-4e6a-b4f1-b0de54fe6af8',
733 'only_matching': True,
735 'url': 'https://radio.nrk.no/podkast/hele_historien/sesong/bortfoert-i-bergen/l_774d1a2c-7aa7-4965-8d1a-2c7aa7d9652c',
736 'only_matching': True,
739 def _real_extract(self, url):
740 video_id = self._match_id(url)
741 return self.url_result(
742 'nrk:%s' % video_id, ie=NRKIE.ie_key(), video_id=video_id)
745 class NRKPlaylistBaseIE(InfoExtractor):
746 def _extract_description(self, webpage):
749 def _real_extract(self, url):
750 playlist_id = self._match_id(url)
752 webpage = self._download_webpage(url, playlist_id)
755 self.url_result('nrk:%s' % video_id, NRKIE.ie_key())
756 for video_id in re.findall(self._ITEM_RE, webpage)
759 playlist_title = self. _extract_title(webpage)
760 playlist_description = self._extract_description(webpage)
762 return self.playlist_result(
763 entries, playlist_id, playlist_title, playlist_description)
766 class NRKPlaylistIE(NRKPlaylistBaseIE):
767 _VALID_URL = r'https?://(?:www\.)?nrk\.no/(?!video|skole)(?:[^/]+/)+(?P<id>[^/]+)'
768 _ITEM_RE = r'class="[^"]*\brich\b[^"]*"[^>]+data-video-id="([^"]+)"'
770 'url': 'http://www.nrk.no/troms/gjenopplev-den-historiske-solformorkelsen-1.12270763',
772 'id': 'gjenopplev-den-historiske-solformorkelsen-1.12270763',
773 'title': 'Gjenopplev den historiske solformørkelsen',
774 'description': 'md5:c2df8ea3bac5654a26fc2834a542feed',
778 'url': 'http://www.nrk.no/kultur/bok/rivertonprisen-til-karin-fossum-1.12266449',
780 'id': 'rivertonprisen-til-karin-fossum-1.12266449',
781 'title': 'Rivertonprisen til Karin Fossum',
782 'description': 'Første kvinne på 15 år til å vinne krimlitteraturprisen.',
787 def _extract_title(self, webpage):
788 return self._og_search_title(webpage, fatal=False)
790 def _extract_description(self, webpage):
791 return self._og_search_description(webpage)
794 class NRKTVEpisodesIE(NRKPlaylistBaseIE):
795 _VALID_URL = r'https?://tv\.nrk\.no/program/[Ee]pisodes/[^/]+/(?P<id>\d+)'
796 _ITEM_RE = r'data-episode=["\']%s' % NRKTVIE._EPISODE_RE
798 'url': 'https://tv.nrk.no/program/episodes/nytt-paa-nytt/69031',
801 'title': 'Nytt på nytt, sesong: 201210',
806 def _extract_title(self, webpage):
807 return self._html_search_regex(
808 r'<h1>([^<]+)</h1>', webpage, 'title', fatal=False)
811 class NRKSkoleIE(InfoExtractor):
812 IE_DESC = 'NRK Skole'
813 _VALID_URL = r'https?://(?:www\.)?nrk\.no/skole/?\?.*\bmediaId=(?P<id>\d+)'
816 'url': 'https://www.nrk.no/skole/?page=search&q=&mediaId=14099',
817 'md5': '18c12c3d071953c3bf8d54ef6b2587b7',
821 'title': 'Genetikk og eneggede tvillinger',
822 'description': 'md5:3aca25dcf38ec30f0363428d2b265f8d',
826 'url': 'https://www.nrk.no/skole/?page=objectives&subject=naturfag&objective=K15114&mediaId=19355',
827 'only_matching': True,
830 def _real_extract(self, url):
831 video_id = self._match_id(url)
833 nrk_id = self._download_json(
834 'https://nrkno-skole-prod.kube.nrk.no/skole/api/media/%s' % video_id,
837 return self.url_result('nrk:%s' % nrk_id)