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

Code before:
        'playlist_mincount': 15
    }, {
        'url': 'https://allstar.gg/u/62b8bdfc9021052f7905882d?view=Montages',
        'info_dict': {
            'id': '62b8bdfc9021052f7905882d',
            'title': 'cherokee - Montages',
        },
        'playlist_mincount': 4
    }, {
        'url': 'https://allstar.gg/profile?user=cherokee&view=Mobile Clips',
        'info_dict': {
            'id': '62b8bdfc9021052f7905882d',
            'title': 'cherokee - Mobile Clips',
        },
        'playlist_mincount': 1
    }]

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

        for video_data in self._send_query(
                _QUERIES.get(query_id), {
                    'user': user_id,
                    'page': page_num,
                    'game': int_or_none(game),
                }, ('data', 'videos', 'data'), f'{user_id} page {page_num}'):
            yield _set_webpage_url(_parse_video_data(video_data))

    def _get_user_data(self, user_id, path=()):
        return traverse_obj(
            self._download_json(
                urljoin('https://api.allstar.gg/v1/users/profile/', user_id),
                user_id), path)

    def _real_extract(self, url):
        user_id = self._match_id(url)
        user_id, user_name = self._get_user_data(
            user_id, ('data', ('_id', ('profile', 'username'))))
        url_query = parse_qs(url)
        game = traverse_obj(url_query, ('game', 0, {str_or_none}))
        view = traverse_obj(url_query, ('view', 0, {str_or_none}), default='Clips')
        query_id = view.lower()

        if query_id not in ('clips', 'montages', 'mobile clips'):
            raise UnsupportedError(f'view={view}')

        assert query_id in _QUERIES

        return self.playlist_result(
            OnDemandPagedList(
                functools.partial(

Review comment (bug):
Setting the video_id to `f'{user_id} page {page_num}'`, seems wrong.
The video_id should stay `user_id`, while the current state can be outputted through the `note` argument of `self._download_json`. I would either generate the note based on the arguments given to `self._send_query` or just add an additional `note` argument.

Code after:
        'info_dict': {
            'id': '62b8bdfc9021052f7905882d-mobile',
            'title': 'cherokee - Mobile Clips',
        },
        'playlist_mincount': 1
    }]

    _PAGE_SIZE = 10

    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=' - '))