]> gitweb @ CieloNegro.org - youtube-dl.git/commitdiff
[YoutubeDL] store the subtitles to download in the 'requested_subtitles' field
authorJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>
Mon, 16 Feb 2015 20:12:31 +0000 (21:12 +0100)
committerJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>
Mon, 16 Feb 2015 20:51:08 +0000 (21:51 +0100)
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.

test/test_subtitles.py
youtube_dl/YoutubeDL.py
youtube_dl/extractor/common.py
youtube_dl/postprocessor/ffmpeg.py

index 3f2d61d3682cad77d0fb9f83c6f691af842ced78..b3c615c4f7a12d093aa2b36ffbc8267ce8aef5a2 100644 (file)
@@ -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():
index e665e3d53bb4ca1f557074f4c46179bfaf65de5c..8545dc9e924aaadc2ba862b96b268b6cf6511ea9 100755 (executable)
@@ -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:
index 161c623eb8f11d732cddeb8dcd5af8191bb77ac4..d149e0f92d0bfca461cffa97b79e9293b7f0d86e 100644 (file)
@@ -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
index d1bbfbfe38400f6fe804721df5cc84fff98ccd58..e42298f0e8c1a0d97d7c3a465ec6aea337ef380c 100644 (file)
@@ -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',