]> gitweb @ CieloNegro.org - youtube-dl.git/commitdiff
[YoutubeDL] only add normal subtitles to the 'requested_subtitles' field if 'writesub...
authorJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>
Sun, 22 Feb 2015 10:37:27 +0000 (11:37 +0100)
committerJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>
Sun, 22 Feb 2015 10:37:27 +0000 (11:37 +0100)
test/test_YoutubeDL.py
youtube_dl/YoutubeDL.py

index e11292211a3a589e2e7440cf6bca637291abe1a9..055e4255583d500805facc4fc59e296170e876e4 100644 (file)
@@ -389,6 +389,13 @@ class TestFormatSelection(unittest.TestCase):
         self.assertFalse(subs['es']['_auto'])
         self.assertTrue(subs['pt']['_auto'])
 
+        result = get_info({'writeautomaticsub': True, 'subtitleslangs': ['es', 'pt']})
+        subs = result['requested_subtitles']
+        self.assertTrue(subs)
+        self.assertEqual(set(subs.keys()), set(['es', 'pt']))
+        self.assertTrue(subs['es']['_auto'])
+        self.assertTrue(subs['pt']['_auto'])
+
     def test_add_extra_info(self):
         test_dict = {
             'extractor': 'Foo',
index 088b111eb835f684bf934b4ba9a2334a9822f43a..7319323e59ae34dbcfc5c3101d32fddb1ff46319 100755 (executable)
@@ -1156,11 +1156,13 @@ class YoutubeDL(object):
         info_dict.update(formats_to_download[-1])
         return info_dict
 
-    def process_subtitles(self, video_id, available_subs, available_autocaps):
+    def process_subtitles(self, video_id, normal_subtitles, automatic_captions):
         """Select the requested subtitles and their format"""
-        if available_autocaps and self.params.get('writeautomaticsub'):
-            available_subs = available_subs.copy()
-            for lang, cap_info in available_autocaps.items():
+        available_subs = {}
+        if normal_subtitles and self.params.get('writesubtitles'):
+            available_subs.update(normal_subtitles)
+        if automatic_captions and self.params.get('writeautomaticsub'):
+            for lang, cap_info in automatic_captions.items():
                 if lang not in available_subs:
                     available_subs[lang] = cap_info