mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-30 03:33:02 +00:00
[ivi] fallback to old extraction method for unknown error codes
This commit is contained in:
parent
f9c4a45210
commit
76d9eca43d
1 changed files with 45 additions and 34 deletions
|
@ -93,46 +93,57 @@ def _real_extract(self, url):
|
||||||
]
|
]
|
||||||
}).encode()
|
}).encode()
|
||||||
|
|
||||||
try:
|
for site in (353, 183):
|
||||||
from Crypto.Cipher import Blowfish
|
content_data = data % site
|
||||||
from Crypto.Hash import CMAC
|
if site == 353:
|
||||||
|
try:
|
||||||
|
from Cryptodome.Cipher import Blowfish
|
||||||
|
from Cryptodome.Hash import CMAC
|
||||||
|
pycryptodomex_found = True
|
||||||
|
except ImportError:
|
||||||
|
pycryptodomex_found = False
|
||||||
|
continue
|
||||||
|
|
||||||
timestamp = self._download_json(
|
timestamp = (self._download_json(
|
||||||
|
self._LIGHT_URL, video_id,
|
||||||
|
'Downloading timestamp JSON', data=json.dumps({
|
||||||
|
'method': 'da.timestamp.get',
|
||||||
|
'params': []
|
||||||
|
}).encode(), fatal=False) or {}).get('result')
|
||||||
|
if not timestamp:
|
||||||
|
continue
|
||||||
|
|
||||||
|
query = {
|
||||||
|
'ts': timestamp,
|
||||||
|
'sign': CMAC.new(self._LIGHT_KEY, timestamp.encode() + content_data, Blowfish).hexdigest(),
|
||||||
|
}
|
||||||
|
else:
|
||||||
|
query = {}
|
||||||
|
|
||||||
|
video_json = self._download_json(
|
||||||
self._LIGHT_URL, video_id,
|
self._LIGHT_URL, video_id,
|
||||||
'Downloading timestamp JSON', data=json.dumps({
|
'Downloading video JSON', data=content_data, query=query)
|
||||||
'method': 'da.timestamp.get',
|
|
||||||
'params': []
|
|
||||||
}).encode())['result']
|
|
||||||
|
|
||||||
data = data % 353
|
error = video_json.get('error')
|
||||||
query = {
|
if error:
|
||||||
'ts': timestamp,
|
origin = error.get('origin')
|
||||||
'sign': CMAC.new(self._LIGHT_KEY, timestamp.encode() + data, Blowfish).hexdigest(),
|
message = error.get('message') or error.get('user_message')
|
||||||
}
|
extractor_msg = 'Unable to download video %s'
|
||||||
except ImportError:
|
if origin == 'NotAllowedForLocation':
|
||||||
data = data % 183
|
self.raise_geo_restricted(message, self._GEO_COUNTRIES)
|
||||||
query = {}
|
elif origin == 'NoRedisValidData':
|
||||||
|
extractor_msg = 'Video %s does not exist'
|
||||||
video_json = self._download_json(
|
elif site == 353:
|
||||||
self._LIGHT_URL, video_id,
|
continue
|
||||||
'Downloading video JSON', data=data, query=query)
|
elif not pycryptodomex_found:
|
||||||
|
|
||||||
error = video_json.get('error')
|
|
||||||
if error:
|
|
||||||
origin = error.get('origin')
|
|
||||||
message = error.get('message') or error.get('user_message')
|
|
||||||
extractor_msg = 'Unable to download video %s'
|
|
||||||
if origin == 'NotAllowedForLocation':
|
|
||||||
self.raise_geo_restricted(message, self._GEO_COUNTRIES)
|
|
||||||
elif origin == 'NoRedisValidData':
|
|
||||||
extractor_msg = 'Video %s does not exist'
|
|
||||||
elif message:
|
|
||||||
if 'недоступен для просмотра на площадке s183' in message:
|
|
||||||
raise ExtractorError(
|
raise ExtractorError(
|
||||||
'pycryptodome not found. Please install it.',
|
'pycryptodome not found. Please install it.',
|
||||||
expected=True)
|
expected=True)
|
||||||
extractor_msg += ': ' + message
|
elif message:
|
||||||
raise ExtractorError(extractor_msg % video_id, expected=True)
|
extractor_msg += ': ' + message
|
||||||
|
raise ExtractorError(extractor_msg % video_id, expected=True)
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
|
||||||
result = video_json['result']
|
result = video_json['result']
|
||||||
title = result['title']
|
title = result['title']
|
||||||
|
|
Loading…
Reference in a new issue