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

Code before:
        return self._parse_json(js_data.replace('window._SSR_HYDRATED_DATA=', ''), video_id, transform_source=js_to_json)

    def _get_video_format(self, video_type, video_type_json):
        # select video data based on video type
        video_type_based_format = {}
        if video_type.startswith('dash'):
            video_data = traverse_obj(video_type_json, ('dynamic_video', 'dynamic_video_list'))
            video_type_based_format = {
                'format_note': 'DASH video',
            }
        else:
            video_data = video_type_json.get('video_list')

        _single_video_format = list()
        for video in video_data:
            if isinstance(video, str) and video.startswith('video_'):
                video = video_data.get(video)
            video_url = base64.b64decode(video.get('main_url')).decode()
            base_format = {
                'url': video_url,
                'width': int_or_none(video.get('vwidth')),
                'height': int_or_none(video.get('vheight')),
                'fps': int_or_none(video.get('fps')),
                'vcodec': video.get('codec_type'),
                'format_id': str(video.get('quality_type')),
                'ext': 'mp4' if parse_qs(video_url).get('mime_type')[0] == 'video_mp4' else 'mp4', 
                **video_type_based_format
            }

            _single_video_format.append(base_format)
        return _single_video_format

    def _real_extract(self, url):
        video_id = self._match_id(url)
        # need to pass cookie (at least contain __ac_nonce and ttwid)
        webpage = self._download_webpage(url, video_id)

        json_data = self._get_json_data(webpage, video_id)
        video_info = traverse_obj(json_data, ('anyVideo', 'gidInformation', 'packerData', 'video', 'videoResource'))

        format_ = list()
        for video_type, json_ in video_info.items():
            if not isinstance(json_, dict):
                continue
            video_format = self._get_video_format(video_type, json_)
            format_.extend(video_format)

        self._sort_formats(format_)
        return {
            'id': video_id,
            'title': traverse_obj(json_data, ('anyVideo', 'gidInformation', 'packerData', 'video', 'title')),

Review comment (suggestion):
```suggestion
                'ext': 'mp4', 
```

It's always MP4.

Code after:
    }]

    def _get_json_data(self, webpage, video_id):
        js_data = get_element_by_id('SSR_HYDRATED_DATA', webpage)
        if not js_data:
            if self._cookies_passed:
                raise ExtractorError('Failed to get SSR_HYDRATED_DATA')
            raise ExtractorError('Cookies (not necessarily logged in) are needed', expected=True)

        return self._parse_json(
            js_data.replace('window._SSR_HYDRATED_DATA=', ''), video_id, transform_source=js_to_json)

    def _media_selector(self, json_data):
        for path, override in (
            (('video_list', ), {}),
            (('dynamic_video', 'dynamic_video_list'), {'acodec': 'none'}),
            (('dynamic_video', 'dynamic_audio_list'), {'vcodec': 'none', 'ext': 'm4a'}),
        ):
            for media in traverse_obj(json_data, (..., *path, lambda _, v: v['main_url'])):
                yield {
                    'url': base64.b64decode(media['main_url']).decode(),
                    'width': int_or_none(media.get('vwidth')),
                    'height': int_or_none(media.get('vheight')),
                    'fps': int_or_none(media.get('fps')),
                    'vcodec': media.get('codec_type'),
                    'format_id': str_or_none(media.get('quality_type')),
                    'filesize': int_or_none(media.get('size')),
                    'ext': 'mp4',
                    **override,
                }

    def _real_extract(self, url):
        video_id = self._match_id(url)
        webpage = self._download_webpage(url, video_id)
        json_data = self._get_json_data(webpage, video_id)['anyVideo']['gidInformation']['packerData']['video']

        formats = list(self._media_selector(json_data.get('videoResource')))
        self._sort_formats(formats)
        return {
            'id': video_id,
            'title': json_data.get('title'),
            'description': json_data.get('video_abstract'),
            'formats': formats,
            'like_count': json_data.get('video_like_count'),
            'duration': int_or_none(json_data.get('duration')),
            'tags': [json_data.get('tag')],
            'uploader_id': traverse_obj(json_data, ('user_info', 'user_id')),
            'uploader': traverse_obj(json_data, ('user_info', 'name')),
            'view_count': json_data.get('video_watch_count'),
            'dislike_count': json_data.get('video_unlike_count'),
            'timestamp': int_or_none(json_data.get('video_publish_time')),