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

Code before:
        'url': 'https://www.tuffhedemantv.com/en/c/2022-tuff-hedeman-tour-hobbs-nm-january-22.227',
        'only_matching': True,
    }, {
        'url': 'https://www.albertalacrossetv.com/en/c/up-floor-ground-balls-one-more.3449',
        'only_matching': True,
    }, {
        'url': 'https://www.silenticetv.com/en/c/jp-unlocked-day-in-the-life-of-langley-ha-15u.5197',
        'only_matching': True,
    }, {
        'url': 'https://jphl.vidflex.tv/en/c/jp-unlocked-day-in-the-life-of-langley-ha-15u.5197',
        'only_matching': True,
    }]

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

        data_url = self._html_search_regex(
            r'content_api:\s*(["\'])(?P<url>https?://(?:(?!\1).)+)\1', webpage, 'content api url', group='url')
        media_config = traverse_obj(
            self._download_json(data_url, video_id),
            ('config', {base64.b64decode}, {bytes.decode}, {json.loads}, {dict}))

        return {
            'id': video_id,
            'formats': [*self._yield_formats(media_config, video_id)],
            **self._search_json_ld(
                webpage.replace('/*<![CDATA[*/', '').replace('/*]]>*/', ''), video_id),
        }

    def _yield_formats(self, media_config, video_id):
        for media_source in traverse_obj(media_config, ('media', 'source', lambda _, v: url_or_none(v['src']))):
            media_url = media_source['src']
            media_type = mimetype2ext(media_source.get('type'))

            if media_type == 'm3u8':
                yield from self._extract_m3u8_formats(media_url, video_id, fatal=False, m3u8_id='hls')
            elif media_type == 'mp4':
                bitrate = self._search_regex(r'_(\d+)k\.mp4', media_url, 'bitrate', default=None)
                yield {
                    'format_id': join_nonempty('http', bitrate),
                    'url': media_url,
                    'ext': 'mp4',
                    'tbr': int_or_none(bitrate),
                }
            else:
                yield {
                    'url': media_url,
                    'ext': media_type,
                }


Review comment (suggestion):
```suggestion
            'formats': list(self._yield_formats(media_config, video_id)),
```

Code after:
        'url': 'https://www.tuffhedemantv.com/en/c/2022-tuff-hedeman-tour-hobbs-nm-january-22.227',
        'only_matching': True,
    }, {
        'url': 'https://www.albertalacrossetv.com/en/c/up-floor-ground-balls-one-more.3449',
        'only_matching': True,
    }, {
        'url': 'https://www.silenticetv.com/en/c/jp-unlocked-day-in-the-life-of-langley-ha-15u.5197',
        'only_matching': True,
    }, {
        'url': 'https://jphl.vidflex.tv/en/c/jp-unlocked-day-in-the-life-of-langley-ha-15u.5197',
        'only_matching': True,
    }]

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

        data_url = self._html_search_regex(
            r'content_api:\s*(["\'])(?P<url>https?://(?:(?!\1).)+)\1', webpage, 'content api url', group='url')
        media_config = traverse_obj(
            self._download_json(data_url, video_id),
            ('config', {base64.b64decode}, {bytes.decode}, {json.loads}, {dict}))

        return {
            'id': video_id,
            'formats': list(self._yield_formats(media_config, video_id)),
            **self._search_json_ld(
                webpage.replace('/*<![CDATA[*/', '').replace('/*]]>*/', ''), video_id),
        }

    def _yield_formats(self, media_config, video_id):
        for media_source in traverse_obj(media_config, ('media', 'source', lambda _, v: url_or_none(v['src']))):
            media_url = media_source['src']
            media_type = mimetype2ext(media_source.get('type'))

            if media_type == 'm3u8':
                yield from self._extract_m3u8_formats(media_url, video_id, fatal=False, m3u8_id='hls')
            elif media_type == 'mp4':
                bitrate = self._search_regex(r'_(\d+)k\.mp4', media_url, 'bitrate', default=None)
                yield {
                    'format_id': join_nonempty('http', bitrate),
                    'url': media_url,
                    'ext': 'mp4',
                    'tbr': int_or_none(bitrate),
                }
            else:
                yield {
                    'url': media_url,
                    'ext': media_type,
                }