mirror of
https://github.com/blackjack4494/yt-dlc.git
synced 2024-12-22 07:43:08 +00:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
b54d0e702a
1 changed files with 21 additions and 13 deletions
|
@ -6,6 +6,7 @@ import hmac
|
||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
import uuid
|
import uuid
|
||||||
|
import json
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..compat import (
|
from ..compat import (
|
||||||
|
@ -30,16 +31,25 @@ class HotStarBaseIE(InfoExtractor):
|
||||||
exp = st + 6000
|
exp = st + 6000
|
||||||
auth = 'st=%d~exp=%d~acl=/*' % (st, exp)
|
auth = 'st=%d~exp=%d~acl=/*' % (st, exp)
|
||||||
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()
|
||||||
|
token = self._download_json(
|
||||||
|
'https://api.hotstar.com/in/aadhar/v2/web/in/user/guest-signup',
|
||||||
|
video_id, note='Downloading token',
|
||||||
|
data=json.dumps({"idType": "device", "id": compat_str(uuid.uuid4())}).encode('utf-8'),
|
||||||
|
headers={
|
||||||
|
'hotstarauth': auth,
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
})['description']['userIdentity']
|
||||||
response = self._download_json(
|
response = self._download_json(
|
||||||
'https://api.hotstar.com/' + path, video_id, headers={
|
'https://api.hotstar.com/' + path, video_id, headers={
|
||||||
'hotstarauth': auth,
|
'hotstarauth': auth,
|
||||||
'x-country-code': 'IN',
|
'x-hs-appversion': '6.72.2',
|
||||||
'x-platform-code': 'JIO',
|
'x-hs-platform': 'web',
|
||||||
|
'x-hs-usertoken': token,
|
||||||
}, query=query)
|
}, query=query)
|
||||||
if response['statusCode'] != 'OK':
|
if response['message'] != "Playback URL's fetched successfully":
|
||||||
raise ExtractorError(
|
raise ExtractorError(
|
||||||
response['body']['message'], expected=True)
|
response['message'], expected=True)
|
||||||
return response['body']['results']
|
return response['data']
|
||||||
|
|
||||||
def _call_api(self, path, video_id, query_name='contentId'):
|
def _call_api(self, path, video_id, query_name='contentId'):
|
||||||
return self._call_api_impl(path, video_id, {
|
return self._call_api_impl(path, video_id, {
|
||||||
|
@ -49,13 +59,11 @@ class HotStarBaseIE(InfoExtractor):
|
||||||
|
|
||||||
def _call_api_v2(self, path, video_id):
|
def _call_api_v2(self, path, video_id):
|
||||||
return self._call_api_impl(
|
return self._call_api_impl(
|
||||||
'%s/in/contents/%s' % (path, video_id), video_id, {
|
'%s/content/%s' % (path, video_id), video_id, {
|
||||||
'desiredConfig': 'encryption:plain;ladder:phone,tv;package:hls,dash',
|
'desired-config': 'encryption:plain;ladder:phone,tv;package:hls,dash',
|
||||||
'client': 'mweb',
|
'device-id': compat_str(uuid.uuid4()),
|
||||||
'clientVersion': '6.18.0',
|
'os-name': 'Windows',
|
||||||
'deviceId': compat_str(uuid.uuid4()),
|
'os-version': '10',
|
||||||
'osName': 'Windows',
|
|
||||||
'osVersion': '10',
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@ -121,7 +129,7 @@ class HotStarIE(HotStarBaseIE):
|
||||||
headers = {'Referer': url}
|
headers = {'Referer': url}
|
||||||
formats = []
|
formats = []
|
||||||
geo_restricted = False
|
geo_restricted = False
|
||||||
playback_sets = self._call_api_v2('h/v2/play', video_id)['playBackSets']
|
playback_sets = self._call_api_v2('play/v1/playback', video_id)['playBackSets']
|
||||||
for playback_set in playback_sets:
|
for playback_set in playback_sets:
|
||||||
if not isinstance(playback_set, dict):
|
if not isinstance(playback_set, dict):
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Reference in a new issue