]> jfr.im git - yt-dlp.git/commitdiff
[extractor/sonyliv] Fix login with token (#7223)
authorbashonly <redacted>
Sun, 4 Jun 2023 13:49:10 +0000 (08:49 -0500)
committerGitHub <redacted>
Sun, 4 Jun 2023 13:49:10 +0000 (13:49 +0000)
Authored by: bashonly

yt_dlp/extractor/sonyliv.py

index aaad420f12f0472fc8893e258b3ef74ffba8e490..5ebe20df7aa2e621c7b1eae0bfd010b889f8f75a 100644 (file)
@@ -10,6 +10,8 @@
 from ..utils import (
     ExtractorError,
     int_or_none,
+    jwt_decode_hs256,
+    try_call,
     try_get,
 )
 
@@ -77,8 +79,10 @@ def _perform_login(self, username, password):
         self._HEADERS['device_id'] = self._get_device_id()
         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.report_login()
+            return
         elif len(username) != 10 or not username.isdigit():
             raise ExtractorError(f'Invalid username/password; {self._LOGIN_HINT}')