Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/axs.py (Python)

Code before:
            'season': 3,
            'episode': '5',
            'thumbnail': 'https://images.dotstudiopro.com/5f4d1901f340b50d937cec32',
        },
    }]

    def _real_extract(self, url):
        initial_id = self._match_id(url)
        webpage = self._download_webpage(url, initial_id)

        webpage_json_data = self._search_json(
            r'mountObj\s*=', webpage, 'video ID data', initial_id,
            transform_source=js_to_json, default={})
        video_id = webpage_json_data['video_id']
        company_id = webpage_json_data['company_id']

        meta_url = self._META_URL % (company_id, video_id)
        meta = self._download_json(meta_url, video_id)['video']

        format_url = meta['video_m3u8']
        formats = self._extract_m3u8_formats(
            format_url, video_id, 'mp4', m3u8_id='hls',
            entry_protocol='m3u8_native', fatal=False)

        subtitles = {}
        for cc in meta.get('closeCaption'):
            subtitles.setdefault(cc.get('srtShortLang') or 'en', []).append(
                {'ext': cc.get('srtExt'), 'url': cc['srtPath']})

        return {
            'id': video_id,
            'formats': formats,
            'title': meta['title'],
            'description': meta.get('description'),
            'channel': meta.get('seriestitle'),
            'season': meta.get('season'),
            'episode': meta.get('episode'),
            'duration': float_or_none(meta.get('duration')),
            'timestamp': parse_iso8601(meta.get('updated_at')),
            'thumbnail': meta.get('thumb'),
            'subtitles': subtitles,
        }


Review comment (refactor):
Subtitles extraction should be non-fatal. Here let's use `traverse_obj` to branch/filter:
```suggestion
        for cc in traverse_obj(meta, ('closeCaption', lambda _, v: url_or_none(v['srtPath']))):
```

Code after:
            'duration': 2570.668,
            'series': 'The Big Interview with Dan Rather',
            'season': 3,
            'episode': '5',
            'thumbnail': 'https://images.dotstudiopro.com/5f4d1901f340b50d937cec32',
        },
    }]

    def _real_extract(self, url):
        display_id = self._match_id(url)
        webpage = self._download_webpage(url, display_id)

        webpage_json_data = self._search_json(
            r'mountObj\s*=', webpage, 'video ID data', display_id,
            transform_source=js_to_json)
        video_id = webpage_json_data['video_id']
        company_id = webpage_json_data['company_id']

        meta = self._download_json(
            f'https://api.myspotlight.tv/dotplayer/video/{company_id}/{video_id}',
            video_id, query={'device_type': 'desktop_web'})['video']

        formats = self._extract_m3u8_formats(
            meta['video_m3u8'], video_id, 'mp4', m3u8_id='hls')

        subtitles = {}
        for cc in traverse_obj(meta, ('closeCaption', lambda _, v: url_or_none(v['srtPath']))):
            subtitles.setdefault(cc.get('srtShortLang') or 'en', []).append(
                {'ext': cc.get('srtExt'), 'url': cc['srtPath']})

        return {
            'id': video_id,
            'display_id': display_id,
            'formats': formats,
            **traverse_obj(meta, {
                'title': ('title', {str}),
                'description': ('description', {str}),
                'series': ('seriestitle', {str}),
                'season': ('season', {int}),
                'episode': ('episode', {str}),
                'duration': ('duration', {float_or_none}),
                'timestamp': ('updated_at', {parse_iso8601}),
                'thumbnail': ('thumb', {url_or_none}),
            }),
            'subtitles': subtitles,
        }