1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-11-23 19:55:38 +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:
Johan Andersson 2019-03-23 01:00:44 +01:00
parent 525d33a516
commit 5b6779edf2
5 changed files with 11 additions and 14 deletions

View File

@ -88,7 +88,7 @@ are usually available from your distributions package repositories. If
you dont 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

View File

@ -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

View File

@ -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.")

View File

@ -1,4 +1,4 @@
requests
PySocks
pycryptodome
cryptography
pyyaml

View File

@ -18,7 +18,7 @@ with open(os.path.join(srcdir, 'svtplay_dl', '__version__.py'), 'r') as f:
deps = []
deps.append("requests>=2.0.0")
deps.append("PySocks")
deps.append("pycryptodome")
deps.append("cryptography")
deps.append("pyyaml")
setup(