[extractor/sonyliv] Fix login with token (#7223)

Authored by: bashonly
This commit is contained in:
bashonly 2023-06-04 08:49:10 -05:00 committed by GitHub
parent 97d60ad8cd
commit 4815d35c19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,6 +10,8 @@
from ..utils import ( from ..utils import (
ExtractorError, ExtractorError,
int_or_none, int_or_none,
jwt_decode_hs256,
try_call,
try_get, try_get,
) )
@ -77,8 +79,10 @@ def _perform_login(self, username, password):
self._HEADERS['device_id'] = self._get_device_id() self._HEADERS['device_id'] = self._get_device_id()
self._HEADERS['content-type'] = 'application/json' self._HEADERS['content-type'] = 'application/json'
if username.lower() == 'token' and len(password) > 1198: if username.lower() == 'token' and try_call(lambda: jwt_decode_hs256(password)):
self._HEADERS['authorization'] = password self._HEADERS['authorization'] = password
self.report_login()
return
elif len(username) != 10 or not username.isdigit(): elif len(username) != 10 or not username.isdigit():
raise ExtractorError(f'Invalid username/password; {self._LOGIN_HINT}') raise ExtractorError(f'Invalid username/password; {self._LOGIN_HINT}')