mirror of
				https://github.com/ytdl-org/youtube-dl.git
				synced 2025-10-29 09:26:20 -07:00 
			
		
		
		
	add more subtitles mime types to mimetype2ext and fix the platform subtitle extraction
This commit is contained in:
		| @@ -46,6 +46,7 @@ from ..utils import ( | |||||||
|     xpath_with_ns, |     xpath_with_ns, | ||||||
|     determine_protocol, |     determine_protocol, | ||||||
|     parse_duration, |     parse_duration, | ||||||
|  |     mimetype2ext, | ||||||
| ) | ) | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -1277,16 +1278,7 @@ class InfoExtractor(object): | |||||||
|             if not src or src in urls: |             if not src or src in urls: | ||||||
|                 continue |                 continue | ||||||
|             urls.append(src) |             urls.append(src) | ||||||
|             ext = textstream.get('ext') or determine_ext(src) |             ext = textstream.get('ext') or determine_ext(src) or mimetype2ext(textstream.get('type')) | ||||||
|             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_] |  | ||||||
|             lang = textstream.get('systemLanguage') or textstream.get('systemLanguageName') or textstream.get('lang') or subtitles_lang |             lang = textstream.get('systemLanguage') or textstream.get('systemLanguageName') or textstream.get('lang') or subtitles_lang | ||||||
|             subtitles.setdefault(lang, []).append({ |             subtitles.setdefault(lang, []).append({ | ||||||
|                 'url': src, |                 'url': src, | ||||||
|   | |||||||
| @@ -21,6 +21,7 @@ from ..utils import ( | |||||||
|     sanitized_Request, |     sanitized_Request, | ||||||
|     unsmuggle_url, |     unsmuggle_url, | ||||||
|     xpath_with_ns, |     xpath_with_ns, | ||||||
|  |     mimetype2ext, | ||||||
| ) | ) | ||||||
|  |  | ||||||
| default_ns = 'http://www.w3.org/2005/SMIL21/Language' | default_ns = 'http://www.w3.org/2005/SMIL21/Language' | ||||||
| @@ -68,7 +69,7 @@ class ThePlatformBaseIE(InfoExtractor): | |||||||
|             for caption in captions: |             for caption in captions: | ||||||
|                 lang, src, mime = caption.get('lang', 'en'), caption.get('src'), caption.get('type') |                 lang, src, mime = caption.get('lang', 'en'), caption.get('src'), caption.get('type') | ||||||
|                 subtitles[lang] = [{ |                 subtitles[lang] = [{ | ||||||
|                     'ext': 'srt' if mime == 'text/srt' else 'ttml', |                     'ext': mimetype2ext(mime), | ||||||
|                     'url': src, |                     'url': src, | ||||||
|                 }] |                 }] | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1846,7 +1846,11 @@ def mimetype2ext(mt): | |||||||
|  |  | ||||||
|     return { |     return { | ||||||
|         '3gpp': '3gp', |         '3gpp': '3gp', | ||||||
|  |         'smptett+xml': 'tt', | ||||||
|  |         'srt': 'srt', | ||||||
|  |         'ttaf+xml': 'dfxp', | ||||||
|         'ttml+xml': 'ttml', |         'ttml+xml': 'ttml', | ||||||
|  |         'vtt': 'vtt', | ||||||
|         'x-flv': 'flv', |         'x-flv': 'flv', | ||||||
|         'x-mp4-fragmented': 'mp4', |         'x-mp4-fragmented': 'mp4', | ||||||
|         'x-ms-wmv': 'wmv', |         'x-ms-wmv': 'wmv', | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user