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

Code before:

            vtt_subs, hls_subs = {}, {}
            if media_format == 'vtt':
                no_fmt, vtt_subs = self._extract_m3u8_formats_and_subtitles(
                    video_url, video_id, ext='vtt', entry_protocol='m3u8_native',
                    m3u8_id='vtt', fatal=False)
                continue
            elif media_format == 'm3u8' and tbr is not None:
                a_format.update({
                    'format_id': join_nonempty('hls', tbr),
                    'ext': 'mp4',
                })
            elif media_format == 'm3u8-variant' or ext == 'm3u8':
                # For some videos the initial m3u8 URL returns JSON instead
                try:
                    manifest_json = self._download_json(
                        video_url, video_id, note='Downloading manifest JSON')
                except ExtractorError:
                    pass
                else:
                    video_url = manifest_json.get('master_m3u8')
                    if not video_url:
                        continue
                hls_fmts, hls_subs = self._extract_m3u8_formats_and_subtitles(
                    video_url, video_id, ext='mp4', entry_protocol='m3u8_native',
                    m3u8_id='hls', fatal=False)
                formats.extend(hls_fmts)
                continue
            elif ext == 'mp3' or media_format == 'mp3':
                a_format['vcodec'] = 'none'
            else:
                a_format.update({
                    'width': int_or_none(published_url.get('width')),
                    'height': int_or_none(published_url.get('height')),
                })
            formats.append(a_format)

        self._sort_formats(formats)

        subtitles = {}
        for caption in video_data.get('captions', []):
            a_caption = {
                'url': caption['url'],
                'ext': 'tt' if caption.get('format') == 'SMPTE-TT' else None
            }
            subtitles.setdefault(caption['language'], []).append(a_caption)
        subtitles = self._merge_subtitles(subtitles, hls_subs, vtt_subs)

        return {
            'id': video_id,
            'formats': formats,

Review comment (suggestion):
```suggestion
                    video_url, video_id, ext='mp4', m3u8_id='hls', fatal=False)
```

Code after:
                    'format_id': join_nonempty('hls', tbr),
                    'ext': 'mp4',
                })
            elif media_format == 'm3u8-variant' or ext == 'm3u8':
                # For some videos the initial m3u8 URL returns JSON instead
                manifest_json = self._download_json(
                    video_url, video_id, note='Downloading manifest JSON', errnote=False)
                if manifest_json:
                    video_url = manifest_json.get('master_m3u8')
                    if not video_url:
                        continue
                hls_fmts, hls_subs = self._extract_m3u8_formats_and_subtitles(
                    video_url, video_id, ext='mp4', m3u8_id='hls', fatal=False)
                formats.extend(hls_fmts)
                continue
            elif ext == 'mp3' or media_format == 'mp3':
                a_format['vcodec'] = 'none'
            else:
                a_format.update({
                    'width': int_or_none(published_url.get('width')),
                    'height': int_or_none(published_url.get('height')),
                })
            formats.append(a_format)

        self._sort_formats(formats)

        subtitles = {}
        for caption in video_data.get('captions', []):
            a_caption = {
                'url': caption['url'],
                'ext': 'tt' if caption.get('format') == 'SMPTE-TT' else None
            }
            subtitles.setdefault(caption['language'], []).append(a_caption)
        subtitles = self._merge_subtitles(subtitles, hls_subs, vtt_subs)

        return {
            'id': video_id,
            'formats': formats,
            'title': video_data.get('def_title'),
            'description': video_data.get('def_description'),
            'tags': video_data.get('def_tags', '').split(','),
            'categories': video_data.get('categories'),
            'thumbnail': video_data.get('src_image_url') or video_data.get('thumbnail'),
            'timestamp': int_or_none(video_data.get(
                'ts_published') or video_data.get('ts_added')),
            'uploader': video_data.get('mcp_id'),
            'duration': int_or_none(video_data.get('duration')),
            'subtitles': subtitles,
        }

    @classmethod