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

Code before:
                    if matches is None:
                        video_list_processed = video_list_processed[:idx]
                        should_brk = True
                        break

            entries += video_list_processed
            if(len(entries) >= n or len(entries) >= BilibiliCategoryIE._MAX_RESULTS) or should_brk:
                break

        return {
            '_type': 'playlist',
            'id': query,
            'entries': entries[:n]
        }

    @classmethod
    def _make_valid_url(cls):
        return cls._VALID_URL

    def _real_extract(self, url):
        u = compat_urllib_parse_urlparse(url)
        category = u.path.split("/")[2]
        subcategory = u.path.split("/")[3]
        count_items_to_fetch = int(self.get_param("playlist_end")) if self.get_param("playlist_end") else self._MAX_RESULTS

        return self._get_n_results(category, subcategory, count_items_to_fetch, self.get_param("match_filter"))


class BiliBiliSearchIE(SearchInfoExtractor):
    IE_DESC = 'Bilibili video search, "bilisearch" keyword'
    _MAX_RESULTS = 100000
    _SEARCH_KEY = 'bilisearch'
    MAX_NUMBER_OF_RESULTS = 1000

    def _get_n_results(self, query, n):
        """Get a specified number of results for a query"""

        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 {

Review comment (suggestion):
use single quotes e.g.
```suggestion
        category = u.path.split('/')[2]
        subcategory = u.path.split('/')[3]
        count_items_to_fetch = int(self.get_param('playlist_end')) if self.get_param('playlist_end') else self._MAX_RESULTS

        return self._get_n_results(category, subcategory, count_items_to_fetch, self.get_param('match_filter'))
```

Code after:
            self._fetch_page, api_url, num_pages, query), size)

    def _real_extract(self, url):
        u = compat_urllib_parse_urlparse(url)
        category, subcategory = u.path.split('/')[2:4]
        query = '%s: %s' % (category, subcategory)

        return self.playlist_result(self._entries(category, subcategory, query), query, query)


class BiliBiliSearchIE(SearchInfoExtractor):
    IE_DESC = 'Bilibili video search, "bilisearch" keyword'
    _MAX_RESULTS = 100000
    _SEARCH_KEY = 'bilisearch'
    MAX_NUMBER_OF_RESULTS = 1000

    def _get_n_results(self, query, n):
        """Get a specified number of results for a query"""

        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]
                }