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

Code before:
        api_path = update_url_query(ep, {
            'appId': 'be4d79eb8fc7bd008ee82c8ec4ff6fd4',
            'language': 'en',
            'platform': 'WEB',
            'wpf': 'pc',
        })
        wmsgpad = int(time.time() * 1000)
        wmd = base64.b64encode(hmac.HMAC(
            key, f'{api_path[:255]}{wmsgpad}'.encode(), digestmod=hashlib.sha1).digest()).decode()
        headers = {'Content-Type': 'application/json'} if data else {}
        try:
            return self._download_json(
                f'https://global.apis.naver.com/weverse/wevweb{api_path}', video_id, note=note,
                data=data, headers={**self._API_HEADERS, **headers}, query={
                    'wmsgpad': wmsgpad,
                    'wmd': wmd,
                })
        except ExtractorError as e:
            if isinstance(e.cause, HTTPError) and e.cause.status == 401:
                self.raise_login_required(
                    'Session token has expired. Log in again or refresh cookies in browser')
            elif isinstance(e.cause, HTTPError) and e.cause.status == 403:
                if 'Authorization' in self._API_HEADERS:
                    raise ExtractorError('Your account does not have access to this content', expected=True)
                else:
                    self.raise_login_required()
            raise

    def _call_post_api(self, video_id):
        path = '' if 'Authorization' in self._API_HEADERS else '/preview'
        return self._call_api(f'/post/v1.0/post-{video_id}{path}?fieldSet=postV1', video_id)

    def _get_community_id(self, channel):
        return str(self._call_api(
            f'/community/v1.0/communityIdUrlPathByUrlPathArtistCode?keyword={channel}',
            channel, note='Fetching community ID')['communityId'])

    def _get_formats(self, data, video_id):
        formats = traverse_obj(data, ('videos', 'list', lambda _, v: url_or_none(v['source']), {
            'url': 'source',
            'width': ('encodingOption', 'width', {int_or_none}),
            'height': ('encodingOption', 'height', {int_or_none}),
            'vcodec': 'type',
            'vbr': ('bitrate', 'video', {int_or_none}),
            'abr': ('bitrate', 'audio', {int_or_none}),
            'filesize': ('size', {int_or_none}),
            'format_id': ('encodingOption', 'id', {str_or_none}),
        }))

        for stream in traverse_obj(data, ('streams', lambda _, v: v['type'] == 'HLS' and url_or_none(v['source']))):
            query = {}

Review comment (suggestion):
```suggestion
                self.raise_login_required()
```

Code after:
        api_path = update_url_query(ep, {
            'appId': 'be4d79eb8fc7bd008ee82c8ec4ff6fd4',
            'language': 'en',
            'platform': 'WEB',
            'wpf': 'pc',
        })
        wmsgpad = int(time.time() * 1000)
        wmd = base64.b64encode(hmac.HMAC(
            key, f'{api_path[:255]}{wmsgpad}'.encode(), digestmod=hashlib.sha1).digest()).decode()
        headers = {'Content-Type': 'application/json'} if data else {}
        try:
            return self._download_json(
                f'https://global.apis.naver.com/weverse/wevweb{api_path}', video_id, note=note,
                data=data, headers={**self._API_HEADERS, **headers}, query={
                    'wmsgpad': wmsgpad,
                    'wmd': wmd,
                })
        except ExtractorError as e:
            if isinstance(e.cause, HTTPError) and e.cause.status == 401:
                self.raise_login_required(
                    'Session token has expired. Log in again or refresh cookies in browser')
            elif isinstance(e.cause, HTTPError) and e.cause.status == 403:
                if 'Authorization' in self._API_HEADERS:
                    raise ExtractorError('Your account does not have access to this content', expected=True)
                self.raise_login_required()
            raise

    def _call_post_api(self, video_id):
        path = '' if 'Authorization' in self._API_HEADERS else '/preview'
        return self._call_api(f'/post/v1.0/post-{video_id}{path}?fieldSet=postV1', video_id)

    def _get_community_id(self, channel):
        return str(self._call_api(
            f'/community/v1.0/communityIdUrlPathByUrlPathArtistCode?keyword={channel}',
            channel, note='Fetching community ID')['communityId'])

    def _get_formats(self, data, video_id):
        formats = traverse_obj(data, ('videos', 'list', lambda _, v: url_or_none(v['source']), {
            'url': 'source',
            'width': ('encodingOption', 'width', {int_or_none}),
            'height': ('encodingOption', 'height', {int_or_none}),
            'vcodec': 'type',
            'vbr': ('bitrate', 'video', {int_or_none}),
            'abr': ('bitrate', 'audio', {int_or_none}),
            'filesize': ('size', {int_or_none}),
            'format_id': ('encodingOption', 'id', {str_or_none}),
        }))

        for stream in traverse_obj(data, ('streams', lambda _, v: v['type'] == 'HLS' and url_or_none(v['source']))):
            query = {}
            for param in traverse_obj(stream, ('keys', lambda _, v: v['type'] == 'param' and v['name'])):