summaryrefslogtreecommitdiffstats
path: root/module/plugins/internal
diff options
context:
space:
mode:
Diffstat (limited to 'module/plugins/internal')
-rw-r--r--module/plugins/internal/Account.py34
-rw-r--r--module/plugins/internal/AdYouLike.py20
-rw-r--r--module/plugins/internal/Crypter.py8
-rw-r--r--module/plugins/internal/Extractor.py2
-rw-r--r--module/plugins/internal/Hoster.py4
-rw-r--r--module/plugins/internal/OCR.py2
-rw-r--r--module/plugins/internal/Plugin.py10
-rw-r--r--module/plugins/internal/SimpleHoster.py6
8 files changed, 47 insertions, 39 deletions
diff --git a/module/plugins/internal/Account.py b/module/plugins/internal/Account.py
index 7bf8964ad..db0002d09 100644
--- a/module/plugins/internal/Account.py
+++ b/module/plugins/internal/Account.py
@@ -69,14 +69,14 @@ class Account(Plugin):
except WrongPassword:
self.log_warning(
- _("Could not login with account %(user)s | %(msg)s") % {"user": user,
- "msg": _("Wrong Password")})
+ _("Could not login with account %(user)s | %(msg)s") % {'user': user,
+ 'msg': _("Wrong Password")})
success = data['valid'] = False
except Exception, e:
self.log_warning(
- _("Could not login with account %(user)s | %(msg)s") % {"user": user,
- "msg": e})
+ _("Could not login with account %(user)s | %(msg)s") % {'user': user,
+ 'msg': e})
success = data['valid'] = False
if self.core.debug:
traceback.print_exc()
@@ -126,7 +126,7 @@ class Account(Plugin):
self.accounts[user]['options'].update(options)
return self.accounts[user]['options'] != before
else:
- self.accounts[user] = {"password": password, "options": options, "valid": True}
+ self.accounts[user] = {'password': password, 'options': options, 'valid': True}
self._login(user, self.accounts[user])
return True
@@ -211,16 +211,16 @@ class Account(Plugin):
:param req: `Request` instance
:return:
"""
- return {"validuntil" : None, #: -1 for unlimited
- "login" : name,
- # "password" : self.accounts[name]['password'], #: Commented due security reason
- "options" : self.accounts[name]['options'],
- "valid" : self.accounts[name]['valid'],
- "trafficleft": None, #: In bytes, -1 for unlimited
- "maxtraffic" : None,
- "premium" : None,
- "timestamp" : 0, #: Time this info was retrieved
- "type" : self.__name__}
+ return {'validuntil' : None, #: -1 for unlimited
+ 'login' : name,
+ # 'password' : self.accounts[name]['password'], #: Commented due security reason
+ 'options' : self.accounts[name]['options'],
+ 'valid' : self.accounts[name]['valid'],
+ 'trafficleft': None, #: In bytes, -1 for unlimited
+ 'maxtraffic' : None,
+ 'premium' : None,
+ 'timestamp' : 0, #: Time this info was retrieved
+ 'type' : self.__name__}
def get_all_accounts(self, force=False):
@@ -306,7 +306,7 @@ class Account(Plugin):
if user in self.infos:
self.log_warning(_("Account %s has not enough traffic, checking again in 30min") % user)
- self.infos[user].update({"trafficleft": 0})
+ self.infos[user].update({'trafficleft': 0})
self.schedule_refresh(user, 30 * 60)
@@ -314,7 +314,7 @@ class Account(Plugin):
if user in self.infos:
self.log_warning(_("Account %s is expired, checking again in 1h") % user)
- self.infos[user].update({"validuntil": time.time() - 1})
+ self.infos[user].update({'validuntil': time.time() - 1})
self.schedule_refresh(user, 60 * 60)
diff --git a/module/plugins/internal/AdYouLike.py b/module/plugins/internal/AdYouLike.py
index 64ce6e7fa..10f281494 100644
--- a/module/plugins/internal/AdYouLike.py
+++ b/module/plugins/internal/AdYouLike.py
@@ -37,8 +37,8 @@ class AdYouLike(Captcha):
def challenge(self, key=None, html=None):
ayl, callback = key or self.retrieve_key(html)
- #: {"adyoulike":{"key":"P~zQ~O0zV0WTiAzC-iw0navWQpCLoYEP"},
- #: "all":{"element_id":"ayl_private_cap_92300","lang":"fr","env":"prod"}}
+ #: {'adyoulike':{'key':"P~zQ~O0zV0WTiAzC-iw0navWQpCLoYEP"},
+ #: 'all':{'element_id':"ayl_private_cap_92300",'lang':"fr",'env':"prod"}}
ayl = json_loads(ayl)
html = self.plugin.load("http://api-ayl.appspot.com/challenge",
@@ -58,14 +58,14 @@ class AdYouLike(Captcha):
def result(self, server, challenge):
#: Adyoulike.g._jsonp_5579316662423138
- #: ({"translations":{"fr":{"instructions_visual":"Recopiez « Soonnight » ci-dessous :"}},
- #: "site_under":true,"clickable":true,"pixels":{"VIDEO_050":[],"DISPLAY":[],"VIDEO_000":[],"VIDEO_100":[],
- #: "VIDEO_025":[],"VIDEO_075":[]},"medium_type":"image/adyoulike",
- #: "iframes":{"big":"<iframe src=\"http://www.soonnight.com/campagn.html\" scrolling=\"no\"
- #: height=\"250\" width=\"300\" frameborder=\"0\"></iframe>"},"shares":{},"id":256,
- #: "token":"e6QuI4aRSnbIZJg02IsV6cp4JQ9~MjA1","formats":{"small":{"y":300,"x":0,"w":300,"h":60},
- #: "big":{"y":0,"x":0,"w":300,"h":250},"hover":{"y":440,"x":0,"w":300,"h":60}},
- #: "tid":"SqwuAdxT1EZoi4B5q0T63LN2AkiCJBg5"})
+ #: ({'translations':{'fr':{'instructions_visual':"Recopiez « Soonnight » ci-dessous :"}},
+ #: 'site_under':true,'clickable':true,'pixels':{'VIDEO_050':[],'DISPLAY':[],'VIDEO_000':[],'VIDEO_100':[],
+ #: 'VIDEO_025':[],'VIDEO_075':[]},'medium_type':"image/adyoulike",
+ #: 'iframes':{'big':"<iframe src=\"http://www.soonnight.com/campagn.html\" scrolling=\"no\"
+ #: height=\"250\" width=\"300\" frameborder=\"0\"></iframe>"},'shares':{},'id':256,
+ #: 'token':"e6QuI4aRSnbIZJg02IsV6cp4JQ9~MjA1",'formats':{'small':{'y':300,'x':0,'w':300,'h':60},
+ #: 'big':{'y':0,'x':0,'w':300,'h':250},'hover':{'y':440,'x':0,'w':300,'h':60}},
+ #: 'tid':"SqwuAdxT1EZoi4B5q0T63LN2AkiCJBg5"})
if isinstance(server, basestring):
server = json_loads(server)
diff --git a/module/plugins/internal/Crypter.py b/module/plugins/internal/Crypter.py
index dbecb0cf8..9ad16ece8 100644
--- a/module/plugins/internal/Crypter.py
+++ b/module/plugins/internal/Crypter.py
@@ -80,22 +80,22 @@ class Crypter(Hoster):
pid = self.core.api.addPackage(name, self.fixurl(links), package_queue)
if package_password:
- self.core.api.setPackageData(pid, {"password": package_password})
+ self.core.api.setPackageData(pid, {'password': package_password})
#: Workaround to do not break API addPackage method
- setFolder = lambda x: self.core.api.setPackageData(pid, {"folder": x or ""})
+ setFolder = lambda x: self.core.api.setPackageData(pid, {'folder': x or ""})
if use_subfolder:
if not subfolder_per_package:
setFolder(package_folder)
- self.log_debug("Set package %(name)s folder to: %(folder)s" % {"name": name, "folder": folder})
+ self.log_debug("Set package %(name)s folder to: %(folder)s" % {'name': name, 'folder': folder})
elif not folder_per_package or name != folder:
if not folder:
folder = urlparse.urlparse(name).path.split("/")[-1]
setFolder(safe_filename(folder))
- self.log_debug("Set package %(name)s folder to: %(folder)s" % {"name": name, "folder": folder})
+ self.log_debug("Set package %(name)s folder to: %(folder)s" % {'name': name, 'folder': folder})
elif folder_per_package:
setFolder(None)
diff --git a/module/plugins/internal/Extractor.py b/module/plugins/internal/Extractor.py
index 929ef5378..39220508e 100644
--- a/module/plugins/internal/Extractor.py
+++ b/module/plugins/internal/Extractor.py
@@ -67,7 +67,7 @@ class Extractor(Plugin):
for fname, id, fout in files_ids:
if cls.isArchive(fname):
- pname = re.sub(cls.re_multipart, '', fname) if cls.isMultipart(fname) else os.path.splitext(fname)[0]
+ pname = re.sub(cls.re_multipart, "", fname) if cls.isMultipart(fname) else os.path.splitext(fname)[0]
if pname not in processed:
processed.append(pname)
targets.append((fname, id, fout))
diff --git a/module/plugins/internal/Hoster.py b/module/plugins/internal/Hoster.py
index e7df336b6..497df00f3 100644
--- a/module/plugins/internal/Hoster.py
+++ b/module/plugins/internal/Hoster.py
@@ -488,7 +488,7 @@ class Hoster(Plugin):
newname = urlparse.urlparse(newname).path.split('/')[-1]
if disposition and newname != name:
- self.log_info(_("%(name)s saved as %(newname)s") % {"name": name, "newname": newname})
+ self.log_info(_("%(name)s saved as %(newname)s") % {'name': name, 'newname': newname})
self.pyfile.name = newname
filename = os.path.join(location, newname)
@@ -595,7 +595,7 @@ class Hoster(Plugin):
req.close()
- header = {"code": req.code}
+ header = {'code': req.code}
for line in res.splitlines():
line = line.strip()
if not line or ":" not in line:
diff --git a/module/plugins/internal/OCR.py b/module/plugins/internal/OCR.py
index 387db1d13..a00f53947 100644
--- a/module/plugins/internal/OCR.py
+++ b/module/plugins/internal/OCR.py
@@ -42,7 +42,7 @@ class OCR(Plugin):
def load_image(self, image):
self.image = Image.open(image)
self.pixels = self.image.load()
- self.result_captcha = ''
+ self.result_captcha = ""
def deactivate(self):
diff --git a/module/plugins/internal/Plugin.py b/module/plugins/internal/Plugin.py
index d0f75a8a3..7dec6344e 100644
--- a/module/plugins/internal/Plugin.py
+++ b/module/plugins/internal/Plugin.py
@@ -123,6 +123,14 @@ class Plugin(object):
def __init__(self, core):
self.core = core
self.info = {} #: Provide information in dict here
+ self.init()
+
+
+ def init(self):
+ """
+ Initialize the plugin (in addition to `__init__`)
+ """
+ pass
def _log(self, level, args):
@@ -309,7 +317,7 @@ class Plugin(object):
if just_header:
#: Parse header
- header = {"code": req.code}
+ header = {'code': req.code}
for line in res.splitlines():
line = line.strip()
if not line or ":" not in line:
diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py
index 911a7d411..40489d404 100644
--- a/module/plugins/internal/SimpleHoster.py
+++ b/module/plugins/internal/SimpleHoster.py
@@ -361,7 +361,7 @@ class SimpleHoster(Hoster):
if re.search('da(il)?y|today', errmsg, re.I):
wait_time = seconds_to_midnight(gmt=2)
else:
- wait_time = sum(int(v) * {"hr": 3600, "hour": 3600, "min": 60, "sec": 1, "": 1}[u.lower()] for v, u in
+ wait_time = sum(int(v) * {'hr': 3600, 'hour': 3600, 'min': 60, 'sec': 1, "": 1}[u.lower()] for v, u in
re.findall(r'(\d+)\s*(hr|hour|min|sec|)', errmsg, re.I))
self.want_reconnect = wait_time > 300
@@ -385,7 +385,7 @@ class SimpleHoster(Hoster):
if re.search("da(il)?y|today", errmsg):
wait_time = seconds_to_midnight(gmt=2)
else:
- wait_time = sum(int(v) * {"hr": 3600, "hour": 3600, "min": 60, "sec": 1, "": 1}[u.lower()] for v, u in
+ wait_time = sum(int(v) * {'hr': 3600, 'hour': 3600, 'min': 60, 'sec': 1, "": 1}[u.lower()] for v, u in
re.findall(r'(\d+)\s*(hr|hour|min|sec|)', errmsg, re.I))
self.want_reconnect = wait_time > 300
@@ -430,7 +430,7 @@ class SimpleHoster(Hoster):
except Exception:
waitmsg = m.group(0).strip()
- wait_time = sum(int(v) * {"hr": 3600, "hour": 3600, "min": 60, "sec": 1, "": 1}[u.lower()] for v, u in
+ wait_time = sum(int(v) * {'hr': 3600, 'hour': 3600, 'min': 60, 'sec': 1, "": 1}[u.lower()] for v, u in
re.findall(r'(\d+)\s*(hr|hour|min|sec|)', waitmsg, re.I))
self.wait(wait_time, wait_time > 300)