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:
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.
|
you don’t have them, some features will not be working.
|
||||||
|
|
||||||
- [Python](https://www.python.org/) 3.4 or higher
|
- [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
|
- [PyYaml](https://github.com/yaml/pyyaml) for configure file
|
||||||
- [Requests](http://www.python-requests.org/)
|
- [Requests](http://www.python-requests.org/)
|
||||||
- [PySocks](https://github.com/Anorov/PySocks) to enable proxy support
|
- [PySocks](https://github.com/Anorov/PySocks) to enable proxy support
|
||||||
|
@ -1,18 +1,16 @@
|
|||||||
# using edge to get ffmpeg-4.x
|
# using edge to get ffmpeg-4.x
|
||||||
# using testing repo to get pycryptodome
|
|
||||||
FROM alpine:edge
|
FROM alpine:edge
|
||||||
MAINTAINER spaam
|
MAINTAINER spaam
|
||||||
|
|
||||||
COPY dist/*.whl .
|
COPY dist/*.whl .
|
||||||
|
|
||||||
RUN set -xe \
|
RUN set -xe \
|
||||||
&& echo 'http://dl-cdn.alpinelinux.org/alpine/edge/testing' >> /etc/apk/repositories \
|
|
||||||
&& apk add --no-cache \
|
&& apk add --no-cache \
|
||||||
ca-certificates \
|
ca-certificates \
|
||||||
python3 \
|
python3 \
|
||||||
py3-pip \
|
py3-pip \
|
||||||
rtmpdump \
|
rtmpdump \
|
||||||
py3-pycryptodome \
|
py3-cryptography \
|
||||||
ffmpeg \
|
ffmpeg \
|
||||||
&& python3 -m pip install *.whl \
|
&& python3 -m pip install *.whl \
|
||||||
&& rm -f *.whl
|
&& rm -f *.whl
|
||||||
|
@ -127,13 +127,10 @@ class HLS(VideoRetriever):
|
|||||||
key = None
|
key = None
|
||||||
|
|
||||||
if m3u8.encrypted:
|
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():
|
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])
|
file_d = output(file_name[0], self.config, file_name[1])
|
||||||
if file_d is None:
|
if file_d is None:
|
||||||
@ -180,10 +177,12 @@ class HLS(VideoRetriever):
|
|||||||
raise HLSException(keyurl, "Can't decrypt beacuse of DRM")
|
raise HLSException(keyurl, "Can't decrypt beacuse of DRM")
|
||||||
key = self.http.request("get", keyurl, cookies=keycookies, headers=headers).content
|
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()
|
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:
|
if decryptor:
|
||||||
data = decryptor.decrypt(data)
|
data = decryptor.update(data) + decryptor.finalize()
|
||||||
else:
|
else:
|
||||||
raise ValueError("No decryptor found for encrypted hls steam.")
|
raise ValueError("No decryptor found for encrypted hls steam.")
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
requests
|
requests
|
||||||
PySocks
|
PySocks
|
||||||
pycryptodome
|
cryptography
|
||||||
pyyaml
|
pyyaml
|
2
setup.py
2
setup.py
@ -18,7 +18,7 @@ with open(os.path.join(srcdir, 'svtplay_dl', '__version__.py'), 'r') as f:
|
|||||||
deps = []
|
deps = []
|
||||||
deps.append("requests>=2.0.0")
|
deps.append("requests>=2.0.0")
|
||||||
deps.append("PySocks")
|
deps.append("PySocks")
|
||||||
deps.append("pycryptodome")
|
deps.append("cryptography")
|
||||||
deps.append("pyyaml")
|
deps.append("pyyaml")
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
|
Loading…
Reference in New Issue
Block a user