mirror of
https://github.com/spaam/svtplay-dl.git
synced 2024-11-27 13:44:14 +01:00
Replace pycryptodome with cryptography.
This will make it easier to support older distros. For example ubuntu 16.04 and Debian stable (9)
This commit is contained in:
parent
525d33a516
commit
5b6779edf2
@ -88,7 +88,7 @@ are usually available from your distribution’s package repositories. If
|
||||
you don’t have them, some features will not be working.
|
||||
|
||||
- [Python](https://www.python.org/) 3.4 or higher
|
||||
- [pycryptodome](https://www.pycryptodome.org/en/latest/) to download encrypted HLS streams
|
||||
- [cryptography](https://cryptography.io/en/latest/) to download encrypted HLS streams
|
||||
- [PyYaml](https://github.com/yaml/pyyaml) for configure file
|
||||
- [Requests](http://www.python-requests.org/)
|
||||
- [PySocks](https://github.com/Anorov/PySocks) to enable proxy support
|
||||
|
@ -1,18 +1,16 @@
|
||||
# using edge to get ffmpeg-4.x
|
||||
# using testing repo to get pycryptodome
|
||||
FROM alpine:edge
|
||||
MAINTAINER spaam
|
||||
|
||||
COPY dist/*.whl .
|
||||
|
||||
RUN set -xe \
|
||||
&& echo 'http://dl-cdn.alpinelinux.org/alpine/edge/testing' >> /etc/apk/repositories \
|
||||
&& apk add --no-cache \
|
||||
ca-certificates \
|
||||
python3 \
|
||||
py3-pip \
|
||||
rtmpdump \
|
||||
py3-pycryptodome \
|
||||
py3-cryptography \
|
||||
ffmpeg \
|
||||
&& python3 -m pip install *.whl \
|
||||
&& rm -f *.whl
|
||||
|
@ -127,14 +127,11 @@ class HLS(VideoRetriever):
|
||||
key = None
|
||||
|
||||
if m3u8.encrypted:
|
||||
from Crypto.Cipher import AES
|
||||
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
|
||||
from cryptography.hazmat.backends import default_backend
|
||||
|
||||
def random_iv():
|
||||
try:
|
||||
from Crypto import Random
|
||||
return Random.new().read(AES.block_size)
|
||||
except ImportError:
|
||||
return os.urandom(16)
|
||||
return os.urandom(16)
|
||||
file_d = output(file_name[0], self.config, file_name[1])
|
||||
if file_d is None:
|
||||
return
|
||||
@ -180,10 +177,12 @@ class HLS(VideoRetriever):
|
||||
raise HLSException(keyurl, "Can't decrypt beacuse of DRM")
|
||||
key = self.http.request("get", keyurl, cookies=keycookies, headers=headers).content
|
||||
iv = binascii.unhexlify(i["EXT-X-KEY"]["IV"][2:].zfill(32)) if "IV" in i["EXT-X-KEY"] else random_iv()
|
||||
decryptor = AES.new(key, AES.MODE_CBC, iv)
|
||||
backend = default_backend()
|
||||
cipher = Cipher(algorithms.AES(key), modes.CBC(iv), backend=backend)
|
||||
decryptor = cipher.decryptor()
|
||||
|
||||
if decryptor:
|
||||
data = decryptor.decrypt(data)
|
||||
data = decryptor.update(data) + decryptor.finalize()
|
||||
else:
|
||||
raise ValueError("No decryptor found for encrypted hls steam.")
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
requests
|
||||
PySocks
|
||||
pycryptodome
|
||||
cryptography
|
||||
pyyaml
|
Loading…
Reference in New Issue
Block a user