From 95f56ae40b7c6a56b959b512aa82c8674377c31c Mon Sep 17 00:00:00 2001 From: Gonzalo SR Date: Thu, 11 Apr 2013 15:16:13 +0300 Subject: Fixed incorrect use of rstrip() rstrip() ate the last "r" in .rar files. "The chars argument is not a suffix; rather, all combinations of its values are stripped" (see http://docs.python.org/2/library/stdtypes.html#str.rstrip) Using rsplit() instead. --- module/plugins/hoster/MegaNz.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'module/plugins/hoster') diff --git a/module/plugins/hoster/MegaNz.py b/module/plugins/hoster/MegaNz.py index a28ddca9d..3b64c3ef5 100644 --- a/module/plugins/hoster/MegaNz.py +++ b/module/plugins/hoster/MegaNz.py @@ -19,7 +19,7 @@ class MegaNz(Hoster): __name__ = "MegaNz" __type__ = "hoster" __pattern__ = r"https?://([a-z0-9]+\.)?mega\.co\.nz/#!([a-zA-Z0-9!_\-]+)" - __version__ = "0.11" + __version__ = "0.12" __description__ = """mega.co.nz hoster plugin""" __author_name__ = ("RaNaN", ) __author_mail__ = ("ranan@pyload.org", ) @@ -34,7 +34,7 @@ class MegaNz(Hoster): def getCipherKey(self, key): """ Construct the cipher key from the given data """ a = array("I", key) - key_array = array("I", [a[0] ^ a[4], a[1] ^a[5], a[2] ^ a[6], a[3] ^a[7]]) + key_array = array("I", [a[0] ^ a[4], a[1] ^ a[5], a[2] ^ a[6], a[3] ^ a[7]]) return key_array def callApi(self, **kwargs): @@ -55,7 +55,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", "").rsplit("\0")[0].strip()) def decryptFile(self, key): """ Decrypts the file at lastDownload` """ @@ -69,7 +69,7 @@ class MegaNz(Hoster): self.pyfile.setStatus("decrypting") f = open(self.lastDownload, "rb") - df = open(self.lastDownload.rstrip(self.FILE_SUFFIX), "wb") + df = open(self.lastDownload.rsplit(self.FILE_SUFFIX)[0], "wb") # TODO: calculate CBC-MAC for checksum -- cgit v1.2.3 From 2f9dc56db6fc84e9915b7b8bc7892b880fe03059 Mon Sep 17 00:00:00 2001 From: Gonzalo SR Date: Thu, 11 Apr 2013 19:07:46 +0300 Subject: revert correct rsrtrip() --- module/plugins/hoster/MegaNz.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hoster') diff --git a/module/plugins/hoster/MegaNz.py b/module/plugins/hoster/MegaNz.py index 3b64c3ef5..e5be4eeb7 100644 --- a/module/plugins/hoster/MegaNz.py +++ b/module/plugins/hoster/MegaNz.py @@ -55,7 +55,7 @@ class MegaNz(Hoster): self.fail(_("Decryption failed")) # Data is padded, 0-bytes must be stripped - return json.loads(attr.replace("MEGA", "").rsplit("\0")[0].strip()) + return json.loads(attr.replace("MEGA", "").rstrip("\0").strip()) def decryptFile(self, key): """ Decrypts the file at lastDownload` """ -- cgit v1.2.3