mirror of https://github.com/yt-dlp/yt-dlp.git
[ivi] sign content request only when pycryptodome is available
This commit is contained in:
parent
656c20010f
commit
1bba88efc7
|
@ -80,13 +80,22 @@ class IviIE(InfoExtractor):
|
||||||
'MP4-SHQ', 'MP4-HD720', 'MP4-HD1080')
|
'MP4-SHQ', 'MP4-HD720', 'MP4-HD1080')
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
|
video_id = self._match_id(url)
|
||||||
|
|
||||||
|
data = json.dumps({
|
||||||
|
'method': 'da.content.get',
|
||||||
|
'params': [
|
||||||
|
video_id, {
|
||||||
|
'site': 's%d',
|
||||||
|
'referrer': 'http://www.ivi.ru/watch/%s' % video_id,
|
||||||
|
'contentid': video_id
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}).encode()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from Crypto.Cipher import Blowfish
|
from Crypto.Cipher import Blowfish
|
||||||
from Crypto.Hash import CMAC
|
from Crypto.Hash import CMAC
|
||||||
except ImportError:
|
|
||||||
raise ExtractorError('pycrypto not found. Please install it.', expected=True)
|
|
||||||
|
|
||||||
video_id = self._match_id(url)
|
|
||||||
|
|
||||||
timestamp = self._download_json(
|
timestamp = self._download_json(
|
||||||
self._LIGHT_URL, video_id,
|
self._LIGHT_URL, video_id,
|
||||||
|
@ -95,23 +104,18 @@ class IviIE(InfoExtractor):
|
||||||
'params': []
|
'params': []
|
||||||
}).encode())['result']
|
}).encode())['result']
|
||||||
|
|
||||||
data = json.dumps({
|
data = data % 353
|
||||||
'method': 'da.content.get',
|
query = {
|
||||||
'params': [
|
'ts': timestamp,
|
||||||
video_id, {
|
'sign': CMAC.new(self._LIGHT_KEY, timestamp.encode() + data, Blowfish).hexdigest(),
|
||||||
'site': 's353',
|
|
||||||
'referrer': 'http://www.ivi.ru/watch/%s' % video_id,
|
|
||||||
'contentid': video_id
|
|
||||||
}
|
}
|
||||||
]
|
except ImportError:
|
||||||
}).encode()
|
data = data % 183
|
||||||
|
query = {}
|
||||||
|
|
||||||
video_json = self._download_json(
|
video_json = self._download_json(
|
||||||
self._LIGHT_URL, video_id,
|
self._LIGHT_URL, video_id,
|
||||||
'Downloading video JSON', data=data, query={
|
'Downloading video JSON', data=data, query=query)
|
||||||
'ts': timestamp,
|
|
||||||
'sign': CMAC.new(self._LIGHT_KEY, timestamp.encode() + data, Blowfish).hexdigest(),
|
|
||||||
})
|
|
||||||
|
|
||||||
error = video_json.get('error')
|
error = video_json.get('error')
|
||||||
if error:
|
if error:
|
||||||
|
@ -121,6 +125,8 @@ class IviIE(InfoExtractor):
|
||||||
msg=error['message'], countries=self._GEO_COUNTRIES)
|
msg=error['message'], countries=self._GEO_COUNTRIES)
|
||||||
elif origin == 'NoRedisValidData':
|
elif origin == 'NoRedisValidData':
|
||||||
raise ExtractorError('Video %s does not exist' % video_id, expected=True)
|
raise ExtractorError('Video %s does not exist' % video_id, expected=True)
|
||||||
|
elif origin == 'NotAllowedError':
|
||||||
|
raise ExtractorError('pycryptodome not found. Please install it.', expected=True)
|
||||||
raise ExtractorError(
|
raise ExtractorError(
|
||||||
'Unable to download video %s: %s' % (video_id, error['message']),
|
'Unable to download video %s: %s' % (video_id, error['message']),
|
||||||
expected=True)
|
expected=True)
|
||||||
|
|
Loading…
Reference in New Issue