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

Code before:
            title = '%s - %s' % (uploader, title)

        uploader_id = str_or_none(
            user_data.get('_id')
            or user_data.get('username')
            or post_data.get('uid'))

        thumbnail = url_or_none(
            urljoin(self._MEDIA_BASE_URL, post_data.get('main'))
            or self._og_search_thumbnail(webpage))

        tags = post_data.get('htgs')
        timestamp = int_or_none(post_data.get('cdate'))
        duration = float_or_none(post_data.get('vid_dur'))

        if not dict_get(post_data, ['vid', 'ovid']):
            raise ExtractorError("There's no video in this post.")

        formats = []
        vid = post_data.get('vid')
        ovid = post_data.get('ovid')

        if vid:
            formats.extend(self._extract_m3u8_formats(
                urljoin(self._MEDIA_BASE_URL, vid), post_id, 'mp4',
                entry_protocol='m3u8_native', m3u8_id='hls'))
        if ovid:
            formats.append({
                'url': urljoin(self._MEDIA_BASE_URL, ovid),
                'format_id': 'ovid',
                'ext': 'mp4',
                'width': int_or_none(post_data.get('vid_wid')),
                'height': int_or_none(post_data.get('vid_hgt')),
                'preference': 0
            })

        self._sort_formats(formats)

        return {
            'id': post_id,
            'title': title,
            'description': description,
            'thumbnail': thumbnail,
            'timestamp': timestamp,
            'uploader_id': uploader_id,
            'uploader': uploader,
            'formats': formats,
            'duration': duration,
            'tags': tags,
        }


Review comment (refactor):
```suggestion
        formats = self._extract_m3u8_formats(
            urljoin(self._MEDIA_BASE_URL, vid), post_id, 'mp4',
            entry_protocol='m3u8_native', m3u8_id='hls') if vid else []
```

Code after:
        vid = post_data.get('vid')
        ovid = post_data.get('ovid')

        formats = self._extract_m3u8_formats(
            urljoin(self._MEDIA_BASE_URL, vid), post_id, 'mp4',
            entry_protocol='m3u8_native', m3u8_id='hls') if vid else []

        if ovid:
            formats.append({
                'url': urljoin(self._MEDIA_BASE_URL, ovid),
                'format_id': 'ovid',
                'ext': 'mp4',
                'width': int_or_none(post_data.get('vid_wid')),
                'height': int_or_none(post_data.get('vid_hgt')),
                'source_preference': 1,
                'quality': 1,
            })

        self._sort_formats(formats)

        return {
            'id': post_id,
            'title': title,
            'description': description,
            'thumbnail': url_or_none(
                urljoin(self._MEDIA_BASE_URL, post_data.get('main'))
                or self._og_search_thumbnail(webpage)),
            'timestamp': int_or_none(post_data.get('cdate')),
            'uploader_id': str_or_none(
                dict_get(user_data, ['_id', 'username'])
                or post_data.get('uid')),
            'uploader': uploader,
            'formats': formats,
            'duration': float_or_none(post_data.get('vid_dur')),
            'tags': post_data.get('htgs'),
        }