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

Code before:
        page_num += 1

        for video_data in self._send_query(
                query, {
                    'user': user_id,
                    'page': page_num,
                    'game': game,
                }, ('data', 'videos', 'data'), display_id, f'Downloading page {page_num}'):
            yield self._set_webpage_url(self._parse_video_data(video_data))

    def _real_extract(self, url):
        display_id = self._match_id(url)
        profile_data = self._download_json(
            urljoin('https://api.allstar.gg/v1/users/profile/', display_id), display_id)
        user_id = traverse_obj(profile_data, ('data', ('_id'), {str}))

        if user_id is None:
            raise ExtractorError('Can not extract the user_id')

        username = traverse_obj(profile_data, ('data', 'profile', ('username'), {str}))
        url_query = parse_qs(url)
        game = traverse_obj(url_query, ('game', 0, {int}))
        query_id = traverse_obj(url_query, ('view', 0), default='Clips')

        if query_id not in ('Clips', 'Montages', 'Mobile Clips'):
            raise UnsupportedError(url)

        return self.playlist_result(
            OnDemandPagedList(
                functools.partial(
                    self._get_page, user_id, display_id, game, _QUERIES.get(query_id)), self._PAGE_SIZE),
            user_id, f'{username or display_id} - {query_id}')


Review comment (refactor):
Since we are matching the URL, imo this is more appropriate
```suggestion
        if query_id not in ('Clips', 'Montages', 'Mobile Clips'):
            raise ExtractorError(f'Unsupported playlist URL type {query_id!r}')
```

Code after:

    def _get_page(self, user_id, display_id, game, query, page_num):
        page_num += 1

        for video_data in self._call_api(
                query, {
                    'user': user_id,
                    'page': page_num,
                    'game': game,
                }, ('data', 'videos', 'data'), display_id, f'Downloading page {page_num}'):
            yield self._parse_video_data(video_data)

    def _real_extract(self, url):
        display_id = self._match_id(url)
        profile_data = self._download_json(
            urljoin('https://api.allstar.gg/v1/users/profile/', display_id), display_id)
        user_id = traverse_obj(profile_data, ('data', ('_id'), {str}))
        if not user_id:
            raise ExtractorError('Unable to extract the user id')

        username = traverse_obj(profile_data, ('data', 'profile', ('username'), {str}))
        url_query = parse_qs(url)
        game = traverse_obj(url_query, ('game', 0, {int_or_none}))
        query_id = traverse_obj(url_query, ('view', 0), default='Clips')

        if query_id not in ('Clips', 'Montages', 'Mobile Clips'):
            raise ExtractorError(f'Unsupported playlist URL type {query_id!r}')

        return self.playlist_result(
            OnDemandPagedList(
                functools.partial(
                    self._get_page, user_id, display_id, game, _QUERIES.get(query_id)), self._PAGE_SIZE),
            playlist_id=join_nonempty(user_id, query_id.lower().split()[0], game),
            playlist_title=join_nonempty((username or display_id), query_id, game, delim=' - '))