1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-12-22 16:08:58 +00:00

refactor: extract common _is_jwt_token_expired to InfoExtractor

This commit is contained in:
Michaël De Boey
2025-03-06 15:38:53 +01:00
parent e67d786c7c
commit 0242090a86
11 changed files with 20 additions and 53 deletions

View File

@@ -13,7 +13,6 @@ from ..utils import (
get_element_by_class,
get_element_html_by_class,
int_or_none,
jwt_decode_hs256,
jwt_encode_hs256,
make_archive_id,
merge_dicts,
@@ -316,10 +315,6 @@ class VrtNUIE(VRTBaseIE):
# Refresh token cookie is scoped to /vrtmax/sso, others are scoped to /
return try_call(lambda: self._get_cookies('https://www.vrt.be/vrtmax/sso')[cookie_name].value)
@staticmethod
def _is_jwt_token_expired(token):
return jwt_decode_hs256(token)['exp'] - time.time() < 300
def _perform_login(self, username, password):
refresh_token = self._get_vrt_cookie(self._REFRESH_TOKEN_COOKIE_NAME)
if refresh_token and not self._is_jwt_token_expired(refresh_token):