[extractor/crunchyroll] Better message for premium videos

Closes #6227
This commit is contained in:
pukkandan 2023-02-14 01:06:38 +05:30
parent a9c685453f
commit 44699d10dc
No known key found for this signature in database
GPG Key ID: 7EEE9E1E817D0A39
1 changed files with 10 additions and 3 deletions

View File

@ -20,8 +20,12 @@ class CrunchyrollBaseIE(InfoExtractor):
_NETRC_MACHINE = 'crunchyroll'
params = None
@property
def is_logged_in(self):
return self._get_cookies(self._LOGIN_URL).get('etp_rt')
def _perform_login(self, username, password):
if self._get_cookies(self._LOGIN_URL).get('etp_rt'):
if self.is_logged_in:
return
upsell_response = self._download_json(
@ -46,7 +50,7 @@ class CrunchyrollBaseIE(InfoExtractor):
}).encode('ascii'))
if login_response['code'] != 'ok':
raise ExtractorError('Login failed. Server message: %s' % login_response['message'], expected=True)
if not self._get_cookies(self._LOGIN_URL).get('etp_rt'):
if not self.is_logged_in:
raise ExtractorError('Login succeeded but did not set etp_rt cookie')
def _get_embedded_json(self, webpage, display_id):
@ -157,7 +161,10 @@ class CrunchyrollBetaIE(CrunchyrollBaseIE):
f'{api_domain}/cms/v2{bucket}/episodes/{internal_id}', display_id,
note='Retrieving episode metadata', query=params)
if episode_response.get('is_premium_only') and not episode_response.get('playback'):
raise ExtractorError('This video is for premium members only.', expected=True)
if self.is_logged_in:
raise ExtractorError('This video is for premium members only', expected=True)
else:
self.raise_login_required('This video is for premium members only')
stream_response = self._download_json(
f'{api_domain}{episode_response["__links__"]["streams"]["href"]}', display_id,