summary refs log tree commit diff
diff options
context:
space:
mode:
authorJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>2015-02-16 21:12:31 +0100
committerJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>2015-02-16 21:51:08 +0100
commitc84dd8a90dcc75547b343449b921b644a2119c4f (patch)
tree3173266bbbee4bc5554d0a641d49ca06ffa623b3
parent65469a7f8b0ba50bd3c8918707e35125962aa2cd (diff)
downloadyoutube-dl-c84dd8a90dcc75547b343449b921b644a2119c4f.tar.gz
youtube-dl-c84dd8a90dcc75547b343449b921b644a2119c4f.tar.xz
youtube-dl-c84dd8a90dcc75547b343449b921b644a2119c4f.zip
[YoutubeDL] store the subtitles to download in the 'requested_subtitles' field
We need to keep the orginal subtitles information, so that the '--load-info' option can be used to list or select the subtitles again.
We'll also be able to have a separate field for storing the automatic captions info.
-rw-r--r--test/test_subtitles.py2
-rwxr-xr-xyoutube_dl/YoutubeDL.py6
-rw-r--r--youtube_dl/extractor/common.py2
-rw-r--r--youtube_dl/postprocessor/ffmpeg.py7
4 files changed, 8 insertions, 9 deletions
diff --git a/test/test_subtitles.py b/test/test_subtitles.py
index 3f2d61d36..b3c615c4f 100644
--- a/test/test_subtitles.py
+++ b/test/test_subtitles.py
@@ -36,7 +36,7 @@ class BaseTestSubtitles(unittest.TestCase):
 
     def getSubtitles(self):
         info_dict = self.getInfoDict()
-        subtitles = info_dict['subtitles']
+        subtitles = info_dict['requested_subtitles']
         if not subtitles:
             return subtitles
         for sub_info in subtitles.values():
diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py
index e665e3d53..8545dc9e9 100755
--- a/youtube_dl/YoutubeDL.py
+++ b/youtube_dl/YoutubeDL.py
@@ -1022,7 +1022,7 @@ class YoutubeDL(object):
         if self.params.get('listsubtitles', False):
             self.list_subtitles(info_dict['id'], info_dict.get('subtitles'))
             return
-        info_dict['subtitles'] = self.process_subtitles(info_dict['id'], info_dict.get('subtitles'))
+        info_dict['requested_subtitles'] = self.process_subtitles(info_dict['id'], info_dict.get('subtitles'))
 
         # This extractors handle format selection themselves
         if info_dict['extractor'] in ['Youku']:
@@ -1301,10 +1301,10 @@ class YoutubeDL(object):
         subtitles_are_requested = any([self.params.get('writesubtitles', False),
                                        self.params.get('writeautomaticsub')])
 
-        if subtitles_are_requested and 'subtitles' in info_dict and info_dict['subtitles']:
+        if subtitles_are_requested and info_dict.get('requested_subtitles'):
             # subtitles download errors are already managed as troubles in relevant IE
             # that way it will silently go on when used with unsupporting IE
-            subtitles = info_dict['subtitles']
+            subtitles = info_dict['requested_subtitles']
             for sub_lang, sub_info in subtitles.items():
                 sub_format = sub_info['ext']
                 if sub_info.get('data') is not None:
diff --git a/youtube_dl/extractor/common.py b/youtube_dl/extractor/common.py
index 161c623eb..d149e0f92 100644
--- a/youtube_dl/extractor/common.py
+++ b/youtube_dl/extractor/common.py
@@ -157,8 +157,6 @@ class InfoExtractor(object):
                     with the "ext" entry and one of:
                         * "data": The subtitles file contents
                         * "url": A url pointing to the subtitles file
-                    Note: YoutubeDL.extract_info will get the requested
-                    format and replace the "subformats" list with it.
     duration:       Length of the video in seconds, as an integer.
     view_count:     How many users have watched the video on the platform.
     like_count:     Number of positive ratings of the video
diff --git a/youtube_dl/postprocessor/ffmpeg.py b/youtube_dl/postprocessor/ffmpeg.py
index d1bbfbfe3..e42298f0e 100644
--- a/youtube_dl/postprocessor/ffmpeg.py
+++ b/youtube_dl/postprocessor/ffmpeg.py
@@ -462,13 +462,14 @@ class FFmpegEmbedSubtitlePP(FFmpegPostProcessor):
         if information['ext'] != 'mp4':
             self._downloader.to_screen('[ffmpeg] Subtitles can only be embedded in mp4 files')
             return True, information
-        if not information.get('subtitles'):
+        subtitles = information.get('requested_subtitles')
+        if not subtitles:
             self._downloader.to_screen('[ffmpeg] There aren\'t any subtitles to embed')
             return True, information
 
-        sub_langs = [key for key in information['subtitles']]
+        sub_langs = list(subtitles.keys())
         filename = information['filepath']
-        input_files = [filename] + [subtitles_filename(filename, lang, sub_info['ext']) for lang, sub_info in information['subtitles'].items()]
+        input_files = [filename] + [subtitles_filename(filename, lang, sub_info['ext']) for lang, sub_info in subtitles.items()]
 
         opts = [
             '-map', '0',