import re
from .common import InfoExtractor
-from ..compat import compat_str
from ..utils import (
+ determine_ext,
extract_attributes,
ExtractorError,
int_or_none,
parse_age_limit,
remove_end,
unescapeHTML,
+ url_or_none,
)
captions = stream.get('captions')
if isinstance(captions, list):
for caption in captions:
- subtitle_url = caption.get('fileUrl')
- if (not subtitle_url or not isinstance(subtitle_url, compat_str) or
- not subtitle_url.startswith('http')):
+ subtitle_url = url_or_none(caption.get('fileUrl'))
+ if not subtitle_url or not subtitle_url.startswith('http'):
continue
lang = caption.get('fileLang', 'en')
- subtitles.setdefault(lang, []).append({'url': subtitle_url})
+ ext = determine_ext(subtitle_url)
+ subtitles.setdefault(lang, []).append({
+ 'url': subtitle_url,
+ 'ext': 'ttml' if ext == 'xml' else ext,
+ })
return {
'id': video_id,