- for _, captions in (try_get(
- video, lambda x: x['attachments']['captions'],
- dict) or {}).items():
- if not captions or not isinstance(captions, list):
- continue
- for caption in captions:
- caption_url = caption.get('url')
- if not caption_url:
- continue
- ext = caption.get('format')
- if ext == 'xml':
- ext = 'ttml'
- subtitles.setdefault(caption.get('lang') or 'en', []).append({
- 'url': caption_url,
- 'ext': ext,
- })
+ for resource in video.get('resources', []):
+ if resource.startswith('closed_caption_'):
+ splitted_resource = resource.split('_')
+ if splitted_resource[2]:
+ subtitles.setdefault('en', []).append({
+ 'url': 'https://resources.redbull.tv/%s/%s' % (video_id, resource),
+ 'ext': splitted_resource[2],
+ })