summaryrefslogtreecommitdiffstats
path: root/module/plugins/hoster/MegaNz.py
diff options
context:
space:
mode:
Diffstat (limited to 'module/plugins/hoster/MegaNz.py')
-rw-r--r--module/plugins/hoster/MegaNz.py18
1 files changed, 10 insertions, 8 deletions
diff --git a/module/plugins/hoster/MegaNz.py b/module/plugins/hoster/MegaNz.py
index e5be4eeb7..db97f6859 100644
--- a/module/plugins/hoster/MegaNz.py
+++ b/module/plugins/hoster/MegaNz.py
@@ -9,17 +9,18 @@ from base64 import standard_b64decode
from Crypto.Cipher import AES
from Crypto.Util import Counter
-from module.common.json_layer import json
+from module.common.json_layer import json_loads, json_dumps
from module.plugins.Hoster import Hoster
#def getInfo(urls):
# pass
+
class MegaNz(Hoster):
__name__ = "MegaNz"
__type__ = "hoster"
__pattern__ = r"https?://([a-z0-9]+\.)?mega\.co\.nz/#!([a-zA-Z0-9!_\-]+)"
- __version__ = "0.12"
+ __version__ = "0.13"
__description__ = """mega.co.nz hoster plugin"""
__author_name__ = ("RaNaN", )
__author_mail__ = ("ranan@pyload.org", )
@@ -42,9 +43,9 @@ class MegaNz(Hoster):
# generate a session id, no idea where to obtain elsewhere
uid = random.randint(10 << 9, 10 ** 10)
- resp = self.load(self.API_URL % uid, post=json.dumps([kwargs]))
+ resp = self.load(self.API_URL % uid, post=json_dumps([kwargs]))
self.logDebug("Api Response: " + resp)
- return json.loads(resp)
+ return json_loads(resp)
def decryptAttr(self, data, key):
@@ -55,7 +56,7 @@ class MegaNz(Hoster):
self.fail(_("Decryption failed"))
# Data is padded, 0-bytes must be stripped
- return json.loads(attr.replace("MEGA", "").rstrip("\0").strip())
+ return json_loads(attr.replace("MEGA", "").rstrip("\0").strip())
def decryptFile(self, key):
""" Decrypts the file at lastDownload` """
@@ -64,7 +65,7 @@ class MegaNz(Hoster):
n = key[16:24]
# convert counter to long and shift bytes
- ctr = Counter.new(128, initial_value=long(n.encode("hex"),16) << 64)
+ ctr = Counter.new(128, initial_value=long(n.encode("hex"), 16) << 64)
cipher = AES.new(self.getCipherKey(key), AES.MODE_CTR, counter=ctr)
self.pyfile.setStatus("decrypting")
@@ -73,10 +74,11 @@ class MegaNz(Hoster):
# TODO: calculate CBC-MAC for checksum
- size = 2 ** 15 # buffer size, 32k
+ size = 2 ** 15 # buffer size, 32k
while True:
buf = f.read(size)
- if not buf: break
+ if not buf:
+ break
df.write(cipher.decrypt(buf))