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

Code before:
        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):
`traverse_obj` is especially useful for inline metadata extraction; we can use dict key traversal here. Using set syntax, we can expect types (e.g. `{str}`) and perform transformations (`{callable}`)

I changed `channel` to `series`, since that seems more accurate? Although if you have rationale for extracting it as `channel`, feel free to keep it that way. Tests will need to be updated if we change it to `series`

`title` shouldn't be fatal; that was an old youtube-dl convention. yt-dlp core code can handle when no title is returned
```suggestion
            **traverse_obj(meta, {
                'title': ('title', {str}),
                'description': ('description', {str}),
                'series': ('seriestitle', {str}),
                'season': ('season', {str}),
                'episode': ('episode', {str}),
                'duration': ('duration', {float_or_none}),
                'timestamp': ('updated_at', {parse_iso8601}),
                'thumbnail': ('thumb', {url_or_none}),
            }),
```

Code after:
            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,
        }