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

use filter_dict

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

View File

@ -12,6 +12,7 @@
ExtractorError,
OnDemandPagedList,
determine_ext,
filter_dict,
int_or_none,
join_nonempty,
jwt_decode_hs256,
@ -58,13 +59,13 @@ def _call_api_impl(self, path, video_id, query, cookies=None, st=None):
auth += '~hmac=' + hmac.new(self._AKAMAI_ENCRYPTION_KEY, auth.encode(), hashlib.sha256).hexdigest()
response = self._download_json(
f'{self._API_URL_V2}/{path}', video_id, query=query,
headers={
headers=filter_dict({
**(self._SUB_HEADERS if self._has_active_subscription(cookies) 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()),
'content-type': 'application/json',
})
}))
if not traverse_obj(response, ('success', {dict})):
raise ExtractorError('API call was unsuccessful')