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

Code before:
                                                       None, note="Sending OTP")
                if otp_request_json['code'] == 0:
                    self.to_screen(otp_request_json['message'])
                else:
                    raise ExtractorError(otp_request_json['message'], expected=True)
                otp_code = self._get_tfa_info('OTP')
                otp_verify_json = self._download_json('https://b2bapi.zee5.com/device/verifyotp_v1.php?phoneno=91{}&otp={}&guest_token={}&platform=web'.format(username, otp_code, self._DEVICE_ID),
                                                      None, note="Verifying OTP", fatal=False)
                if not otp_verify_json:
                    raise ExtractorError('Unable to verify OTP.', expected=True)
                self._USER_TOKEN = otp_verify_json.get('token')
                if not self._USER_TOKEN:
                    raise ExtractorError(otp_request_json['message'], expected=True)
            elif username.lower() == 'token' and len(password) > 1198:
                self._USER_TOKEN = password

    def _real_initialize(self):
        self._login()

    def _real_extract(self, url):
        video_id, display_id = re.match(self._VALID_URL, url).group('id', 'display_id')
        access_token_request = self._download_json(
            'https://useraction.zee5.com/token/platform_tokens.php?platform_name=web_app',
            video_id, note='Downloading access token')
        data = {
            "x-access-token": access_token_request['token']
        }
        if self._USER_TOKEN:
            data['Authorization'] = 'bearer %s' % self._USER_TOKEN
        else:
            data['X-Z5-Guest-Token'] = self._DEVICE_ID

        json_data = self._download_json(
            self._DETAIL_API_URL.format(video_id, self._DEVICE_ID),
            video_id, headers={'content-type': 'application/json'}, data=json.dumps(data).encode('utf-8'))
        asset_data = json_data['assetDetails']
        show_data = json_data.get('showDetails', {})
        if 'premium' in asset_data['business_type']:
            raise ExtractorError('Premium content is DRM protected.', expected=True)
        if not asset_data.get('hls_url'):
            self.raise_login_required(self._LOGIN_HINT, metadata_available=True, method=None)
        formats, m3u8_subs = self._extract_m3u8_formats_and_subtitles(asset_data['hls_url'], video_id, 'mp4', fatal=False)
        self._sort_formats(formats)

        subtitles = {}
        for sub in asset_data.get('subtitle_url', []):
            sub_url = sub.get('url')
            if not sub_url:
                continue
            subtitles.setdefault(sub.get('language', 'en'), []).append({
                'url': self._proto_relative_url(sub_url),

Review comment (suggestion):
```suggestion
            'x-access-token': access_token_request['token']
```

Code after:
                                                       None, note='Sending OTP')
                if otp_request_json['code'] == 0:
                    self.to_screen(otp_request_json['message'])
                else:
                    raise ExtractorError(otp_request_json['message'], expected=True)
                otp_code = self._get_tfa_info('OTP')
                otp_verify_json = self._download_json('https://b2bapi.zee5.com/device/verifyotp_v1.php?phoneno=91{}&otp={}&guest_token={}&platform=web'.format(username, otp_code, self._DEVICE_ID),
                                                      None, note='Verifying OTP', fatal=False)
                if not otp_verify_json:
                    raise ExtractorError('Unable to verify OTP.', expected=True)
                self._USER_TOKEN = otp_verify_json.get('token')
                if not self._USER_TOKEN:
                    raise ExtractorError(otp_request_json['message'], expected=True)
            elif username.lower() == 'token' and len(password) > 1198:
                self._USER_TOKEN = password

    def _real_initialize(self):
        self._login()

    def _real_extract(self, url):
        video_id, display_id = re.match(self._VALID_URL, url).group('id', 'display_id')
        access_token_request = self._download_json(
            'https://useraction.zee5.com/token/platform_tokens.php?platform_name=web_app',
            video_id, note='Downloading access token')
        data = {
            'x-access-token': access_token_request['token']
        }
        if self._USER_TOKEN:
            data['Authorization'] = 'bearer %s' % self._USER_TOKEN
        else:
            data['X-Z5-Guest-Token'] = self._DEVICE_ID

        json_data = self._download_json(
            self._DETAIL_API_URL.format(video_id, self._DEVICE_ID),
            video_id, headers={'content-type': 'application/json'}, data=json.dumps(data).encode('utf-8'))
        asset_data = json_data['assetDetails']
        show_data = json_data.get('showDetails', {})
        if 'premium' in asset_data['business_type']:
            raise ExtractorError('Premium content is DRM protected.', expected=True)
        if not asset_data.get('hls_url'):
            self.raise_login_required(self._LOGIN_HINT, metadata_available=True, method=None)
        formats, m3u8_subs = self._extract_m3u8_formats_and_subtitles(asset_data['hls_url'], video_id, 'mp4', fatal=False)
        self._sort_formats(formats)

        subtitles = {}
        for sub in asset_data.get('subtitle_url', []):
            sub_url = sub.get('url')
            if not sub_url:
                continue
            subtitles.setdefault(sub.get('language', 'en'), []).append({
                'url': self._proto_relative_url(sub_url),