mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-06-28 09:28:33 +00:00
use jwt_is_expired
in CanalSurmas
extractor
This commit is contained in:
parent
5e1507c39a
commit
825d71efbc
@ -8,7 +8,7 @@
|
|||||||
jwt_decode_hs256,
|
jwt_decode_hs256,
|
||||||
parse_iso8601,
|
parse_iso8601,
|
||||||
url_or_none,
|
url_or_none,
|
||||||
variadic,
|
variadic,jwt_is_expired,
|
||||||
)
|
)
|
||||||
from ..utils.traversal import traverse_obj
|
from ..utils.traversal import traverse_obj
|
||||||
|
|
||||||
@ -31,12 +31,8 @@ class CanalsurmasIE(InfoExtractor):
|
|||||||
_API_BASE = 'https://api-rtva.interactvty.com'
|
_API_BASE = 'https://api-rtva.interactvty.com'
|
||||||
_access_token = None
|
_access_token = None
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def _is_jwt_expired(token):
|
|
||||||
return jwt_decode_hs256(token)['exp'] - time.time() < 300
|
|
||||||
|
|
||||||
def _call_api(self, endpoint, video_id, fields=None):
|
def _call_api(self, endpoint, video_id, fields=None):
|
||||||
if not self._access_token or self._is_jwt_expired(self._access_token):
|
if not self._access_token or jwt_is_expired(self._access_token):
|
||||||
self._access_token = self._download_json(
|
self._access_token = self._download_json(
|
||||||
f'{self._API_BASE}/jwt/token/', None,
|
f'{self._API_BASE}/jwt/token/', None,
|
||||||
'Downloading access token', 'Failed to download access token',
|
'Downloading access token', 'Failed to download access token',
|
||||||
|
Loading…
Reference in New Issue
Block a user