Compare commits

...

5 Commits

Author SHA1 Message Date
64ea58e49c
[nrk:base] Add tests for alt_title, flake8 and convension 2020-06-21 22:15:12 +02:00
5063afc5df
[nrk:base] Fall back to another endpoint for season and episode number
Prevents some long-running series from returning `NA`
2020-06-21 21:42:56 +02:00
2be9bcaae6
[nrk:base] Add alt_title
This is what I consider the actual title
2020-06-20 05:09:11 +02:00
cbd871084c
[nrk:base] Secondary method to fetch streams
Can't see why the original method don't work for some streams.
Bonus: provides 1080p quality
Closes #24221
2020-06-20 03:40:02 +02:00
d71bc476a8
[nrk:episode] Fixes KeyError
Get content of meta tag
Inspired by, and closes #25594
2020-06-20 03:36:28 +02:00

View File

@ -41,6 +41,7 @@ class NRKBaseIE(InfoExtractor):
break break
title = data.get('fullTitle') or data.get('mainTitle') or data['title'] title = data.get('fullTitle') or data.get('mainTitle') or data['title']
alt_title = data.get('mainTitle')
video_id = data.get('id') or video_id video_id = data.get('id') or video_id
entries = [] entries = []
@ -62,6 +63,14 @@ class NRKBaseIE(InfoExtractor):
if not asset_url: if not asset_url:
continue continue
formats = self._extract_akamai_formats(asset_url, video_id) formats = self._extract_akamai_formats(asset_url, video_id)
playback_manifest = self._download_json(
'http://%s/playback/manifest/program/%s' % (self._api_host, video_id),
video_id, 'Downloading manifest JSON', fatal=False)
streamurl = playback_manifest.get('statistics').get('conviva').get('streamUrl')
formats.extend(self._extract_m3u8_formats(
streamurl, video_id, 'mp4', 'm3u8_native', m3u8_id='hls', fatal=False,
errnote='Alternate extractor failed'))
if not formats: if not formats:
continue continue
self._sort_formats(formats) self._sort_formats(formats)
@ -139,6 +148,13 @@ class NRKBaseIE(InfoExtractor):
EPISODENUM_RE, _season_episode, 'episode number', EPISODENUM_RE, _season_episode, 'episode number',
default=None, group='episode')) default=None, group='episode'))
if not season_number or episode_number:
programs = self._download_json(
'http://%s/programs/%s' % (self._api_host, video_id),
video_id, 'Downloading programs manifest JSON', fatal=False)
season_number = int_or_none(programs.get('seasonNumber'))
episode_number = int_or_none(programs.get('episodeNumber'))
thumbnails = None thumbnails = None
images = data.get('images') images = data.get('images')
if images and isinstance(images, dict): if images and isinstance(images, dict):
@ -162,6 +178,7 @@ class NRKBaseIE(InfoExtractor):
'categories': [category] if category else None, 'categories': [category] if category else None,
'age_limit': parse_age_limit(data.get('legalAge')), 'age_limit': parse_age_limit(data.get('legalAge')),
'thumbnails': thumbnails, 'thumbnails': thumbnails,
'alt_title': alt_title,
} }
vcodec = 'none' if data.get('mediaType') == 'Audio' else None vcodec = 'none' if data.get('mediaType') == 'Audio' else None
@ -349,7 +366,8 @@ class NRKTVIE(NRKBaseIE):
'id': 'KMTE50001317AA', 'id': 'KMTE50001317AA',
'ext': 'mp4', 'ext': 'mp4',
'title': 'Anno 13:30', 'title': 'Anno 13:30',
'description': 'md5:11d9613661a8dbe6f9bef54e3a4cbbfa', 'alt_title': 'Anno',
'description': 'md5:13735a46076f1ed9310ed13dfd69789f',
'duration': 2340, 'duration': 2340,
'series': 'Anno', 'series': 'Anno',
'episode': '13:30', 'episode': '13:30',
@ -390,6 +408,7 @@ class NRKTVEpisodeIE(InfoExtractor):
'id': 'MUHH36005220BA', 'id': 'MUHH36005220BA',
'ext': 'mp4', 'ext': 'mp4',
'title': 'Kro, krig og kjærlighet 2:6', 'title': 'Kro, krig og kjærlighet 2:6',
'alt_title': 'Kro, krig og kjærlighet',
'description': 'md5:b32a7dc0b1ed27c8064f58b97bda4350', 'description': 'md5:b32a7dc0b1ed27c8064f58b97bda4350',
'duration': 1563, 'duration': 1563,
'series': 'Hellums kro', 'series': 'Hellums kro',
@ -427,7 +446,8 @@ class NRKTVEpisodeIE(InfoExtractor):
nrk_id = self._parse_json( nrk_id = self._parse_json(
self._search_regex(JSON_LD_RE, webpage, 'JSON-LD', group='json_ld'), self._search_regex(JSON_LD_RE, webpage, 'JSON-LD', group='json_ld'),
display_id)['@id'] display_id).get('@id') or \
self._html_search_meta('nrk:program-id', webpage)
assert re.match(NRKTVIE._EPISODE_RE, nrk_id) assert re.match(NRKTVIE._EPISODE_RE, nrk_id)
return self.url_result( return self.url_result(