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

Code before:
            sub_data = self._download_webpage(
                sub['url'], ep_id or aid, fatal=False,
                encoding='utf-8-sig' if sub_ext == 'ass' else None,
                note=f'Downloading subtitles{format_field(sub, "lang", "for %s")} ({sub_lang})',
                errnote='Unable to download subtitles')
            if sub_ext != 'ass':
                sub_ext, sub_data = 'srt', self.json2srt(sub_data)

            if sub_data:
                subtitles.setdefault(sub_lang, []).append({
                    'ext': sub_ext,
                    'data': sub_data
                })

        for sub in traverse_obj(sub_json, ('video_subtitle', ..., {dict})):
            sub_lang = sub.get('lang_key') or 'en'
            if sub.get('ass'):
                subtitles.setdefault(sub_lang, []).append({
                    'ext': 'ass',
                    'url': traverse_obj(sub, ('ass', 'url'))
                })

            if sub.get('srt'):
                sub_data = self._download_json(
                    traverse_obj(sub, ('srt', 'url')), ep_id or aid, fatal=False,
                    note=f'Downloading subtitles{format_field(sub, "lang", "for %s")} ({sub_lang})',
                    errnote='Unable to download subtitles')
                if sub_data:
                    subtitles.setdefault(sub_lang, []).append({
                        'ext': 'srt',
                        'data': self.json2srt(sub_data)
                    })

        return subtitles

    def _get_formats(self, *, ep_id=None, aid=None):
        video_json = self._call_api(
            '/web/playurl', ep_id or aid, note='Downloading video formats',
            errnote='Unable to download video formats', query=filter_dict({
                'platform': 'web',
                'ep_id': ep_id,
                'aid': aid,
            }))
        video_json = video_json['playurl']
        formats = []
        for vid in video_json.get('video') or []:
            video_res = vid.get('video_resource') or {}
            video_info = vid.get('stream_info') or {}
            if not video_res.get('url'):
                continue
            formats.append({

Review comment (suggestion):
```suggestion
                    note=f'Downloading subtitles{format_field(sub, "lang", " for %s")} ({sub_lang})',
```

Code after:
        },
        'playlist_mincount': 5,
        'skip': 'paid video in list',
    }]

    def _get_cheese_entries(self, season_info):
        for ep_id in traverse_obj(season_info, ('episodes', lambda _, v: v['episode_can_view'], 'id')):
            yield self._extract_episode(season_info, ep_id)

    def _real_extract(self, url):
        season_id = self._match_id(url)
        season_info = self._download_season_info('season_id', season_id)

        return self.playlist_result(
            self._get_cheese_entries(season_info), season_id,
            **traverse_obj(season_info, {
                'title': ('title', {str}),
                'description': ('subtitle', {str}),
            }))


class BilibiliSpaceBaseIE(InfoExtractor):
    def _extract_playlist(self, fetch_page, get_metadata, get_entries):
        first_page = fetch_page(0)
        metadata = get_metadata(first_page)

        paged_list = InAdvancePagedList(
            lambda idx: get_entries(fetch_page(idx) if idx else first_page),
            metadata['page_count'], metadata['page_size'])

        return metadata, paged_list


class BilibiliSpaceVideoIE(BilibiliSpaceBaseIE):
    _VALID_URL = r'https?://space\.bilibili\.com/(?P<id>\d+)(?P<video>/video)?/?(?:[?#]|$)'
    _TESTS = [{
        'url': 'https://space.bilibili.com/3985676/video',
        'info_dict': {
            'id': '3985676',
        },
        'playlist_mincount': 178,
    }, {
        'url': 'https://space.bilibili.com/313580179/video',
        'info_dict': {
            'id': '313580179',
        },
        'playlist_mincount': 92,
    }]

    def _extract_signature(self, playlist_id):
        session_data = self._download_json('https://api.bilibili.com/x/web-interface/nav', playlist_id, fatal=False)