diff --git a/yt_dlp/extractor/cbc.py b/yt_dlp/extractor/cbc.py index 527bfe03dd..d7cb3ebfb6 100644 --- a/yt_dlp/extractor/cbc.py +++ b/yt_dlp/extractor/cbc.py @@ -653,7 +653,7 @@ def _perform_login(self, username, password): raise def _fetch_access_token(self): - if self._is_jwt_token_expired(self._access_token): + if self._jwt_is_expired(self._access_token): try: self._call_oauth_api({ 'grant_type': 'refresh_token', @@ -671,7 +671,7 @@ def _fetch_claims_token(self): if not self._get_login_info()[0]: return None - if not self._claims_token or self._is_jwt_token_expired(self._claims_token): + if not self._claims_token or self._jwt_is_expired(self._claims_token): self._claims_token = self._download_json( 'https://services.radio-canada.ca/ott/subscription/v2/gem/Subscriber/profile', None, 'Downloading claims token', query={'device': 'web'}, diff --git a/yt_dlp/extractor/common.py b/yt_dlp/extractor/common.py index 3ae318c18a..84bdea80bf 100644 --- a/yt_dlp/extractor/common.py +++ b/yt_dlp/extractor/common.py @@ -996,7 +996,7 @@ def _guess_encoding_from_content(content_type, webpage_bytes): return encoding @staticmethod - def _is_jwt_token_expired(token): + def _jwt_is_expired(token): return jwt_decode_hs256(token)['exp'] - time.time() < 300 def __check_blocked(self, content): diff --git a/yt_dlp/extractor/digitalconcerthall.py b/yt_dlp/extractor/digitalconcerthall.py index bc876ad5d1..a19b96a66d 100644 --- a/yt_dlp/extractor/digitalconcerthall.py +++ b/yt_dlp/extractor/digitalconcerthall.py @@ -86,7 +86,7 @@ class DigitalConcertHallIE(InfoExtractor): @property def _access_token_is_expired(self): - return self._is_jwt_token_expired(self._access_token) + return self._jwt_is_expired(self._access_token) def _set_access_token(self, value): self._access_token = value diff --git a/yt_dlp/extractor/iwara.py b/yt_dlp/extractor/iwara.py index 882789cf4e..32c5aea891 100644 --- a/yt_dlp/extractor/iwara.py +++ b/yt_dlp/extractor/iwara.py @@ -22,7 +22,7 @@ class IwaraBaseIE(InfoExtractor): def _is_token_expired(self, token, token_type): # User token TTL == ~3 weeks, Media token TTL == ~1 hour - if self._is_jwt_token_expired(token): + if self._jwt_is_expired(token): self.to_screen(f'{token_type} token has expired') return True diff --git a/yt_dlp/extractor/jiocinema.py b/yt_dlp/extractor/jiocinema.py index a4db9d47c9..3d9957f5f5 100644 --- a/yt_dlp/extractor/jiocinema.py +++ b/yt_dlp/extractor/jiocinema.py @@ -106,7 +106,7 @@ def _call_login_api(self, endpoint, guest_token, data, note): })}, data=data) def _perform_login(self, username, password): - if self._ACCESS_TOKEN and not self._is_jwt_token_expired(self._ACCESS_TOKEN): + if self._ACCESS_TOKEN and not self._jwt_is_expired(self._ACCESS_TOKEN): return UUID_RE = r'[\da-f]{8}-(?:[\da-f]{4}-){3}[\da-f]{12}' @@ -181,7 +181,7 @@ def _perform_login(self, username, password): if JioCinemaBaseIE._REFRESH_TOKEN: self._cache_token('access') self.to_screen(f'Logging in as device ID "{JioCinemaBaseIE._DEVICE_ID}"') - if self._is_jwt_token_expired(JioCinemaBaseIE._ACCESS_TOKEN): + if self._jwt_is_expired(JioCinemaBaseIE._ACCESS_TOKEN): self._refresh_token() @@ -246,9 +246,9 @@ def _extract_formats_and_subtitles(self, playback, video_id): def _real_extract(self, url): video_id = self._match_id(url) - if not self._ACCESS_TOKEN and self._is_jwt_token_expired(self._GUEST_TOKEN): + if not self._ACCESS_TOKEN and self._jwt_is_expired(self._GUEST_TOKEN): self._fetch_guest_token() - elif self._ACCESS_TOKEN and self._is_jwt_token_expired(self._ACCESS_TOKEN): + elif self._ACCESS_TOKEN and self._jwt_is_expired(self._ACCESS_TOKEN): self._refresh_token() playback = self._call_api( diff --git a/yt_dlp/extractor/mlb.py b/yt_dlp/extractor/mlb.py index 61b56817ea..c8f4fcf7e8 100644 --- a/yt_dlp/extractor/mlb.py +++ b/yt_dlp/extractor/mlb.py @@ -351,7 +351,7 @@ class MLBTVIE(InfoExtractor): @property def _api_headers(self): - if self._is_jwt_token_expired(self._access_token): + if self._jwt_is_expired(self._access_token): self.write_debug('Access token has expired; re-logging in') self._perform_login(*self._get_login_info()) return {'Authorization': f'Bearer {self._access_token}'} diff --git a/yt_dlp/extractor/qdance.py b/yt_dlp/extractor/qdance.py index 680da2cf52..3faab0465e 100644 --- a/yt_dlp/extractor/qdance.py +++ b/yt_dlp/extractor/qdance.py @@ -114,7 +114,7 @@ def _real_initialize(self): self.raise_login_required() def _get_auth(self): - if self._is_jwt_token_expired(self._access_token): + if self._jwt_is_expired(self._access_token): if not self._refresh_token: raise ExtractorError( 'Cannot refresh access token, login with yt-dlp or refresh cookies in browser') diff --git a/yt_dlp/extractor/stacommu.py b/yt_dlp/extractor/stacommu.py index 26710a140b..c9489763ea 100644 --- a/yt_dlp/extractor/stacommu.py +++ b/yt_dlp/extractor/stacommu.py @@ -20,7 +20,7 @@ class StacommuBaseIE(WrestleUniverseBaseIE): @WrestleUniverseBaseIE._TOKEN.getter def _TOKEN(self): - if self._REAL_TOKEN and self._is_jwt_token_expired(self._REAL_TOKEN): + if self._REAL_TOKEN and self._jwt_is_expired(self._REAL_TOKEN): self._refresh_token() return self._REAL_TOKEN diff --git a/yt_dlp/extractor/vrt.py b/yt_dlp/extractor/vrt.py index 5c945d2065..4b9fe39445 100644 --- a/yt_dlp/extractor/vrt.py +++ b/yt_dlp/extractor/vrt.py @@ -272,15 +272,15 @@ def _fetch_tokens(self): access_token = self._get_vrt_cookie(self._ACCESS_TOKEN_COOKIE_NAME) video_token = self._get_vrt_cookie(self._VIDEO_TOKEN_COOKIE_NAME) - if (access_token and not self._is_jwt_token_expired(access_token) - and video_token and not self._is_jwt_token_expired(video_token)): + if (access_token and not self._jwt_is_expired(access_token) + and video_token and not self._jwt_is_expired(video_token)): return access_token, video_token if has_credentials: access_token, video_token = self.cache.load(self._NETRC_MACHINE, 'token_data', default=(None, None)) - if (access_token and not self._is_jwt_token_expired(access_token) - and video_token and not self._is_jwt_token_expired(video_token)): + if (access_token and not self._jwt_is_expired(access_token) + and video_token and not self._jwt_is_expired(video_token)): self.write_debug('Restored tokens from cache') self._set_cookie(self._TOKEN_COOKIE_DOMAIN, self._ACCESS_TOKEN_COOKIE_NAME, access_token) self._set_cookie(self._TOKEN_COOKIE_DOMAIN, self._VIDEO_TOKEN_COOKIE_NAME, video_token) @@ -317,12 +317,12 @@ def _get_vrt_cookie(self, cookie_name): 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): + if refresh_token and not self._jwt_is_expired(refresh_token): self.write_debug('Using refresh token from logged-in cookies; skipping login with credentials') return refresh_token = self.cache.load(self._NETRC_MACHINE, 'refresh_token', default=None) - if refresh_token and not self._is_jwt_token_expired(refresh_token): + if refresh_token and not self._jwt_is_expired(refresh_token): self.write_debug('Restored refresh token from cache') self._set_cookie(self._TOKEN_COOKIE_DOMAIN, self._REFRESH_TOKEN_COOKIE_NAME, refresh_token, path='/vrtmax/sso') return diff --git a/yt_dlp/extractor/wrestleuniverse.py b/yt_dlp/extractor/wrestleuniverse.py index 3a9293f44f..47193a2e86 100644 --- a/yt_dlp/extractor/wrestleuniverse.py +++ b/yt_dlp/extractor/wrestleuniverse.py @@ -43,7 +43,7 @@ def _TOKEN(self): self.raise_login_required() self._TOKEN = token - if not self._REAL_TOKEN or self._is_jwt_token_expired(self._REAL_TOKEN): + if not self._REAL_TOKEN or self._jwt_is_expired(self._REAL_TOKEN): if not self._REFRESH_TOKEN: raise ExtractorError( 'Expired token. Refresh your cookies in browser and try again', expected=True) diff --git a/yt_dlp/extractor/zee5.py b/yt_dlp/extractor/zee5.py index dc975d05a4..02cd2a77b8 100644 --- a/yt_dlp/extractor/zee5.py +++ b/yt_dlp/extractor/zee5.py @@ -123,7 +123,7 @@ def _perform_login(self, username, password): else: raise ExtractorError(self._LOGIN_HINT, expected=True) - if self._is_jwt_token_expired(self._USER_TOKEN): + if self._jwt_is_expired(self._USER_TOKEN): raise ExtractorError('User token has expired', expected=True) self._USER_COUNTRY = jwt_decode_hs256(self._USER_TOKEN).get('current_country')