refactor: extract common _is_jwt_token_expired to InfoExtractor

This commit is contained in:
Michaël De Boey
2025-03-15 23:56:24 +01:00
parent e67d786c7c
commit 0242090a86
11 changed files with 20 additions and 53 deletions
+1 -3
View File
@@ -1,11 +1,9 @@
import json
import time
from .common import InfoExtractor
from ..utils import (
ExtractorError,
int_or_none,
jwt_decode_hs256,
str_or_none,
traverse_obj,
try_call,
@@ -116,7 +114,7 @@ class QDanceIE(InfoExtractor):
self.raise_login_required()
def _get_auth(self):
if (try_call(lambda: jwt_decode_hs256(self._access_token)['exp']) or 0) <= int(time.time() - 120):
if self._is_jwt_token_expired(self._access_token):
if not self._refresh_token:
raise ExtractorError(
'Cannot refresh access token, login with yt-dlp or refresh cookies in browser')