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

Code before:
        aid = episode_info.get('aid')

        return {
            'id': video_id,
            'formats': formats,
            **traverse_obj(bangumi_info, {
                'series': ('series', 'series_title', {str}),
                'series_id': ('series', 'series_id', {str_or_none}),
                'thumbnail': ('square_cover', {url_or_none}),
            }),
            'title': join_nonempty('title', 'long_title', delim=' ', from_dict=episode_info),
            'episode': episode_info.get('long_title'),
            'episode_id': episode_id,
            'episode_number': int_or_none(episode_info.get('title')) or episode_number,
            'season_id': str_or_none(season_id),
            'season_number': season_number,
            'timestamp': int_or_none(episode_info.get('pub_time')),
            'duration': float_or_none(play_info.get('timelength'), scale=1000),
            'subtitles': self.extract_subtitles(video_id, aid, episode_info.get('cid')),
            '__post_extractor': self.extract_comments(aid),
            'http_headers': headers,
        }


class BiliBiliBangumiMediaIE(BilibiliBaseIE):
    _VALID_URL = r'https?://www\.bilibili\.com/bangumi/media/md(?P<id>\d+)/?(?:$|[#?])'
    _TESTS = [{
        'url': 'https://www.bilibili.com/bangumi/media/md24097891',
        'info_dict': {
            'id': '24097891',
        },
        'playlist_mincount': 25,
    }]

    def _real_extract(self, url):
        media_id = self._match_id(url)
        webpage = self._download_webpage(url, media_id)
        ss_id = self._search_json(
            r'window\.__INITIAL_STATE__\s*=', webpage, 'initial_state', media_id)['mediaInfo']['season_id']

        return self.playlist_result(self._get_episodes_from_season(ss_id, url), media_id)


class BiliBiliBangumiSeasonIE(BilibiliBaseIE):
    _VALID_URL = r'(?x)https?://www\.bilibili\.com/bangumi/play/ss(?P<id>\d+)/?(?:$|[#?])'
    _TESTS = [{
        'url': 'https://www.bilibili.com/bangumi/play/ss26801',
        'info_dict': {
            'id': '26801'
        },
        'playlist_mincount': 26

Review comment (suggestion):
```suggestion
    _VALID_URL = r'https?://www\.bilibili\.com/bangumi/media/md(?P<id>\d+)'
```

Code after:

        return {
            'id': video_id,
            'formats': formats,
            **traverse_obj(bangumi_info, {
                'series': ('series', 'series_title', {str}),
                'series_id': ('series', 'series_id', {str_or_none}),
                'thumbnail': ('square_cover', {url_or_none}),
            }),
            'title': join_nonempty('title', 'long_title', delim=' ', from_dict=episode_info),
            'episode': episode_info.get('long_title'),
            'episode_id': episode_id,
            'episode_number': int_or_none(episode_info.get('title')) or episode_number,
            'season_id': str_or_none(season_id),
            'season_number': season_number,
            'timestamp': int_or_none(episode_info.get('pub_time')),
            'duration': float_or_none(play_info.get('timelength'), scale=1000),
            'subtitles': self.extract_subtitles(video_id, aid, episode_info.get('cid')),
            '__post_extractor': self.extract_comments(aid),
            'http_headers': headers,
        }


class BiliBiliBangumiMediaIE(BilibiliBaseIE):
    _VALID_URL = r'https?://www\.bilibili\.com/bangumi/media/md(?P<id>\d+)'
    _TESTS = [{
        'url': 'https://www.bilibili.com/bangumi/media/md24097891',
        'info_dict': {
            'id': '24097891',
        },
        'playlist_mincount': 25,
    }]

    def _real_extract(self, url):
        media_id = self._match_id(url)
        webpage = self._download_webpage(url, media_id)
        ss_id = self._search_json(
            r'window\.__INITIAL_STATE__\s*=', webpage, 'initial_state', media_id)['mediaInfo']['season_id']

        return self.playlist_result(self._get_episodes_from_season(ss_id, url), media_id)


class BiliBiliBangumiSeasonIE(BilibiliBaseIE):
    _VALID_URL = r'(?x)https?://www\.bilibili\.com/bangumi/play/ss(?P<id>\d+)'
    _TESTS = [{
        'url': 'https://www.bilibili.com/bangumi/play/ss26801',
        'info_dict': {
            'id': '26801'
        },
        'playlist_mincount': 26
    }]