add more subtitles mime types to mimetype2ext and fix the platform subtitle extraction
authorremitamine <remitamine@gmail.com>
Sat, 20 Feb 2016 21:02:03 +0000 (22:02 +0100)
committerremitamine <remitamine@gmail.com>
Sat, 20 Feb 2016 21:02:03 +0000 (22:02 +0100)
youtube_dl/extractor/common.py
youtube_dl/extractor/theplatform.py
youtube_dl/utils.py

index f411ea7633568915e4e97df61958d13c6a8aca80..c85dcda0cb257d9cd96b6775f958f8aac059a003 100644 (file)
@@ -46,6 +46,7 @@ from ..utils import (
     xpath_with_ns,
     determine_protocol,
     parse_duration,
+    mimetype2ext,
 )
 
 
@@ -1277,16 +1278,7 @@ class InfoExtractor(object):
             if not src or src in urls:
                 continue
             urls.append(src)
-            ext = textstream.get('ext') or determine_ext(src)
-            if not ext:
-                type_ = textstream.get('type')
-                SUBTITLES_TYPES = {
-                    'text/vtt': 'vtt',
-                    'text/srt': 'srt',
-                    'application/smptett+xml': 'tt',
-                }
-                if type_ in SUBTITLES_TYPES:
-                    ext = SUBTITLES_TYPES[type_]
+            ext = textstream.get('ext') or determine_ext(src) or mimetype2ext(textstream.get('type'))
             lang = textstream.get('systemLanguage') or textstream.get('systemLanguageName') or textstream.get('lang') or subtitles_lang
             subtitles.setdefault(lang, []).append({
                 'url': src,
index 755f816fff95bbe3567afe0168936eb6adb53095..93d8715716d00be7e15c53afbe804a3703b38e68 100644 (file)
@@ -21,6 +21,7 @@ from ..utils import (
     sanitized_Request,
     unsmuggle_url,
     xpath_with_ns,
+    mimetype2ext,
 )
 
 default_ns = 'http://www.w3.org/2005/SMIL21/Language'
@@ -68,7 +69,7 @@ class ThePlatformBaseIE(InfoExtractor):
             for caption in captions:
                 lang, src, mime = caption.get('lang', 'en'), caption.get('src'), caption.get('type')
                 subtitles[lang] = [{
-                    'ext': 'srt' if mime == 'text/srt' else 'ttml',
+                    'ext': mimetype2ext(mime),
                     'url': src,
                 }]
 
index a2c6780ca354f98514910752cec596a4eee172e5..6978a10e4cfa9b89874f5ec1da15c30a3e6d7e99 100644 (file)
@@ -1846,7 +1846,11 @@ def mimetype2ext(mt):
 
     return {
         '3gpp': '3gp',
+        'smptett+xml': 'tt',
+        'srt': 'srt',
+        'ttaf+xml': 'dfxp',
         'ttml+xml': 'ttml',
+        'vtt': 'vtt',
         'x-flv': 'flv',
         'x-mp4-fragmented': 'mp4',
         'x-ms-wmv': 'wmv',