summaryrefslogtreecommitdiff
path: root/tidal_dl_ng/helper/decryption.py
diff options
context:
space:
mode:
authorRobert Honz <exislow+github@gmail.com>2024-11-29 17:41:25 +0100
committerRobert Honz <exislow+github@gmail.com>2024-11-29 17:41:25 +0100
commit33a30537e9a205dd4b43e891b00c0b5f15a9b71b (patch)
tree9ccb8c4c273ce96fd6ebce8ea2077d281d812712 /tidal_dl_ng/helper/decryption.py
parentf2b3cc2505f4c64f09efacd775de3390ae204be0 (diff)
parent4deaf94fb53ad304db73f9384f817b29afcac4a8 (diff)
downloadtidal-dl-ng-33a30537e9a205dd4b43e891b00c0b5f15a9b71b.tar.gz
✨ Merge with master.
Diffstat (limited to 'tidal_dl_ng/helper/decryption.py')
-rw-r--r--tidal_dl_ng/helper/decryption.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/tidal_dl_ng/helper/decryption.py b/tidal_dl_ng/helper/decryption.py
index ebb946a..17ea19b 100644
--- a/tidal_dl_ng/helper/decryption.py
+++ b/tidal_dl_ng/helper/decryption.py
@@ -1,4 +1,5 @@
import base64
+import pathlib
from Crypto.Cipher import AES
from Crypto.Util import Counter
@@ -35,7 +36,7 @@ def decrypt_security_token(security_token: str) -> (str, str):
return key, nonce
-def decrypt_file(path_file_encrypted: str, path_file_destination: str, key: str, nonce: str) -> None:
+def decrypt_file(path_file_encrypted: pathlib.Path, path_file_destination: pathlib.Path, key: str, nonce: str) -> None:
"""
Decrypts an encrypted MQA file given the file, key and nonce.
TODO: Is it really only necessary for MQA of for all other formats, too?
@@ -46,9 +47,9 @@ def decrypt_file(path_file_encrypted: str, path_file_destination: str, key: str,
decryptor = AES.new(key, AES.MODE_CTR, counter=counter)
# Open and decrypt
- with open(path_file_encrypted, "rb") as f_src:
+ with path_file_encrypted.open("rb") as f_src:
audio_decrypted = decryptor.decrypt(f_src.read())
# Replace with decrypted file
- with open(path_file_destination, "wb") as f_dst:
+ with path_file_destination.open("wb") as f_dst:
f_dst.write(audio_decrypted)