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 -5
View File
@@ -1,5 +1,3 @@
import time
from .common import InfoExtractor
from ..networking.exceptions import HTTPError
from ..utils import (
@@ -84,16 +82,14 @@ class DigitalConcertHallIE(InfoExtractor):
'User-Agent': _USER_AGENT,
}
_access_token = None
_access_token_expiry = 0
_refresh_token = None
@property
def _access_token_is_expired(self):
return self._access_token_expiry - 30 <= int(time.time())
return self._is_jwt_token_expired(self._access_token)
def _set_access_token(self, value):
self._access_token = value
self._access_token_expiry = traverse_obj(value, ({jwt_decode_hs256}, 'exp', {int})) or 0
def _cache_tokens(self, /):
self.cache.store(self._NETRC_MACHINE, 'tokens', {