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

Code before:
            'thumbnail': r're:^https?://.*\.(jpg|jpeg|png)$',
        },
    }]

    def _real_extract(self, url):
        episode_id = self._match_id(url)
        headers = self.geo_verification_headers()
        webpage = self._download_webpage(url, episode_id, headers=headers)

        if '您所在的地区无法观看本片' in webpage:
            raise GeoRestrictedError('This video is restricted')
        elif '正在观看预览，大会员免费看全片' in webpage:
            self.raise_login_required('This video is for premium members only')

        headers['Referer'] = url

        play_info = (
            self._search_json(
                r'playurlSSRData\s*=', webpage, 'embedded page info', episode_id,
                end_pattern='\n', default=None)
            or self._download_json(
                'https://api.bilibili.com/pgc/player/web/v2/playurl', episode_id,
                'Extracting episode', query={'fnval': 12240, 'ep_id': episode_id},
                headers=headers))

        # play_info can be structured least three different ways, e.g.:
        # 1.) play_info['result']['video_info'] and play_info['code']
        # 2.) play_info['raw']['data']['video_info'] and play_info['code']
        # 3.) play_info['data']['result']['video_info'] and play_info['data']['code']
        # So we need to transform any of the above into a common structure
        status_code = play_info.get('code')
        if 'raw' in play_info:
            play_info = play_info['raw']
        if 'data' in play_info:
            play_info = play_info['data']
        if status_code is None:
            status_code = play_info.get('code')
        if 'result' in play_info:
            play_info = play_info['result']

        geo_blocked = traverse_obj(play_info, (
            'plugins', lambda _, v: v['name'] == 'AreaLimitPanel', 'config', 'is_block', {bool}, any))
        premium_only = status_code == -10403

        video_info = traverse_obj(play_info, ('video_info', {dict})) or {}
        formats = self.extract_formats(video_info)

        if not formats:
            if geo_blocked:
                self.raise_geo_restricted()
            elif premium_only or '成为大会员抢先看' in webpage or '开通大会员观看' in webpage:

Review comment (suggestion):
```suggestion
        # play_info can be structured in at least three different ways, e.g.:
```

Code after:
            'thumbnail': r're:^https?://.*\.(jpg|jpeg|png)$',
        },
    }]

    def _real_extract(self, url):
        episode_id = self._match_id(url)
        headers = self.geo_verification_headers()
        webpage = self._download_webpage(url, episode_id, headers=headers)

        if '您所在的地区无法观看本片' in webpage:
            raise GeoRestrictedError('This video is restricted')
        elif '正在观看预览，大会员免费看全片' in webpage:
            self.raise_login_required('This video is for premium members only')

        headers['Referer'] = url

        play_info = (
            self._search_json(
                r'playurlSSRData\s*=', webpage, 'embedded page info', episode_id,
                end_pattern='\n', default=None)
            or self._download_json(
                'https://api.bilibili.com/pgc/player/web/v2/playurl', episode_id,
                'Extracting episode', query={'fnval': 12240, 'ep_id': episode_id},
                headers=headers))

        # play_info can be structured in at least three different ways, e.g.:
        # 1.) play_info['result']['video_info'] and play_info['code']
        # 2.) play_info['raw']['data']['video_info'] and play_info['code']
        # 3.) play_info['data']['result']['video_info'] and play_info['data']['code']
        # So we need to transform any of the above into a common structure
        status_code = play_info.get('code')
        if 'raw' in play_info:
            play_info = play_info['raw']
        if 'data' in play_info:
            play_info = play_info['data']
        if status_code is None:
            status_code = play_info.get('code')
        if 'result' in play_info:
            play_info = play_info['result']

        geo_blocked = traverse_obj(play_info, (
            'plugins', lambda _, v: v['name'] == 'AreaLimitPanel', 'config', 'is_block', {bool}, any))
        premium_only = status_code == -10403

        video_info = traverse_obj(play_info, ('video_info', {dict})) or {}
        formats = self.extract_formats(video_info)

        if not formats:
            if geo_blocked:
                self.raise_geo_restricted()
            elif premium_only or '成为大会员抢先看' in webpage or '开通大会员观看' in webpage: