mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-09-05 18:39:37 +02:00
[extractor/zee5] Fix extraction of new content (#7280)
Authored by: bashonly
This commit is contained in:
parent
1a2eb5bda5
commit
9d7fde89a4
@ -1,14 +1,16 @@
|
|||||||
import json
|
import json
|
||||||
import random
|
import time
|
||||||
import string
|
import uuid
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..compat import compat_str
|
from ..compat import compat_str
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
int_or_none,
|
int_or_none,
|
||||||
|
jwt_decode_hs256,
|
||||||
parse_age_limit,
|
parse_age_limit,
|
||||||
str_or_none,
|
str_or_none,
|
||||||
|
try_call,
|
||||||
try_get,
|
try_get,
|
||||||
unified_strdate,
|
unified_strdate,
|
||||||
unified_timestamp,
|
unified_timestamp,
|
||||||
@ -94,12 +96,12 @@ class Zee5IE(InfoExtractor):
|
|||||||
'url': 'https://www.zee5.com/music-videos/details/adhento-gaani-vunnapaatuga-jersey-nani-shraddha-srinath/0-0-56973',
|
'url': 'https://www.zee5.com/music-videos/details/adhento-gaani-vunnapaatuga-jersey-nani-shraddha-srinath/0-0-56973',
|
||||||
'only_matching': True
|
'only_matching': True
|
||||||
}]
|
}]
|
||||||
_DETAIL_API_URL = 'https://spapi.zee5.com/singlePlayback/getDetails/secure?content_id={}&device_id={}&platform_name=desktop_web&country=IN&check_parental_control=false'
|
_DEVICE_ID = str(uuid.uuid4())
|
||||||
_DEVICE_ID = ''.join(random.choices(string.ascii_letters + string.digits, k=20)).ljust(32, '0')
|
|
||||||
_USER_TOKEN = None
|
_USER_TOKEN = None
|
||||||
_LOGIN_HINT = 'Use "--username <mobile_number>" to login using otp or "--username token" and "--password <user_token>" to login using user token.'
|
_LOGIN_HINT = 'Use "--username <mobile_number>" to login using otp or "--username token" and "--password <user_token>" to login using user token.'
|
||||||
_NETRC_MACHINE = 'zee5'
|
_NETRC_MACHINE = 'zee5'
|
||||||
_GEO_COUNTRIES = ['IN']
|
_GEO_COUNTRIES = ['IN']
|
||||||
|
_USER_COUNTRY = None
|
||||||
|
|
||||||
def _perform_login(self, username, password):
|
def _perform_login(self, username, password):
|
||||||
if len(username) == 10 and username.isdigit() and self._USER_TOKEN is None:
|
if len(username) == 10 and username.isdigit() and self._USER_TOKEN is None:
|
||||||
@ -118,11 +120,16 @@ def _perform_login(self, username, password):
|
|||||||
self._USER_TOKEN = otp_verify_json.get('token')
|
self._USER_TOKEN = otp_verify_json.get('token')
|
||||||
if not self._USER_TOKEN:
|
if not self._USER_TOKEN:
|
||||||
raise ExtractorError(otp_request_json['message'], expected=True)
|
raise ExtractorError(otp_request_json['message'], expected=True)
|
||||||
elif username.lower() == 'token' and len(password) > 1198:
|
elif username.lower() == 'token' and try_call(lambda: jwt_decode_hs256(password)):
|
||||||
self._USER_TOKEN = password
|
self._USER_TOKEN = password
|
||||||
else:
|
else:
|
||||||
raise ExtractorError(self._LOGIN_HINT, expected=True)
|
raise ExtractorError(self._LOGIN_HINT, expected=True)
|
||||||
|
|
||||||
|
token = jwt_decode_hs256(self._USER_TOKEN)
|
||||||
|
if token.get('exp', 0) <= int(time.time()):
|
||||||
|
raise ExtractorError('User token has expired', expected=True)
|
||||||
|
self._USER_COUNTRY = token.get('current_country')
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id, display_id = self._match_valid_url(url).group('id', 'display_id')
|
video_id, display_id = self._match_valid_url(url).group('id', 'display_id')
|
||||||
access_token_request = self._download_json(
|
access_token_request = self._download_json(
|
||||||
@ -137,8 +144,13 @@ def _real_extract(self, url):
|
|||||||
data['X-Z5-Guest-Token'] = self._DEVICE_ID
|
data['X-Z5-Guest-Token'] = self._DEVICE_ID
|
||||||
|
|
||||||
json_data = self._download_json(
|
json_data = self._download_json(
|
||||||
self._DETAIL_API_URL.format(video_id, self._DEVICE_ID),
|
'https://spapi.zee5.com/singlePlayback/getDetails/secure', video_id, query={
|
||||||
video_id, headers={'content-type': 'application/json'}, data=json.dumps(data).encode('utf-8'))
|
'content_id': video_id,
|
||||||
|
'device_id': self._DEVICE_ID,
|
||||||
|
'platform_name': 'desktop_web',
|
||||||
|
'country': self._USER_COUNTRY or self.get_param('geo_bypass_country') or 'IN',
|
||||||
|
'check_parental_control': False,
|
||||||
|
}, headers={'content-type': 'application/json'}, data=json.dumps(data).encode('utf-8'))
|
||||||
asset_data = json_data['assetDetails']
|
asset_data = json_data['assetDetails']
|
||||||
show_data = json_data.get('showDetails', {})
|
show_data = json_data.get('showDetails', {})
|
||||||
if 'premium' in asset_data['business_type']:
|
if 'premium' in asset_data['business_type']:
|
||||||
|
Loading…
Reference in New Issue
Block a user