[YoutubeDL] only add normal subtitles to the 'requested_subtitles' field if 'writesub...
[youtube-dl] / youtube_dl / YoutubeDL.py
index a47f8f5de953f61d068fbe2e50fb9ebf656f84b4..7319323e59ae34dbcfc5c3101d32fddb1ff46319 100755 (executable)
@@ -1156,16 +1156,20 @@ 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
 
-        if not available_subs:
-            return available_subs
+        if (not self.params.get('writesubtitles') and not
+                self.params.get('writeautomaticsub') or not
+                available_subs):
+            return None
 
         if self.params.get('allsubtitles', False):
             requested_langs = available_subs.keys()
@@ -1659,13 +1663,12 @@ class YoutubeDL(object):
         if not subtitles:
             self.to_screen('%s has no %s' % (video_id, name))
             return
-        header_line = 'Language    formats'
-        sub_lines = [
-            '%-12s%s' % (lang, ', '.join(f['ext'] for f in reversed(formats)))
-            for lang, formats in subtitles.items()]
         self.to_screen(
-            'Available %s for %s:\n%s\n%s' %
-            (name, video_id, header_line, '\n'.join(sub_lines)))
+            'Available %s for %s:' % (name, video_id))
+        self.to_screen(render_table(
+            ['Language', 'formats'],
+            [[lang, ', '.join(f['ext'] for f in reversed(formats))]
+                for lang, formats in subtitles.items()]))
 
     def urlopen(self, req):
         """ Start an HTTP download """