diff options
author | Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com> | 2015-02-17 22:16:29 +0100 |
---|---|---|
committer | Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com> | 2015-02-17 22:16:29 +0100 |
commit | 9868ea493626a3a81d30d084fd00d22982a0f86a (patch) | |
tree | a19d54a81c23aeef5ecf915678caae71ce3bf556 /youtube_dl | |
parent | 85920dd01d98cf74ea7d3ab7834a3b50cd6f1fde (diff) |
[extractor/common] Simplify subtitles handling methods
Initially I was going to use a single method for handling both subtitles and automatic captions, that's why I used the 'list_subtitles' and the 'subtitles' variables.
Diffstat (limited to 'youtube_dl')
-rw-r--r-- | youtube_dl/extractor/common.py | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/youtube_dl/extractor/common.py b/youtube_dl/extractor/common.py index fe7d8dbc9..7d8ce1808 100644 --- a/youtube_dl/extractor/common.py +++ b/youtube_dl/extractor/common.py @@ -1000,21 +1000,19 @@ class InfoExtractor(object): return not any_restricted def extract_subtitles(self, *args, **kwargs): - subtitles = {} - list_subtitles = self._downloader.params.get('listsubtitles') - if self._downloader.params.get('writesubtitles', False) or list_subtitles: - subtitles.update(self._get_subtitles(*args, **kwargs)) - return subtitles + if (self._downloader.params.get('writesubtitles', False) or + self._downloader.params.get('listsubtitles')): + return self._get_subtitles(*args, **kwargs) + return {} def _get_subtitles(self, *args, **kwargs): raise NotImplementedError("This method must be implemented by subclasses") def extract_automatic_captions(self, *args, **kwargs): - automatic_captions = {} - list_subtitles = self._downloader.params.get('listsubtitles') - if self._downloader.params.get('writeautomaticsub', False) or list_subtitles: - automatic_captions.update(self._get_automatic_captions(*args, **kwargs)) - return automatic_captions + if (self._downloader.params.get('writeautomaticsub', False) or + self._downloader.params.get('listsubtitles')): + return self._get_automatic_captions(*args, **kwargs) + return {} def _get_automatic_captions(self, *args, **kwargs): raise NotImplementedError("This method must be implemented by subclasses") |