mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2026-05-22 15:22:24 +00:00
Compare commits
No commits in common. "5e292baad62c749b6c340621ab2d0f904165ddfb" and "06c1a8cdffe14050206683253726875144192ef5" have entirely different histories.
5e292baad6
...
06c1a8cdff
@ -1,5 +1,6 @@
|
|||||||
import hashlib
|
import hashlib
|
||||||
import hmac
|
import hmac
|
||||||
|
import json
|
||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
import uuid
|
import uuid
|
||||||
@ -28,20 +29,31 @@ class HotStarBaseIE(InfoExtractor):
|
|||||||
headers={'x-country-code': 'IN', 'x-platform-code': 'PCTV'})
|
headers={'x-country-code': 'IN', 'x-platform-code': 'PCTV'})
|
||||||
|
|
||||||
def _call_api_impl(self, path, video_id, query, st=None, cookies=None):
|
def _call_api_impl(self, path, video_id, query, st=None, cookies=None):
|
||||||
if not cookies or not cookies.get('userUP'):
|
|
||||||
self.raise_login_required()
|
|
||||||
|
|
||||||
st = int_or_none(st) or int(time.time())
|
st = int_or_none(st) or int(time.time())
|
||||||
exp = st + 6000
|
exp = st + 6000
|
||||||
auth = f'st={st}~exp={exp}~acl=/*'
|
auth = f'st={st}~exp={exp}~acl=/*'
|
||||||
auth += '~hmac=' + hmac.new(self._AKAMAI_ENCRYPTION_KEY, auth.encode(), hashlib.sha256).hexdigest()
|
auth += '~hmac=' + hmac.new(self._AKAMAI_ENCRYPTION_KEY, auth.encode(), hashlib.sha256).hexdigest()
|
||||||
|
|
||||||
|
if cookies and cookies.get('userUP'):
|
||||||
|
token = cookies.get('userUP').value
|
||||||
|
else:
|
||||||
|
token = self._download_json(
|
||||||
|
f'{self._API_URL}/um/v3/users',
|
||||||
|
video_id, note='Downloading token',
|
||||||
|
data=json.dumps({'device_ids': [{'id': str(uuid.uuid4()), 'type': 'device_id'}]}).encode(),
|
||||||
|
headers={
|
||||||
|
'hotstarauth': auth,
|
||||||
|
'x-hs-platform': 'PCTV', # or 'web'
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
})['user_identity']
|
||||||
|
|
||||||
response = self._download_json(
|
response = self._download_json(
|
||||||
f'{self._API_URL}/{path}', video_id, query=query,
|
f'{self._API_URL}/{path}', video_id, query=query,
|
||||||
headers={
|
headers={
|
||||||
'hotstarauth': auth,
|
'hotstarauth': auth,
|
||||||
'x-hs-appversion': '6.72.2',
|
'x-hs-appversion': '6.72.2',
|
||||||
'x-hs-platform': 'web',
|
'x-hs-platform': 'web',
|
||||||
'x-hs-usertoken': cookies['userUP'].value,
|
'x-hs-usertoken': token,
|
||||||
})
|
})
|
||||||
|
|
||||||
if response['message'] != "Playback URL's fetched successfully":
|
if response['message'] != "Playback URL's fetched successfully":
|
||||||
@ -220,15 +232,10 @@ class HotStarIE(HotStarBaseIE):
|
|||||||
video_type = self._TYPE.get(video_type, video_type)
|
video_type = self._TYPE.get(video_type, video_type)
|
||||||
cookies = self._get_cookies(url) # Cookies before any request
|
cookies = self._get_cookies(url) # Cookies before any request
|
||||||
|
|
||||||
# tas=10000 can cause HTTP Error 504, see https://github.com/yt-dlp/yt-dlp/issues/7946
|
video_data = traverse_obj(
|
||||||
for tas in (10000, 0):
|
self._call_api_v1(
|
||||||
query = {'tas': tas, 'contentId': video_id}
|
f'{video_type}/detail', video_id, fatal=False, query={'tas': 10000, 'contentId': video_id}),
|
||||||
video_data = traverse_obj(
|
('body', 'results', 'item', {dict})) or {}
|
||||||
self._call_api_v1(f'{video_type}/detail', video_id, fatal=False, query=query),
|
|
||||||
('body', 'results', 'item', {dict})) or {}
|
|
||||||
if video_data:
|
|
||||||
break
|
|
||||||
|
|
||||||
if not self.get_param('allow_unplayable_formats') and video_data.get('drmProtected'):
|
if not self.get_param('allow_unplayable_formats') and video_data.get('drmProtected'):
|
||||||
self.report_drm(video_id)
|
self.report_drm(video_id)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user