1
0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-11-15 03:27:46 +01:00

[nrk] Improve series metadata extraction

This commit is contained in:
Sergey M․ 2021-01-03 07:30:45 +07:00
parent 7dfd966848
commit 85de33b04e
No known key found for this signature in database
GPG Key ID: 2C393E0F18A9236D

View File

@ -223,7 +223,9 @@ class NRKIE(NRKBaseIE):
age_limit = int_or_none(try_get(
data, lambda x: x['legalAge']['body']['rating']['code']))
return {
is_series = try_get(data, lambda x: x['_links']['series']['name']) == 'series'
info = {
'id': video_id,
'title': title,
'alt_title': alt_title,
@ -235,6 +237,27 @@ class NRKIE(NRKBaseIE):
'subtitles': subtitles,
}
if is_series:
series = title
if alt_title:
title += ' - %s' % alt_title
season_number = int_or_none(self._search_regex(
r'Sesong\s+(\d+)', description or '', 'season number',
default=None))
episode = alt_title if is_series else None
episode_number = int_or_none(self._search_regex(
r'(\d+)\.\s+episode', episode or '', 'episode number',
default=None))
info.update({
'title': title,
'series': series,
'season_number': season_number,
'episode': episode,
'episode_number': episode_number,
})
return info
class NRKTVIE(InfoExtractor):
IE_DESC = 'NRK TV and NRK Radio'