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

Code before:
            url = None
            formats = None
            item_id = item.get('id', post_id)
            item_type = item.get('type')
            if item_type == 'video':
                url = item.get('url')
            elif item_type == 'ok_video':
                formats = self._extract_formats(
                    item.get('playerUrls', []), item_id)
            if not url and not formats:
                continue
            entry = {
                'id': item_id,
                'title': item.get('title', post_title),
                'duration': item.get('duration'),
                'view_count': item.get('viewsCounter'),
                'thumbnail': dict_get(item, ('preview', 'defaultPreview')),
            }
            if url:
                entry['_type'] = 'url_transparent'
                entry['url'] = url
            elif formats:
                entry['formats'] = formats
            entries.append(entry)
        return entries

    def _extract_formats(self, player_urls, post_id):
        formats = []
        for player_url in player_urls:
            url = player_url.get('url')
            if not url:
                continue
            _type = player_url.get('type')
            if 'hls' in _type:
                # 'hls', 'hls_live'
                formats.extend(self._extract_m3u8_formats(
                    url, video_id=post_id, fatal=False))
            elif 'dash' in _type:
                # 'dash', 'dash_live'
                formats.extend(self._extract_mpd_formats(
                    url, video_id=post_id, fatal=False))
            else:
                # one of: 'tiny', 'low', etc.; see _get_quality for full list
                formats.append({
                    'url': url,
                    'ext': 'mp4',
                    'format_id': _type,
                })
        for format in formats:
            # .../type/<d>/... or ...&type=<d>&...
            format_type = self._search_regex(

Review comment (refactor):
With title/entries extraction being in `_real_extract` we can remove these two functions:
```suggestion
```

Code after:
        for player_url in traverse_obj(player_urls, lambda _, v: url_or_none(v['url'])):
            url = player_url['url']
            format_type = player_url.get('type')
            if format_type in ('hls', 'hls_live', 'live_ondemand_hls', 'live_playback_hls'):
                formats.extend(self._extract_m3u8_formats(url, video_id, m3u8_id='hls', fatal=False))
            elif format_type in ('dash', 'dash_live', 'live_playback_dash'):
                formats.extend(self._extract_mpd_formats(url, video_id, mpd_id='dash', fatal=False))
            elif format_type in self._MP4_TYPES:
                formats.append({
                    'url': url,
                    'ext': 'mp4',
                    'format_id': format_type,
                    'quality': quality(format_type),
                })
            else:
                self.report_warning(f'Unknown format type: {format_type!r}')
        return formats

    def _real_extract(self, url):
        user, post_id = self._match_valid_url(url).group('user', 'post_id')
        post = self._download_json(
            f'https://api.boosty.to/v1/blog/{user}/post/{post_id}', post_id,
            note='Downloading post data', errnote='Unable to download post data')

        post_title = post.get('title')
        if not post_title:
            self.report_warning('Unable to extract post title. Falling back to parsing html page')
            webpage = self._download_webpage(url, video_id=post_id)
            post_title = self._og_search_title(webpage, default=None) or self._html_extract_title(webpage)

        common_metadata = {
            'title': post_title,
            **traverse_obj(post, {
                'channel': ('user', 'name', {str}),
                'channel_id': ('user', 'id', {str_or_none}),
                'timestamp': ('createdAt', {int_or_none}),
                'release_timestamp': ('publishTime', {int_or_none}),
                'modified_timestamp': ('updatedAt', {int_or_none}),
                'tags': ('tags', ..., 'title', {str}),
                'like_count': ('count', 'likes', {int_or_none}),
            }),
        }
        entries = []
        for item in traverse_obj(post, ('data', ..., {dict})):
            item_type = item.get('type')
            if item_type == 'video' and url_or_none(item.get('url')):
                entries.append(self.url_result(item['url'], YoutubeIE))
            elif item_type == 'ok_video':
                video_id = item.get('id') or post_id
                entries.append({
                    'id': video_id,