[YoutubeDL] Autocalculate ext for subtitles when missing
authorSergey M․ <dstftw@gmail.com>
Sun, 4 Oct 2015 14:33:42 +0000 (20:33 +0600)
committerSergey M․ <dstftw@gmail.com>
Sun, 4 Oct 2015 14:42:26 +0000 (20:42 +0600)
youtube_dl/YoutubeDL.py
youtube_dl/extractor/common.py

index d65253882feed92b941fe3d791626a9a43e852a4..adf70d658b2d24b6b526869da9a8b0005cca5afb 100755 (executable)
@@ -1232,13 +1232,20 @@ class YoutubeDL(object):
             except (ValueError, OverflowError, OSError):
                 pass
 
+        subtitles = info_dict.get('subtitles')
+        if subtitles:
+            for _, subtitle in subtitles.items():
+                for subtitle_format in subtitle:
+                    if 'ext' not in subtitle_format:
+                        subtitle_format['ext'] = determine_ext(subtitle_format['url']).lower()
+
         if self.params.get('listsubtitles', False):
             if 'automatic_captions' in info_dict:
                 self.list_subtitles(info_dict['id'], info_dict.get('automatic_captions'), 'automatic captions')
-            self.list_subtitles(info_dict['id'], info_dict.get('subtitles'), 'subtitles')
+            self.list_subtitles(info_dict['id'], subtitles, 'subtitles')
             return
         info_dict['requested_subtitles'] = self.process_subtitles(
-            info_dict['id'], info_dict.get('subtitles'),
+            info_dict['id'], subtitles,
             info_dict.get('automatic_captions'))
 
         # We now pick which formats have to be downloaded
index 4fe2307cdd42b9187d86940c2628b2648fc97d7b..dbae75406233ae8d5d2db2acf2090e6522a91295 100644 (file)
@@ -165,6 +165,7 @@ class InfoExtractor(object):
                     with the "ext" entry and one of:
                         * "data": The subtitles file contents
                         * "url": A URL pointing to the subtitles file
+                    "ext" will be calculated from URL if missing
     automatic_captions: Like 'subtitles', used by the YoutubeIE for
                     automatically generated captions
     duration:       Length of the video in seconds, as an integer.