1
1
mirror of https://github.com/ytdl-org/youtube-dl synced 2024-11-09 05:37:09 +01:00
This commit is contained in:
Dev Bali 2024-07-28 01:25:58 +09:00 committed by GitHub
commit d88d8dc0d8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -33,6 +33,7 @@ class HotStarBaseIE(InfoExtractor):
auth += '~hmac=' + hmac.new(self._AKAMAI_ENCRYPTION_KEY, auth.encode(), hashlib.sha256).hexdigest()
h = {'hotstarauth': auth}
h.update(headers)
return self._download_json(
'https://api.hotstar.com/' + path,
video_id, headers=h, query=query, data=data)
@ -59,7 +60,8 @@ class HotStarBaseIE(InfoExtractor):
except ExtractorError as e:
if isinstance(e.cause, compat_HTTPError):
if e.cause.code == 402:
self.raise_login_required()
raise ExtractorError('This video is only available for registered users. You may want to use --cookies.', expected=True)
message = self._parse_json(e.cause.read().decode(), video_id)['message']
if message in ('Content not available in region', 'Country is not supported'):
raise self.raise_geo_restricted(message)
@ -135,6 +137,13 @@ class HotStarIE(HotStarBaseIE):
formats = []
geo_restricted = False
for cookie in self._downloader.cookiejar:
if "hotstar" in cookie.domain:
if cookie.name == "userUP":
self._USER_TOKEN = cookie.value
elif cookie.name == "device-id":
self._DEVICE_ID = cookie.value
if not self._USER_TOKEN:
self._DEVICE_ID = compat_str(uuid.uuid4())
self._USER_TOKEN = self._call_api_v2('um/v3/users', video_id, {