diff options
author | Rogério Brito <rbrito@ime.usp.br> | 2017-05-19 03:21:46 -0300 |
---|---|---|
committer | Rogério Brito <rbrito@ime.usp.br> | 2017-05-19 03:21:46 -0300 |
commit | 532a08904ffbacc5e5ccf99edb660c5f37ddb213 (patch) | |
tree | 12399229cfa94b847a3ba07fcdca2336e5adc5b0 /youtube_dl/extractor/nrk.py | |
parent | 97a8fc3ae80fb363c69c2e6b8c29b5373ac72aea (diff) | |
parent | d9d7cd0e85dc712461d9185db9df9d6c900a573b (diff) | |
download | youtube-dl-532a08904ffbacc5e5ccf99edb660c5f37ddb213.zip youtube-dl-532a08904ffbacc5e5ccf99edb660c5f37ddb213.tar.gz youtube-dl-532a08904ffbacc5e5ccf99edb660c5f37ddb213.tar.bz2 |
Merge tag 'upstream/2017.05.18.1'
Upstream version 2017.05.18.1
Diffstat (limited to 'youtube_dl/extractor/nrk.py')
-rw-r--r-- | youtube_dl/extractor/nrk.py | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/youtube_dl/extractor/nrk.py b/youtube_dl/extractor/nrk.py index 7fe79cb..3b4f51f 100644 --- a/youtube_dl/extractor/nrk.py +++ b/youtube_dl/extractor/nrk.py @@ -148,13 +148,34 @@ class NRKBaseIE(InfoExtractor): vcodec = 'none' if data.get('mediaType') == 'Audio' else None - # TODO: extract chapters when https://github.com/rg3/youtube-dl/pull/9409 is merged - for entry in entries: entry.update(common_info) for f in entry['formats']: f['vcodec'] = vcodec + points = data.get('shortIndexPoints') + if isinstance(points, list): + chapters = [] + for next_num, point in enumerate(points, start=1): + if not isinstance(point, dict): + continue + start_time = parse_duration(point.get('startPoint')) + if start_time is None: + continue + end_time = parse_duration( + data.get('duration') + if next_num == len(points) + else points[next_num].get('startPoint')) + if end_time is None: + continue + chapters.append({ + 'start_time': start_time, + 'end_time': end_time, + 'title': point.get('title'), + }) + if chapters and len(entries) == 1: + entries[0]['chapters'] = chapters + return self.playlist_result(entries, video_id, title, description) |