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

Code before:

        # For m3u8
        m3u8_file = traverse_obj(real_video_json, ('qualities', 'auto'))

        for format in m3u8_file:
            video_url = format.get('url')
            if video_url is None:
                continue
            self.video_format = self._extract_m3u8_formats(video_url, video_id=video_id)
# noqa W293
        episode = f'Episode {episode_order}'

        self._sort_formats(self.video_format)
        return {
            'id': video_id,
            'access_id': access_id,
            'formats': self.video_format,
            'title': videos.get('title'),
            'season': videos.get('season_name'),
            'thumbnail': program_detail.get('thumbnail_image'),
            'description': program_detail.get('description'),
            'episode_number': videos.get('episode_order'),
            'series': program_detail.get('title'),
            'episode': episode,

        }


class NetversePlaylistIE(NetverseBaseIE):
    _VALID_URL = r'https?://(?:\w+\.)?netverse\.id/(?P<type>webseries)/(?P<display_id>[^/?#&]+)'
    _TEST = {
        'url': 'https://netverse.id/webseries/tetangga-masa-gitu',
        'info_dict': {
            'id': 16,
            'title': 'Tetangga Masa Gitu',
        },
        'playlist_mincount': 10,
        'params': {
            'skip_download': True,
        }
    }

    def _real_extract(self, url):
        playlist_data = self.get_required_json(url)

        webseries_info = traverse_obj(playlist_data, ('response', 'webseries_info'))

        videos = traverse_obj(playlist_data, ('response', 'related', 'data'))

        entries = []
        for video in videos:

Review comment (suggestion):
Lots of unnecessary variables. Eg:
```diff
-     'series': program_detail.get('title'),
+     'series': travrse_obj(videos, ('program_detail', 'title')),
```

Code after:
        'skip': 'This video get Geo-blocked for some country'
    }]

    def _real_extract(self, url):
        display_id, sites_type = self._match_valid_url(url).group('display_id', 'type')
        program_json = self._call_api(display_id, sites_type)
        videos = program_json['response']['videos']

        return {
            '_type': 'url_transparent',
            'ie_key': DailymotionIE.ie_key(),
            'url': smuggle_url(videos['dailymotion_url'], {'query': {'embedder': 'https://www.netverse.id'}}),
            'display_id': display_id,
            'title': videos.get('title'),
            'season': videos.get('season_name'),
            'thumbnail': traverse_obj(videos, ('program_detail', 'thumbnail_image')),
            'description': traverse_obj(videos, ('program_detail', 'description')),
            'episode_number': videos.get('episode_order'),
        }


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_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')):