From 5060e4c6374a5116d0d8b02528f910f8c5f8bcf9 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 15 Jul 2014 16:25:41 +0200 Subject: Fix code indentation, some bad whitespaces and missing authors + use 'not' instead 'is None' + replace __pattern__'s r" with r' + other minor cosmetics --- module/plugins/hoster/MegaNz.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hoster/MegaNz.py') diff --git a/module/plugins/hoster/MegaNz.py b/module/plugins/hoster/MegaNz.py index a55220bc2..a396204ab 100644 --- a/module/plugins/hoster/MegaNz.py +++ b/module/plugins/hoster/MegaNz.py @@ -22,8 +22,8 @@ class MegaNz(Hoster): __pattern__ = r'https?://([a-z0-9]+\.)?mega\.co\.nz/#!([a-zA-Z0-9!_\-]+)' __version__ = "0.14" __description__ = """Mega.co.nz hoster plugin""" - __author_name__ = ("RaNaN", ) - __author_mail__ = ("ranan@pyload.org", ) + __author_name__ = "RaNaN" + __author_mail__ = "ranan@pyload.org" API_URL = "https://g.api.mega.co.nz/cs?id=%d" FILE_SUFFIX = ".crypted" -- cgit v1.2.3 From 7b8c458cca7d21a029620f98e453f746fce69cd1 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 14 Jul 2014 16:10:01 +0200 Subject: Prefer single quote for dict key name --- module/plugins/hoster/MegaNz.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'module/plugins/hoster/MegaNz.py') diff --git a/module/plugins/hoster/MegaNz.py b/module/plugins/hoster/MegaNz.py index a396204ab..cf35f2d2d 100644 --- a/module/plugins/hoster/MegaNz.py +++ b/module/plugins/hoster/MegaNz.py @@ -110,7 +110,7 @@ class MegaNz(Hoster): dl = self.callApi(a="g", g=1, p=node, ssl=1)[0] if "e" in dl: - e = dl["e"] + e = dl['e'] # ETEMPUNAVAIL (-18): Resource temporarily not available, please try again later if e == -18: self.retry() @@ -121,12 +121,12 @@ class MegaNz(Hoster): # EACCESS (-11): Access violation (e.g., trying to write to a read-only share) key = self.b64_decode(key) - attr = self.decryptAttr(dl["at"], key) + attr = self.decryptAttr(dl['at'], key) - pyfile.name = attr["n"] + self.FILE_SUFFIX + pyfile.name = attr['n'] + self.FILE_SUFFIX - self.download(dl["g"]) + self.download(dl['g']) self.decryptFile(key) # Everything is finished and final name can be set - pyfile.name = attr["n"] + pyfile.name = attr['n'] -- cgit v1.2.3 From ba916633f2bedb04c7358000b91aed69f52e8e43 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 1 Aug 2014 19:35:59 +0200 Subject: Remove trailing whitespaces + remove license headers + import urllib methods directly + sort and fix key attributes + use save_join instead join + sort some import declarations + other minor code cosmetics --- module/plugins/hoster/MegaNz.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'module/plugins/hoster/MegaNz.py') diff --git a/module/plugins/hoster/MegaNz.py b/module/plugins/hoster/MegaNz.py index cf35f2d2d..5562aad06 100644 --- a/module/plugins/hoster/MegaNz.py +++ b/module/plugins/hoster/MegaNz.py @@ -1,26 +1,25 @@ # -*- coding: utf-8 -*- -import re import random -from array import array -from os import remove -from base64 import standard_b64decode +import re from Crypto.Cipher import AES from Crypto.Util import Counter +from array import array +from base64 import standard_b64decode +from os import remove 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.14" + + __pattern__ = r'https?://([a-z0-9]+\.)?mega\.co\.nz/#!([a-zA-Z0-9!_\-]+)' + __description__ = """Mega.co.nz hoster plugin""" __author_name__ = "RaNaN" __author_mail__ = "ranan@pyload.org" @@ -28,6 +27,7 @@ class MegaNz(Hoster): API_URL = "https://g.api.mega.co.nz/cs?id=%d" FILE_SUFFIX = ".crypted" + def b64_decode(self, data): data = data.replace("-", "+").replace("_", "/") return standard_b64decode(data + '=' * (-len(data) % 4)) -- cgit v1.2.3