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

Code before:
class NetversePlaylistIE(NetverseBaseIE):
    _VALID_URL = r'https?://(?:\w+\.)?netverse\.id/(?P<type>webseries)/(?P<display_id>[^/?#&]+)'
    _TESTS = [{
        # multiple season
        'url': 'https://netverse.id/webseries/tetangga-masa-gitu',
        'info_dict': {
            'id': 'tetangga-masa-gitu',
            'title': 'Tetangga Masa Gitu',
        },
        'playlist_count': 519,
    }, {
        # single season
        'url': 'https://netverse.id/webseries/kelas-internasional',
        'info_dict': {
            'id': 'kelas-internasional',
            'title': 'Kelas Internasional',
        },
        'playlist_count': 203,
    }]

    def parse_single_season_playlist(self, page_num, url=None, slug=None, custom_id=None, season_id='',
                                     endpoint=None):

        _, playlist_json = self._call_api(
            url=url, slug=slug, query={'page': page_num + 1}, season=season_id, custom_id=custom_id,
            endpoint=endpoint)
        for slug in traverse_obj(playlist_json, ('response', ..., 'data', ..., 'slug')):
            yield self.url_result(f'https://www.netverse.id/video/{slug}', NetverseIE)

    def parse_playlist(self, url, json_data, playlist_id):
        slug_sample = traverse_obj(json_data, ('related', 'data', ..., 'slug'))[0]
        season_id_list = [season.get('id') for season in json_data.get('seasons')]

        for season in season_id_list:
            _, playlist_json = self._call_api(
                slug=slug_sample, custom_id=playlist_id, season=season,
                endpoint='season')

            season_list = traverse_obj(playlist_json, ('response', 'season_list'))

            current_page = 0
            while current_page < season_list.get('last_page'):
                yield from self.parse_single_season_playlist(
                    current_page, slug=slug_sample, custom_id=playlist_id, season_id=season,
                    endpoint='season')
                current_page = current_page + 1

    def _real_extract(self, url):
        playlist_id, playlist_data = self._call_api(url)
        return self.playlist_result(
            self.parse_playlist(url, playlist_data['response'], playlist_id),

Review comment (suggestion):
```suggestion
        _, playlist_json = self._call_api(
            url=url, slug=slug, query={'page': page_num + 1},
            season=season_id, custom_id=custom_id, endpoint=endpoint)
```

Code after:
            'id': 'kelas-internasional',
            'title': 'Kelas Internasional',
        },
        'playlist_count': 203,
    }]

    def parse_playlist(self, json_data, playlist_id):
        slug_sample = traverse_obj(json_data, ('related', 'data', ..., 'slug'))[0]
        for season in traverse_obj(json_data, ('seasons', ..., 'id')):
            playlist_json = self._call_api(
                slug_sample, 'season', display_id=playlist_id, season_id=season)

            for current_page in range(playlist_json['response']['season_list']['last_page']):
                playlist_json = self._call_api(slug_sample, 'season', query={'page': current_page + 1},
                                               season_id=season, display_id=playlist_id)
                for slug in traverse_obj(playlist_json, ('response', ..., 'data', ..., 'slug')):
                    yield self.url_result(f'https://www.netverse.id/video/{slug}', NetverseIE)

    def _real_extract(self, url):
        playlist_id, sites_type = self._match_valid_url(url).group('display_id', 'type')
        playlist_data = self._call_api(playlist_id, sites_type)

        return self.playlist_result(
            self.parse_playlist(playlist_data['response'], playlist_id),
            traverse_obj(playlist_data, ('response', 'webseries_info', 'slug')),
            traverse_obj(playlist_data, ('response', 'webseries_info', 'title')))