From 25e5ebf382b2fca9d4b6909ac1ac9b5af89bcdd9 Mon Sep 17 00:00:00 2001 From: Frans de Jonge Date: Thu, 5 Feb 2015 12:51:33 +0100 Subject: [PATCH 1/3] Add NPO.nl subtitles Implements #3638 --- youtube_dl/extractor/npo.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/youtube_dl/extractor/npo.py b/youtube_dl/extractor/npo.py index 175b14583..0580461bb 100644 --- a/youtube_dl/extractor/npo.py +++ b/youtube_dl/extractor/npo.py @@ -1,6 +1,6 @@ from __future__ import unicode_literals -from .common import InfoExtractor +from .subtitles import SubtitlesInfoExtractor from ..utils import ( fix_xml_ampersands, parse_duration, @@ -11,7 +11,7 @@ ) -class NPOBaseIE(InfoExtractor): +class NPOBaseIE(SubtitlesInfoExtractor): def _get_token(self, video_id): token_page = self._download_webpage( 'http://ida.omroep.nl/npoplayer/i.js', @@ -159,6 +159,13 @@ def _get_info(self, video_id): 'quality': stream.get('kwaliteit'), }) + subtitles = {} + + tt888 = metadata.get('tt888') + if self._have_to_download_any_subtitles and tt888 == 'ja': + subtitles['nl'] = 'http://e.omroep.nl/tt888/%s' % video_id + subtitles = self.extract_subtitles(video_id, subtitles) + self._sort_formats(formats) return { @@ -169,6 +176,7 @@ def _get_info(self, video_id): 'upload_date': unified_strdate(metadata.get('gidsdatum')), 'duration': parse_duration(metadata.get('tijdsduur')), 'formats': formats, + 'subtitles': subtitles, } From 9e91449c8d1dae53eda6fb250384f0afa5122ce6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergey=20M=E2=80=A4?= Date: Thu, 5 Feb 2015 20:13:28 +0600 Subject: [PATCH 2/3] [npo] Fix subtitles (Closes #3638) --- youtube_dl/extractor/npo.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/youtube_dl/extractor/npo.py b/youtube_dl/extractor/npo.py index 0580461bb..54be06a4e 100644 --- a/youtube_dl/extractor/npo.py +++ b/youtube_dl/extractor/npo.py @@ -159,15 +159,18 @@ def _get_info(self, video_id): 'quality': stream.get('kwaliteit'), }) - subtitles = {} - - tt888 = metadata.get('tt888') - if self._have_to_download_any_subtitles and tt888 == 'ja': - subtitles['nl'] = 'http://e.omroep.nl/tt888/%s' % video_id - subtitles = self.extract_subtitles(video_id, subtitles) - self._sort_formats(formats) + subtitles = {} + if metadata.get('tt888') == 'ja': + subtitles['nl'] = 'http://e.omroep.nl/tt888/%s' % video_id + + if self._downloader.params.get('listsubtitles', False): + self._list_available_subtitles(video_id, subtitles) + return + + subtitles = self.extract_subtitles(video_id, subtitles) + return { 'id': video_id, 'title': metadata['titel'], From 6a348cf7d507f0373e9a6f67358202b66a858cd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergey=20M=E2=80=A4?= Date: Thu, 5 Feb 2015 20:14:56 +0600 Subject: [PATCH 3/3] Credit @Frenzie for npo subtitles (#4878) --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index 83d8161a9..85ca81a27 100644 --- a/AUTHORS +++ b/AUTHORS @@ -108,3 +108,4 @@ Enam Mijbah Noor David Luhmer Shaya Goldberg Paul Hartmann +Frans de Jonge