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

Code before:
        entries = []
        pageNumber = 0
        while True:
            pageNumber += 1
            # FIXME
            api_url = "https://api.bilibili.com/x/web-interface/search/type?context=&page=%s&order=pubdate&keyword=%s&duration=0&tids_2=&__refresh__=true&search_type=video&tids=0&highlight=1" % (
                pageNumber, query)
            json_str = self._download_webpage(
                api_url, "None", query={"Search_key": query},
                note='Extracting results from page %s' % pageNumber)
            data = json.loads(json_str)['data']

            # FIXME: this is hideous
            if "result" not in data:
                return {
                    '_type': 'playlist',
                    'id': query,
                    'entries': entries[:n]
                }

            videos = data['result']
            for video in videos:
                e = self.url_result(video['arcurl'], 'BiliBili', compat_str(video['aid']))
                entries.append(e)

            if (len(entries) >= n or len(videos) >= BiliBiliSearchIE.MAX_NUMBER_OF_RESULTS):
                return {
                    '_type': 'playlist',
                    'id': query,
                    'entries': entries[:n]
                }


class BilibiliAudioBaseIE(InfoExtractor):
    def _call_api(self, path, sid, query=None):
        if not query:
            query = {'sid': sid}
        return self._download_json(
            'https://www.bilibili.com/audio/music-service-c/web/' + path,
            sid, query=query)['data']


class BilibiliAudioIE(BilibiliAudioBaseIE):
    _VALID_URL = r'https?://(?:www\.)?bilibili\.com/audio/au(?P<id>\d+)'
    _TEST = {
        'url': 'https://www.bilibili.com/audio/au1003142',
        'md5': 'fec4987014ec94ef9e666d4d158ad03b',
        'info_dict': {
            'id': '1003142',
            'ext': 'm4a',
            'title': '【tsukimi】YELLOW / 神山羊',

Review comment (refactor):
```suggestion
            if len(entries) >= n or len(videos) >= BiliBiliSearchIE.MAX_NUMBER_OF_RESULTS:
```

seems like a lot of this file don't follow our coding conventions

Unless you want to clean up the code in this PR, it may be better to get rid of all these unrelated changes

Code after:
            # FIXME
            api_url = 'https://api.bilibili.com/x/web-interface/search/type?context=&page=%s&order=pubdate&keyword=%s&duration=0&tids_2=&__refresh__=true&search_type=video&tids=0&highlight=1' % (pageNumber, query)
            json_str = self._download_webpage(
                api_url, "None", query={"Search_key": query},
                note='Extracting results from page %s' % pageNumber)
            data = json.loads(json_str)['data']

            # FIXME: this is hideous
            if "result" not in data:
                return {
                    '_type': 'playlist',
                    'id': query,
                    'entries': entries[:n]
                }

            videos = data['result']
            for video in videos:
                e = self.url_result(video['arcurl'], 'BiliBili', compat_str(video['aid']))
                entries.append(e)

            if(len(entries) >= n or len(videos) >= BiliBiliSearchIE.MAX_NUMBER_OF_RESULTS):
                return {
                    '_type': 'playlist',
                    'id': query,
                    'entries': entries[:n]
                }


class BilibiliAudioBaseIE(InfoExtractor):
    def _call_api(self, path, sid, query=None):
        if not query:
            query = {'sid': sid}
        return self._download_json(
            'https://www.bilibili.com/audio/music-service-c/web/' + path,
            sid, query=query)['data']


class BilibiliAudioIE(BilibiliAudioBaseIE):
    _VALID_URL = r'https?://(?:www\.)?bilibili\.com/audio/au(?P<id>\d+)'
    _TEST = {
        'url': 'https://www.bilibili.com/audio/au1003142',
        'md5': 'fec4987014ec94ef9e666d4d158ad03b',
        'info_dict': {
            'id': '1003142',
            'ext': 'm4a',
            'title': '【tsukimi】YELLOW / 神山羊',
            'artist': 'tsukimi',
            'comment_count': int,
            'description': 'YELLOW的mp3版！',
            'duration': 183,
            'subtitles': {