aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp/extractor
diff options
context:
space:
mode:
Diffstat (limited to 'yt_dlp/extractor')
-rw-r--r--yt_dlp/extractor/bilibili.py16
-rw-r--r--yt_dlp/extractor/ivi.py26
2 files changed, 12 insertions, 30 deletions
diff --git a/yt_dlp/extractor/bilibili.py b/yt_dlp/extractor/bilibili.py
index d4b05248f..266d57871 100644
--- a/yt_dlp/extractor/bilibili.py
+++ b/yt_dlp/extractor/bilibili.py
@@ -6,6 +6,7 @@ import urllib.error
import urllib.parse
from .common import InfoExtractor, SearchInfoExtractor
+from ..dependencies import Cryptodome
from ..utils import (
ExtractorError,
GeoRestrictedError,
@@ -893,22 +894,15 @@ class BiliIntlBaseIE(InfoExtractor):
}
def _perform_login(self, username, password):
- try:
- from Cryptodome.PublicKey import RSA
- from Cryptodome.Cipher import PKCS1_v1_5
- except ImportError:
- try:
- from Crypto.PublicKey import RSA
- from Crypto.Cipher import PKCS1_v1_5
- except ImportError:
- raise ExtractorError('pycryptodomex not found. Please install', expected=True)
+ if not Cryptodome:
+ raise ExtractorError('pycryptodomex not found. Please install', expected=True)
key_data = self._download_json(
'https://passport.bilibili.tv/x/intl/passport-login/web/key?lang=en-US', None,
note='Downloading login key', errnote='Unable to download login key')['data']
- public_key = RSA.importKey(key_data['key'])
- password_hash = PKCS1_v1_5.new(public_key).encrypt((key_data['hash'] + password).encode('utf-8'))
+ public_key = Cryptodome.PublicKey.RSA.importKey(key_data['key'])
+ password_hash = Cryptodome.Cipher.PKCS1_v1_5.new(public_key).encrypt((key_data['hash'] + password).encode('utf-8'))
login_post = self._download_json(
'https://passport.bilibili.tv/x/intl/passport-login/web/login/password?lang=en-US', None, data=urlencode_postdata({
'username': username,
diff --git a/yt_dlp/extractor/ivi.py b/yt_dlp/extractor/ivi.py
index dc6a48196..96220bea9 100644
--- a/yt_dlp/extractor/ivi.py
+++ b/yt_dlp/extractor/ivi.py
@@ -2,11 +2,8 @@ import json
import re
from .common import InfoExtractor
-from ..utils import (
- ExtractorError,
- int_or_none,
- qualities,
-)
+from ..dependencies import Cryptodome
+from ..utils import ExtractorError, int_or_none, qualities
class IviIE(InfoExtractor):
@@ -94,18 +91,8 @@ class IviIE(InfoExtractor):
for site in (353, 183):
content_data = (data % site).encode()
if site == 353:
- try:
- from Cryptodome.Cipher import Blowfish
- from Cryptodome.Hash import CMAC
- pycryptodome_found = True
- except ImportError:
- try:
- from Crypto.Cipher import Blowfish
- from Crypto.Hash import CMAC
- pycryptodome_found = True
- except ImportError:
- pycryptodome_found = False
- continue
+ if not Cryptodome:
+ continue
timestamp = (self._download_json(
self._LIGHT_URL, video_id,
@@ -118,7 +105,8 @@ class IviIE(InfoExtractor):
query = {
'ts': timestamp,
- 'sign': CMAC.new(self._LIGHT_KEY, timestamp.encode() + content_data, Blowfish).hexdigest(),
+ 'sign': Cryptodome.Hash.CMAC.new(self._LIGHT_KEY, timestamp.encode() + content_data,
+ Cryptodome.Cipher.Blowfish).hexdigest(),
}
else:
query = {}
@@ -138,7 +126,7 @@ class IviIE(InfoExtractor):
extractor_msg = 'Video %s does not exist'
elif site == 353:
continue
- elif not pycryptodome_found:
+ elif not Cryptodome:
raise ExtractorError('pycryptodomex not found. Please install', expected=True)
elif message:
extractor_msg += ': ' + message