diff options
author | Nitzo <nitzo2001@yahoo.com> | 2016-04-30 16:24:17 +0200 |
---|---|---|
committer | Nitzo <nitzo2001@yahoo.com> | 2016-04-30 16:24:17 +0200 |
commit | 814bf15ed40a66c512f5bfb69643ca9e5a8c43de (patch) | |
tree | 2c2df7cf1008bbb22e9b6aec42952c85b2d89adf /module | |
parent | [Checksum] Fix #540 (diff) | |
download | pyload-814bf15ed40a66c512f5bfb69643ca9e5a8c43de.tar.xz |
[MegaCoNz] Code cosmetics
Diffstat (limited to 'module')
-rw-r--r-- | module/plugins/crypter/MegaCoNzFolder.py | 5 | ||||
-rw-r--r-- | module/plugins/hoster/MegaCoNz.py | 29 |
2 files changed, 17 insertions, 17 deletions
diff --git a/module/plugins/crypter/MegaCoNzFolder.py b/module/plugins/crypter/MegaCoNzFolder.py index 3d47ede05..8e63fc992 100644 --- a/module/plugins/crypter/MegaCoNzFolder.py +++ b/module/plugins/crypter/MegaCoNzFolder.py @@ -2,13 +2,14 @@ from module.plugins.internal.Crypter import Crypter from module.plugins.internal.misc import json + from module.plugins.hoster.MegaCoNz import MegaClient, MegaCrypto class MegaCoNzFolder(Crypter): __name__ = "MegaCoNzFolder" __type__ = "crypter" - __version__ = "0.16" + __version__ = "0.17" __status__ = "testing" __pattern__ = r'(https?://(?:www\.)?mega(\.co)?\.nz/|mega:|chrome:.+?)#F!(?P<ID>[\w^_]+)!(?P<KEY>[\w,\-=]+)' @@ -26,7 +27,7 @@ class MegaCoNzFolder(Crypter): id = self.info['pattern']['ID'] master_key = self.info['pattern']['KEY'] - self.log_debug("ID: %s" % id, "Key: %s" % master_key, "Type: public folder") + self.log_debug(_("ID: %s") % id, _("Key: %s") % master_key, _("Type: public folder")) master_key = MegaCrypto.base64_to_a32(master_key) diff --git a/module/plugins/hoster/MegaCoNz.py b/module/plugins/hoster/MegaCoNz.py index 056a06711..82be11064 100644 --- a/module/plugins/hoster/MegaCoNz.py +++ b/module/plugins/hoster/MegaCoNz.py @@ -88,8 +88,8 @@ class MegaCrypto(object): """ Construct the cipher key from the given data """ - k = (key[0] ^ key[4], key[1] ^ key[5], key[2] ^ key[6], key[3] ^ key[7]) - iv = key[4:6] + (0, 0) + k = (key[0] ^ key[4], key[1] ^ key[5], key[2] ^ key[6], key[3] ^ key[7]) + iv = key[4:6] + (0, 0) meta_mac = key[6:8] return k, iv, meta_mac @@ -124,7 +124,7 @@ class MegaCrypto(object): Calculate chunks for a given encrypted file size """ chunk_start = 0 - chunk_size = 0x20000 + chunk_size = 0x20000 while chunk_start + chunk_size < size: yield (chunk_start, chunk_size) @@ -143,16 +143,16 @@ class MegaCrypto(object): def __init__(self, key): k, iv, meta_mac = MegaCrypto.get_cipher_key(key) self.hash = '\0' * 16 - self.key = MegaCrypto.a32_to_str(k) - self.iv = MegaCrypto.a32_to_str(iv[0:2] * 2) - self.AES = Crypto.Cipher.AES.new(self.key, mode=Crypto.Cipher.AES.MODE_CBC, IV=self.hash) + self.key = MegaCrypto.a32_to_str(k) + self.iv = MegaCrypto.a32_to_str(iv[0:2] * 2) + self.AES = Crypto.Cipher.AES.new(self.key, mode=Crypto.Cipher.AES.MODE_CBC, IV=self.hash) def update(self, chunk): cbc = Crypto.Cipher.AES.new(self.key, mode=Crypto.Cipher.AES.MODE_CBC, IV=self.iv) for j in xrange(0, len(chunk), 16): block = chunk[j:j + 16].ljust(16, '\0') - hash = cbc.encrypt(block) + hash = cbc.encrypt(block) self.hash = self.AES.encrypt(hash) @@ -203,7 +203,7 @@ class MegaClient(object): else: raise - self.plugin.log_debug("Api Response: " + res) + self.plugin.log_debug(_("Api Response: ") + res) return json.loads(res) @@ -226,7 +226,7 @@ class MegaClient(object): class MegaCoNz(Hoster): __name__ = "MegaCoNz" __type__ = "hoster" - __version__ = "0.41" + __version__ = "0.42" __status__ = "testing" __pattern__ = r'(https?://(?:www\.)?mega(\.co)?\.nz/|mega:|chrome:.+?)#(?P<TYPE>N|)!(?P<ID>[\w^_]+)!(?P<KEY>[\w\-,=]+)(?:###n=(?P<OWNER>[\w^_]+))?' @@ -244,7 +244,7 @@ class MegaCoNz(Hoster): def decrypt_file(self, key): """ - Decrypts and verifies checksum to the file at last_download` + Decrypts and verifies checksum to the file at 'last_download' """ k, iv, meta_mac = MegaCrypto.get_cipher_key(key) ctr = Crypto.Util.Counter.new(128, initial_value = ((iv[0] << 32) + iv[1]) << 64) @@ -266,10 +266,9 @@ class MegaCoNz(Hoster): encrypted_size = os.path.getsize(file_crypted) checksum_activated = self.config.get("activated", default=False, plugin="Checksum") - check_checksum = self.config.get("check_checksum", default=True, plugin="Checksum") + check_checksum = self.config.get("check_checksum", default=True, plugin="Checksum") cbc_mac = MegaCrypto.Checksum(key) if checksum_activated and check_checksum else None - cbc_mac = MegaCrypto.Checksum(key) progress = 0 for chunk_start, chunk_size in MegaCrypto.get_chunks(encrypted_size): @@ -329,7 +328,7 @@ class MegaCoNz(Hoster): def check_exists(self, name): """ - Because of Mega downloads a temporary encrypted file with the extension of ".crypted", + Because of Mega downloads a temporary encrypted file with the extension of '.crypted', pyLoad cannot correctly detect if the file exists before downloading. This function corrects this. @@ -355,7 +354,7 @@ class MegaCoNz(Hoster): self.log_error(_("Missing owner in URL")) self.fail(_("Missing owner in URL")) - self.log_debug("ID: %s" % id, "Key: %s" % key, "Type: %s" % ("public" if public else "node"), "Owner: %s" % owner) + self.log_debug(_("ID: %s") % id, _("Key: %s") % key, _("Type: %s") % ("public" if public else "node"), _("Owner: %s") % owner) key = MegaCrypto.base64_to_a32(key) @@ -377,7 +376,7 @@ class MegaCoNz(Hoster): if not attr: self.fail(_("Decryption failed")) - self.log_debug("Decrypted Attr: %s" % decode(attr)) + self.log_debug(_("Decrypted Attr: %s") % decode(attr)) name = attr['n'] |