diff options
| author | Sergey M․ <dstftw@gmail.com> | 2021-01-03 07:02:13 +0700 | 
|---|---|---|
| committer | Sergey M․ <dstftw@gmail.com> | 2021-01-03 07:02:13 +0700 | 
| commit | 7dfd966848e17e3d438e5e49e1088b8b1444f9e5 (patch) | |
| tree | beb6054bc6e0d3387c51066bcb055ed8cda73aee | |
| parent | a25d03d7cb52111fab906c2c180f9bdf2c52ed12 (diff) | |
[nrk] Extract subtitles
| -rw-r--r-- | youtube_dl/extractor/nrk.py | 17 | 
1 files changed, 17 insertions, 0 deletions
| diff --git a/youtube_dl/extractor/nrk.py b/youtube_dl/extractor/nrk.py index d023de7f7..bd96d9d14 100644 --- a/youtube_dl/extractor/nrk.py +++ b/youtube_dl/extractor/nrk.py @@ -12,6 +12,7 @@ from ..utils import (      ExtractorError,      int_or_none,      parse_duration, +    str_or_none,      try_get,      urljoin,      url_or_none, @@ -204,6 +205,21 @@ class NRKIE(NRKBaseIE):                  'height': int_or_none(image.get('pixelHeight')),              }) +        subtitles = {} +        for sub in try_get(playable, lambda x: x['subtitles'], list) or []: +            if not isinstance(sub, dict): +                continue +            sub_url = url_or_none(sub.get('webVtt')) +            if not sub_url: +                continue +            sub_key = str_or_none(sub.get('language')) or 'nb' +            sub_type = str_or_none(sub.get('type')) +            if sub_type: +                sub_key += '-%s' % sub_type +            subtitles.setdefault(sub_key, []).append({ +                'url': sub_url, +            }) +          age_limit = int_or_none(try_get(              data, lambda x: x['legalAge']['body']['rating']['code'])) @@ -216,6 +232,7 @@ class NRKIE(NRKBaseIE):              'thumbnails': thumbnails,              'age_limit': age_limit,              'formats': formats, +            'subtitles': subtitles,          } | 
