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

Code before:

        if video_url is None or video_id is None:
            return info_dict

        base_name = 'clip' if '/clips/' in video_url else 'montage'
        info_dict['webpage_url'] = f'https://allstar.gg/{base_name}?{base_name}={video_id}'
        info_dict['webpage_url_basename'] = base_name

        return info_dict

    def _get_page(self, user_id, display_id, game, query, page_num):
        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_or_none}))

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

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

        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} - {view}')


Review comment (suggestion):
```suggestion
        profile_data = self._download_json(
            urljoin('https://api.allstar.gg/v1/users/profile/', display_id), display_id)
```

Code after:
        },
        '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=' - '))