1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-07-27 07:38:30 +00:00

use server time

Authored by: bashonly
This commit is contained in:
bashonly 2025-07-13 17:25:32 -05:00
parent 4b268854a7
commit 76d98b7931
No known key found for this signature in database
GPG Key ID: 783F096F253D15B0

View File

@ -41,11 +41,11 @@ class HotStarBaseIE(InfoExtractor):
'x-hs-platform': 'androidtv',
}
def _has_active_subscription(self, cookies):
def _has_active_subscription(self, cookies, server_time):
expiry = traverse_obj(cookies, (
self._TOKEN_NAME, 'value', {jwt_decode_hs256}, 'sub', {json.loads},
'subscriptions', 'in', ..., 'expiry', {parse_iso8601}, all, {max})) or 0
return expiry > time.time()
return expiry > server_time
def _call_api_v1(self, path, *args, **kwargs):
return self._download_json(
@ -60,7 +60,7 @@ def _call_api_impl(self, path, video_id, query, cookies=None, st=None):
response = self._download_json(
f'{self._API_URL_V2}/{path}', video_id, query=query,
headers=filter_dict({
**(self._SUB_HEADERS if self._has_active_subscription(cookies) else self._FREE_HEADERS),
**(self._SUB_HEADERS if self._has_active_subscription(cookies, st) else self._FREE_HEADERS),
'hotstarauth': auth,
'x-hs-usertoken': traverse_obj(cookies, (self._TOKEN_NAME, 'value')),
'x-hs-device-id': traverse_obj(cookies, ('deviceId', 'value')) or str(uuid.uuid4()),