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

Code before:
            'age_limit': 0,
            'availability': 'public',
            'categories': list,
            'channel_follower_count': int,
            'channel_id': 'UCCzVNbWZfYpBfyofCCUD_0w',
            'channel_is_verified': bool,
            'channel_url': r're:^https://www.youtube.com/',
            'comment_count': int,
            'description': str,
            'heatmap': 'count:100',
            'live_status': str,
            'playable_in_embed': bool,
            'uploader': str,
            'uploader_id': str,
            'uploader_url': r're:^https://www.youtube.com/',
        },
    }]

    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 = self._extract_title(post, post_id, url)
        entries = self._extract_entries(post, post_id, post_title)
        if not entries:
            raise ExtractorError(
                'no video found', video_id=post_id, expected=True)
        result = {
            'id': post_id,
            'title': post_title,
            'channel': traverse_obj(post, ('user', 'name')),
            'timestamp': dict_get(post, ('publishTime', 'createdAt')),
            'modified_timestamp': post.get('updatedAt'),
            'tags': [tag['title'] for tag in post.get('tags', [])],
            'like_count': traverse_obj(post, ('count', 'likes')),
        }
        if len(entries) == 1:
            result.update(entries[0])
        else:
            result['_type'] = 'playlist'
            result['entries'] = entries
        return result

    def _extract_title(self, post, post_id, url):
        title = post.get('title')
        if title:
            return title
        # falling back to parsing html page as a last resort

Review comment (refactor):
I think it is better to inline title/entries extraction and construct a common metadata dict:
```suggestion
        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, fatal=False)
                          or self._html_extract_title(webpage, fatal=True))

        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_date': ('publishTime', {int_or_none}),
                'modified_timestamp': ('updatedAt', {int_or_none}),
                'tags': ('tags', ..., 'title', {str}),
                'like_count': ('count', 'likes', {int_or_none}),
            }),
        }
```

Code after:
                'view_count': int,
                'thumbnail': r're:^https://i\.mycdn\.me/videoPreview\?',
            },
        }, {
            'info_dict': {
                'id': '4a3bba32-78c8-422a-9432-2791aff60b42',
                'title': 'то что не пропустил юта6',
                'channel': 'Илья Давыдов',
                'channel_id': '6808257',
                'timestamp': 1694017040,
                'upload_date': '20230906',
                'release_timestamp': 1694017040,
                'release_date': '20230906',
                'modified_timestamp': 1694071178,
                'modified_date': '20230907',
                'like_count': int,
                'ext': 'mp4',
                'duration': 31867,
                'view_count': int,
                'thumbnail': r're:^https://i\.mycdn\.me/videoPreview\?',
            },
        }],
    }, {
        # single external video (youtube)
        'url': 'https://boosty.to/denischuzhoy/posts/6094a487-bcec-4cf8-a453-43313b463c38',
        'info_dict': {
            'id': 'EXelTnve5lY',
            'title': 'Послание Президента Федеральному Собранию | Класс народа',
            'upload_date': '20210425',
            'channel': 'Денис Чужой',
            'tags': 'count:10',
            'like_count': int,
            'ext': 'mp4',
            'duration': 816,
            'view_count': int,
            'thumbnail': r're:^https://i\.ytimg\.com/',
            'age_limit': 0,
            'availability': 'public',
            'categories': list,
            'channel_follower_count': int,
            'channel_id': 'UCCzVNbWZfYpBfyofCCUD_0w',
            'channel_is_verified': bool,
            'channel_url': r're:^https://www\.youtube\.com/',
            'comment_count': int,
            'description': str,
            'heatmap': 'count:100',
            'live_status': str,
            'playable_in_embed': bool,
            'uploader': str,
            'uploader_id': str,
            'uploader_url': r're:^https://www\.youtube\.com/',