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

Code before:
        return self._download_json(
            f'https://api.netverse.id/medias/api/v2/{self._ENDPOINTS[endpoint]}/{slug}/{season_id}',
            display_id or slug, query=query)

    def _get_comments(self, video_id):
        comment_json = self._download_json(
            f'https://api.netverse.id/mediadetails/api/v3/videos/comments/{video_id}', video_id,
            data=b'', fatal=False, note='Downloading JSON comment metadata') or {}
        last_page_number = traverse_obj(comment_json, ('response', 'comments', 'last_page'))

        for i in range(last_page_number):
            if i == 0:
                comment_data = comment_json
            else:
                comment_data = self._download_json(
                    f'https://api.netverse.id/mediadetails/api/v3/videos/comments/{video_id}', video_id,
                    data=b'', fatal=False, query={'page': i + 1}, note='Downloading JSON comment metadata') or {}
            for comment in traverse_obj(comment_data, ('response', 'comments', 'data', ...)):
                yield {
                    'id': comment.get('_id'),
                    'text': comment.get('comment'),
                    'author_id': comment.get('customer_id'),
                    'author': traverse_obj(comment, ('customer', 'name')),
                    'author_thumbnail': traverse_obj(comment, ('customer', 'profile_picture')),
                }


class NetverseIE(NetverseBaseIE):
    _VALID_URL = r'https?://(?:\w+\.)?netverse\.id/(?P<type>watch|video)/(?P<display_id>[^/?#&]+)'
    _TESTS = [{
        # Watch video
        'url': 'https://www.netverse.id/watch/waktu-indonesia-bercanda-edisi-spesial-lebaran-2016',
        'info_dict': {
            'id': 'k4yhqUwINAGtmHx3NkL',
            'title': 'Waktu Indonesia Bercanda - Edisi Spesial Lebaran 2016',
            'ext': 'mp4',
            'season': 'Season 2016',
            'description': 'md5:d41d8cd98f00b204e9800998ecf8427e',
            'thumbnail': r're:https?://s\d+\.dmcdn\.net/v/[^/]+/x1080',
            'episode_number': 22,
            'episode': 'Episode 22',
            'uploader_id': 'x2ir3vq',
            'age_limit': 0,
            'tags': [],
            'view_count': int,
            'display_id': 'waktu-indonesia-bercanda-edisi-spesial-lebaran-2016',
            'duration': 2990,
            'upload_date': '20210722',
            'timestamp': 1626919804,
            'like_count': int,
            'uploader': 'Net Prime',

Review comment (security):
```suggestion
        last_page_number = None
        for i in itertools.count(1):
            comment_data = self._download_json(
                f'https://api.netverse.id/mediadetails/api/v3/videos/comments/{video_id}',
                video_id, data=b'', fatal=False, query={'page': i},
                note='Downloading JSON comment metadata page {i}') or {}
            yield from traverse_obj(comment_data, ('response', 'comments', 'data', ..., {
                'id': '_id',
                'text': 'comment',
                'author_id': 'customer_id',
                'author': ('customer', 'name'),
                'author_thumbnail': ('customer', 'profile_picture'),
            }))
                
            if not last_page_number:
                last_page_number = traverse_obj(comment_data, ('response', 'comments', 'last_page'))
            if i >= (last_page_number or 0):
                break
```
would avoid code duplication

Code after:

    def _call_api(self, slug, endpoint, query={}, season_id='', display_id=None):
        return self._download_json(
            f'https://api.netverse.id/medias/api/v2/{self._ENDPOINTS[endpoint]}/{slug}/{season_id}',
            display_id or slug, query=query)

    def _get_comments(self, video_id):
        last_page_number = None
        for i in itertools.count(1):
            comment_data = self._download_json(
                f'https://api.netverse.id/mediadetails/api/v3/videos/comments/{video_id}',
                video_id, data=b'', fatal=False, query={'page': i},
                note=f'Downloading JSON comment metadata page {i}') or {}
            yield from traverse_obj(comment_data, ('response', 'comments', 'data', ..., {
                'id': '_id',
                'text': 'comment',
                'author_id': 'customer_id',
                'author': ('customer', 'name'),
                'author_thumbnail': ('customer', 'profile_picture'),
            }))

            if not last_page_number:
                last_page_number = traverse_obj(comment_data, ('response', 'comments', 'last_page'))
            if i >= (last_page_number or 0):
                break


class NetverseIE(NetverseBaseIE):
    _VALID_URL = r'https?://(?:\w+\.)?netverse\.id/(?P<type>watch|video)/(?P<display_id>[^/?#&]+)'
    _TESTS = [{
        # Watch video
        'url': 'https://www.netverse.id/watch/waktu-indonesia-bercanda-edisi-spesial-lebaran-2016',
        'info_dict': {
            'id': 'k4yhqUwINAGtmHx3NkL',
            'title': 'Waktu Indonesia Bercanda - Edisi Spesial Lebaran 2016',
            'ext': 'mp4',
            'season': 'Season 2016',
            'description': 'md5:d41d8cd98f00b204e9800998ecf8427e',
            'thumbnail': r're:https?://s\d+\.dmcdn\.net/v/[^/]+/x1080',
            'episode_number': 22,
            'episode': 'Episode 22',
            'uploader_id': 'x2ir3vq',
            'age_limit': 0,
            'tags': [],
            'view_count': int,
            'display_id': 'waktu-indonesia-bercanda-edisi-spesial-lebaran-2016',
            'duration': 2990,
            'upload_date': '20210722',
            'timestamp': 1626919804,
            'like_count': int,
            'uploader': 'Net Prime',