From 48c743058bd280d62d2aa9f2db56d894b502a8d9 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 14 Dec 2015 03:44:18 +0100 Subject: Update addons --- module/plugins/hooks/AntiStandby.py | 28 ++++++++--------- module/plugins/hooks/BypassCaptcha.py | 17 ++++++----- module/plugins/hooks/Captcha9Kw.py | 48 +++++++++++++++--------------- module/plugins/hooks/CaptchaBrotherhood.py | 24 ++++++++------- module/plugins/hooks/DeathByCaptcha.py | 24 +++++++-------- module/plugins/hooks/DeleteFinished.py | 6 ++-- module/plugins/hooks/DownloadScheduler.py | 6 ++-- module/plugins/hooks/ExpertDecoders.py | 23 +++++++------- module/plugins/hooks/HotFolder.py | 17 +++++------ module/plugins/hooks/ImageTyperz.py | 31 +++++++++---------- module/plugins/hooks/JustPremium.py | 6 ++-- module/plugins/hooks/LogMarker.py | 10 +++---- module/plugins/hooks/MultiHome.py | 6 ++-- module/plugins/hooks/RestartFailed.py | 4 +-- module/plugins/hooks/TransmissionRPC.py | 6 ++-- module/plugins/hooks/UnSkipOnFail.py | 18 ++++------- module/plugins/hooks/UserAgentSwitcher.py | 10 +++---- 17 files changed, 139 insertions(+), 145 deletions(-) (limited to 'module') diff --git a/module/plugins/hooks/AntiStandby.py b/module/plugins/hooks/AntiStandby.py index 5ad95d6e8..34f9dd832 100644 --- a/module/plugins/hooks/AntiStandby.py +++ b/module/plugins/hooks/AntiStandby.py @@ -12,8 +12,8 @@ try: except ImportError: pass -from module.plugins.internal.Addon import Addon, Expose -from module.plugins.internal.utils import encode, fs_join +from module.plugins.internal.Addon import Addon +from module.plugins.internal.misc import Expose, encode, fsjoin class Kernel32(object): @@ -27,7 +27,7 @@ class Kernel32(object): class AntiStandby(Addon): __name__ = "AntiStandby" __type__ = "hook" - __version__ = "0.13" + __version__ = "0.14" __status__ = "testing" __config__ = [("activated", "bool", "Activated" , True ), @@ -50,12 +50,12 @@ class AntiStandby(Addon): def activate(self): - hdd = self.get_config('hdd') - system = not self.get_config('system') - display = not self.get_config('display') + hdd = self.config.get('hdd') + system = not self.config.get('system') + display = not self.config.get('display') if hdd: - self.start_periodical(self.get_config('interval'), threaded=True) + self.start_periodical(self.config.get('interval'), threaded=True) if os.name is "nt": self.win_standby(system, display) @@ -68,11 +68,7 @@ class AntiStandby(Addon): def deactivate(self): - try: - os.remove(self.TMP_FILE) - - except OSError: - pass + self.remove(self.TMP_FILE, trash=False) if os.name is "nt": self.win_standby(True) @@ -152,18 +148,18 @@ class AntiStandby(Addon): @Expose def max_mtime(self, path): return max(0, 0, - *(os.path.getmtime(fs_join(root, file)) + *(os.path.getmtime(fsjoin(root, file)) for root, dirs, files in os.walk(encode(path), topdown=False) for file in files)) def periodical(self): - if self.get_config('hdd') is False: + if self.config.get('hdd') is False: return if (self.pyload.threadManager.pause or - not self.pyload.api.isTimeDownload() or - not self.pyload.threadManager.getActiveFiles()): + not self.pyload.api.isTimeDownload() or + not self.pyload.threadManager.getActiveFiles()): return dl_folder = self.pyload.config.get("general", "download_folder") diff --git a/module/plugins/hooks/BypassCaptcha.py b/module/plugins/hooks/BypassCaptcha.py index 581d2f6dd..bc34f1239 100644 --- a/module/plugins/hooks/BypassCaptcha.py +++ b/module/plugins/hooks/BypassCaptcha.py @@ -4,7 +4,8 @@ import pycurl from module.network.HTTPRequest import BadHeader from module.network.RequestFactory import getRequest as get_request -from module.plugins.internal.Addon import Addon, threaded +from module.plugins.internal.Addon import Addon +from module.plugins.internal.misc import threaded class BypassCaptchaException(Exception): @@ -28,7 +29,7 @@ class BypassCaptchaException(Exception): class BypassCaptcha(Addon): __name__ = "BypassCaptcha" __type__ = "hook" - __version__ = "0.09" + __version__ = "0.10" __status__ = "testing" __config__ = [("activated" , "bool" , "Activated" , False), @@ -50,7 +51,7 @@ class BypassCaptcha(Addon): def get_credits(self): - res = self.load(self.GETCREDITS_URL, post={'key': self.get_config('passkey')}) + res = self.load(self.GETCREDITS_URL, post={'key': self.config.get('passkey')}) data = dict(x.split(' ', 1) for x in res.splitlines()) return int(data['Left']) @@ -65,7 +66,7 @@ class BypassCaptcha(Addon): try: res = self.load(self.SUBMIT_URL, post={'vendor_key': self.PYLOAD_KEY, - 'key': self.get_config('passkey'), + 'key': self.config.get('passkey'), 'gen_task_id': "1", 'file': (pycurl.FORM_FILE, captcha)}, req=req) @@ -85,7 +86,7 @@ class BypassCaptcha(Addon): def respond(self, ticket, success): try: - res = self.load(self.RESPOND_URL, post={'task_id': ticket, 'key': self.get_config('passkey'), + res = self.load(self.RESPOND_URL, post={'task_id': ticket, 'key': self.config.get('passkey'), 'cv': 1 if success else 0}) except BadHeader, e: self.log_error(_("Could not send response"), e) @@ -98,10 +99,10 @@ class BypassCaptcha(Addon): if not task.isTextual(): return False - if not self.get_config('passkey'): + if not self.config.get('passkey'): return False - if self.pyload.isClientConnected() and self.get_config('check_client'): + if self.pyload.isClientConnected() and self.config.get('check_client'): return False if self.get_credits() > 0: @@ -125,7 +126,7 @@ class BypassCaptcha(Addon): @threaded - def _process_captcha(self, task): + def _process_captcha(self, task) c = task.captchaFile try: ticket, result = self.submit(c) diff --git a/module/plugins/hooks/Captcha9Kw.py b/module/plugins/hooks/Captcha9Kw.py index c81882f67..b269750ba 100644 --- a/module/plugins/hooks/Captcha9Kw.py +++ b/module/plugins/hooks/Captcha9Kw.py @@ -2,19 +2,19 @@ from __future__ import with_statement +import base64 import re import time -from base64 import b64encode - from module.network.HTTPRequest import BadHeader -from module.plugins.internal.Addon import Addon, threaded +from module.plugins.internal.Addon import Addon +from module.plugins.internal.misc import threaded class Captcha9Kw(Addon): __name__ = "Captcha9Kw" __type__ = "hook" - __version__ = "0.31" + __version__ = "0.32" __status__ = "testing" __config__ = [("activated" , "bool" , "Activated" , False ), @@ -40,7 +40,7 @@ class Captcha9Kw(Addon): def get_credits(self): res = self.load(self.API_URL, - get={'apikey': self.get_config('passkey'), + get={'apikey': self.config.get('passkey'), 'pyload': "1", 'source': "pyload", 'action': "usercaptchaguthaben"}) @@ -55,7 +55,7 @@ class Captcha9Kw(Addon): @threaded - def _process_captcha(self, task): + def _process_captcha(self, task) try: with open(task.captchaFile, 'rb') as f: data = f.read() @@ -71,14 +71,14 @@ class Captcha9Kw(Addon): 'numeric' : 0, 'case_sensitive': 0, 'math' : 0, - 'prio' : min(max(self.get_config('prio'), 0), 10), - 'confirm' : self.get_config('confirm'), - 'timeout' : min(max(self.get_config('timeout'), 300), 3999), - 'selfsolve' : self.get_config('selfsolve'), - 'cph' : self.get_config('captchaperhour'), - 'cpm' : self.get_config('captchapermin')} - - for opt in str(self.get_config('hoster_options').split('|')): + 'prio' : min(max(self.config.get('prio'), 0), 10), + 'confirm' : self.config.get('confirm'), + 'timeout' : min(max(self.config.get('timeout'), 300), 3999), + 'selfsolve' : self.config.get('selfsolve'), + 'cph' : self.config.get('captchaperhour'), + 'cpm' : self.config.get('captchapermin')} + + for opt in str(self.config.get('hoster_options').split('|')): details = map(str.strip, opt.split(':')) if not details or details[0].lower() is not pluginname.lower(): @@ -96,7 +96,7 @@ class Captcha9Kw(Addon): break - post_data = {'apikey' : self.get_config('passkey'), + post_data = {'apikey' : self.config.get('passkey'), 'prio' : option['prio'], 'confirm' : option['confirm'], 'maxtimeout' : option['timeout'], @@ -114,7 +114,7 @@ class Captcha9Kw(Addon): 'source' : "pyload", 'base64' : 1, 'mouse' : 1 if task.isPositional() else 0, - 'file-upload-01': b64encode(data), + 'file-upload-01': base64.b64encode(data), 'action' : "usercaptchaupload"} for _i in xrange(5): @@ -136,9 +136,9 @@ class Captcha9Kw(Addon): task.data['ticket'] = res - for _i in xrange(int(self.get_config('timeout') / 5)): + for _i in xrange(int(self.config.get('timeout') / 5)): result = self.load(self.API_URL, - get={'apikey': self.get_config('passkey'), + get={'apikey': self.config.get('passkey'), 'id' : res, 'pyload': "1", 'info' : "1", @@ -163,10 +163,10 @@ class Captcha9Kw(Addon): if not task.isTextual() and not task.isPositional(): return - if not self.get_config('passkey'): + if not self.config.get('passkey'): return - if self.pyload.isClientConnected() and self.get_config('check_client'): + if self.pyload.isClientConnected() and self.config.get('check_client'): return credits = self.get_credits() @@ -175,8 +175,8 @@ class Captcha9Kw(Addon): self.log_error(_("Your captcha 9kw.eu account has not enough credits")) return - queue = min(self.get_config('queue'), 999) - timeout = min(max(self.get_config('timeout'), 300), 3999) + queue = min(self.config.get('queue'), 999) + timeout = min(max(self.config.get('timeout'), 300), 3999) pluginname = re.search(r'_(.+?)_\d+.\w+', task.captchaFile).group(1) for _i in xrange(5): @@ -189,7 +189,7 @@ class Captcha9Kw(Addon): else: self.fail(_("Too many captchas in queue")) - for opt in str(self.get_config('hoster_options').split('|')): + for opt in str(self.config.get('hoster_options').split('|')): details = map(str.strip, opt.split(':')) if not details or details[0].lower() is not pluginname.lower(): @@ -219,7 +219,7 @@ class Captcha9Kw(Addon): self.log_debug("No CaptchaID for %s request (task: %s)" % (type, task)) return - passkey = self.get_config('passkey') + passkey = self.config.get('passkey') for _i in xrange(3): res = self.load(self.API_URL, diff --git a/module/plugins/hooks/CaptchaBrotherhood.py b/module/plugins/hooks/CaptchaBrotherhood.py index 5334c1c5b..ba29d809e 100644 --- a/module/plugins/hooks/CaptchaBrotherhood.py +++ b/module/plugins/hooks/CaptchaBrotherhood.py @@ -3,10 +3,11 @@ from __future__ import with_statement import StringIO -import pycurl import time import urllib +import pycurl + try: from PIL import Image @@ -14,7 +15,8 @@ except ImportError: import Image from module.network.RequestFactory import getRequest as get_request -from module.plugins.internal.Addon import Addon, threaded +from module.plugins.internal.Addon import Addon +from module.plugins.internal.misc import threaded class CaptchaBrotherhoodException(Exception): @@ -38,7 +40,7 @@ class CaptchaBrotherhoodException(Exception): class CaptchaBrotherhood(Addon): __name__ = "CaptchaBrotherhood" __type__ = "hook" - __version__ = "0.11" + __version__ = "0.12" __status__ = "testing" __config__ = [("activated" , "bool" , "Activated" , False), @@ -57,7 +59,7 @@ class CaptchaBrotherhood(Addon): def get_credits(self): res = self.load(self.API_URL + "askCredits.aspx", - get={'username': self.get_config('username'), 'password': self.get_config('password')}) + get={'username': self.config.get('username'), 'password': self.config.get('password')}) if not res.startswith("OK"): raise CaptchaBrotherhoodException(res) else: @@ -87,8 +89,8 @@ class CaptchaBrotherhood(Addon): req = get_request() url = "%ssendNewCaptcha.aspx?%s" % (self.API_URL, - urllib.urlencode({'username' : self.get_config('username'), - 'password' : self.get_config('password'), + urllib.urlencode({'username' : self.config.get('username'), + 'password' : self.config.get('password'), 'captchaSource': "pyLoad", 'timeout' : "80"})) @@ -122,8 +124,8 @@ class CaptchaBrotherhood(Addon): def api_response(self, api, ticket): res = self.load("%s%s.aspx" % (self.API_URL, api), - get={'username': self.get_config('username'), - 'password': self.get_config('password'), + get={'username': self.config.get('username'), + 'password': self.config.get('password'), 'captchaID': ticket}) if not res.startswith("OK"): raise CaptchaBrotherhoodException("Unknown response: %s" % res) @@ -138,10 +140,10 @@ class CaptchaBrotherhood(Addon): if not task.isTextual(): return False - if not self.get_config('username') or not self.get_config('password'): + if not self.config.get('username') or not self.config.get('password'): return False - if self.pyload.isClientConnected() and self.get_config('check_client'): + if self.pyload.isClientConnected() and self.config.get('check_client'): return False if self.get_credits() > 10: @@ -159,7 +161,7 @@ class CaptchaBrotherhood(Addon): @threaded - def _process_captcha(self, task): + def _process_captcha(self, task) c = task.captchaFile try: ticket, result = self.submit(c) diff --git a/module/plugins/hooks/DeathByCaptcha.py b/module/plugins/hooks/DeathByCaptcha.py index 5c1c89c88..bce13f0fa 100644 --- a/module/plugins/hooks/DeathByCaptcha.py +++ b/module/plugins/hooks/DeathByCaptcha.py @@ -2,16 +2,16 @@ from __future__ import with_statement -import pycurl +import base64 import re import time -from base64 import b64encode +import pycurl -from module.plugins.internal.utils import json from module.network.HTTPRequest import BadHeader from module.network.RequestFactory import getRequest as get_request -from module.plugins.internal.Addon import Addon, threaded +from module.plugins.internal.Addon import Addon +from module.plugins.internal.misc import json, threaded class DeathByCaptchaException(Exception): @@ -51,7 +51,7 @@ class DeathByCaptchaException(Exception): class DeathByCaptcha(Addon): __name__ = "DeathByCaptcha" __type__ = "hook" - __version__ = "0.10" + __version__ = "0.11" __status__ = "testing" __config__ = [("activated" , "bool" , "Activated" , False), @@ -75,8 +75,8 @@ class DeathByCaptcha(Addon): if post: if not isinstance(post, dict): post = {} - post.update({'username': self.get_config('username'), - 'password': self.get_config('password')}) + post.update({'username': self.config.get('username'), + 'password': self.config.get('password')}) res = None try: @@ -135,14 +135,14 @@ class DeathByCaptcha(Addon): def submit(self, captcha, captchaType="file", match=None): #@NOTE: Workaround multipart-post bug in HTTPRequest.py - if re.match("^\w*$", self.get_config('password')): + if re.match("^\w*$", self.config.get('password')): multipart = True data = (pycurl.FORM_FILE, captcha) else: multipart = False with open(captcha, 'rb') as f: data = f.read() - data = "base64:" + b64encode(data) + data = "base64:" + base64.b64encode(data) res = self.api_response("captcha", {'captchafile': data}, multipart) @@ -171,10 +171,10 @@ class DeathByCaptcha(Addon): if not task.isTextual(): return False - if not self.get_config('username') or not self.get_config('password'): + if not self.config.get('username') or not self.config.get('password'): return False - if self.pyload.isClientConnected() and self.get_config('check_client'): + if self.pyload.isClientConnected() and self.config.get('check_client'): return False try: @@ -209,7 +209,7 @@ class DeathByCaptcha(Addon): @threaded - def _process_captcha(self, task): + def _process_captcha(self, task) c = task.captchaFile try: ticket, result = self.submit(c) diff --git a/module/plugins/hooks/DeleteFinished.py b/module/plugins/hooks/DeleteFinished.py index 17b85959a..fa68ef19c 100644 --- a/module/plugins/hooks/DeleteFinished.py +++ b/module/plugins/hooks/DeleteFinished.py @@ -7,7 +7,7 @@ from module.plugins.internal.Addon import Addon class DeleteFinished(Addon): __name__ = "DeleteFinished" __type__ = "hook" - __version__ = "1.17" + __version__ = "1.18" __status__ = "testing" __config__ = [("activated" , "bool", "Activated" , False), @@ -24,7 +24,7 @@ class DeleteFinished(Addon): def periodical(self): if not self.info['sleep']: - deloffline = self.get_config('deloffline') + deloffline = self.config.get('deloffline') mode = "0,1,4" if deloffline else "0,4" msg = _('delete all finished packages in queue list (%s packages with offline links)') self.log_info(msg % (_('including') if deloffline else _('excluding'))) @@ -39,7 +39,7 @@ class DeleteFinished(Addon): def activate(self): self.info['sleep'] = True - self.set_interval(self.get_config('interval') * 60 * 60) + self.set_interval(self.config.get('interval') * 60 * 60) self.add_event('package_finished', self.wakeup) diff --git a/module/plugins/hooks/DownloadScheduler.py b/module/plugins/hooks/DownloadScheduler.py index 9c644ab20..d4c0356fd 100644 --- a/module/plugins/hooks/DownloadScheduler.py +++ b/module/plugins/hooks/DownloadScheduler.py @@ -9,7 +9,7 @@ from module.plugins.internal.Addon import Addon class DownloadScheduler(Addon): __name__ = "DownloadScheduler" __type__ = "hook" - __version__ = "0.25" + __version__ = "0.26" __status__ = "testing" __config__ = [("activated", "bool", "Activated" , False ), @@ -28,7 +28,7 @@ class DownloadScheduler(Addon): def update_schedule(self, schedule=None): if schedule is None: - schedule = self.get_config('timetable') + schedule = self.config.get('timetable') schedule = re.findall("(\d{1,2}):(\d{2})[\s]*(-?\d+)", schedule.lower().replace("full", "-1").replace("none", "0")) @@ -56,7 +56,7 @@ class DownloadScheduler(Addon): def set_download_speed(self, speed): if speed == 0: - abort = self.get_config('abort') + abort = self.config.get('abort') self.log_info(_("Stopping download server. (Running downloads will %sbe aborted.)") % '' if abort else _('not ')) self.pyload.api.pauseServer() if abort: diff --git a/module/plugins/hooks/ExpertDecoders.py b/module/plugins/hooks/ExpertDecoders.py index 55c07d4b9..9c7f129cb 100644 --- a/module/plugins/hooks/ExpertDecoders.py +++ b/module/plugins/hooks/ExpertDecoders.py @@ -2,20 +2,21 @@ from __future__ import with_statement -import pycurl +import base64 import uuid -from base64 import b64encode +import pycurl from module.network.HTTPRequest import BadHeader from module.network.RequestFactory import getRequest as get_request -from module.plugins.internal.Addon import Addon, threaded +from module.plugins.internal.Addon import Addon +from module.plugins.internal.misc import threaded class ExpertDecoders(Addon): __name__ = "ExpertDecoders" __type__ = "hook" - __version__ = "0.07" + __version__ = "0.08" __status__ = "testing" __config__ = [("activated" , "bool" , "Activated" , False), @@ -32,7 +33,7 @@ class ExpertDecoders(Addon): def get_credits(self): - res = self.load(self.API_URL, post={'key': self.get_config('passkey'), 'action': "balance"}) + res = self.load(self.API_URL, post={'key': self.config.get('passkey'), 'action': "balance"}) if res.isdigit(): self.log_info(_("%s credits left") % res) @@ -44,7 +45,7 @@ class ExpertDecoders(Addon): @threaded - def _process_captcha(self, task): + def _process_captcha(self, task) task.data['ticket'] = ticket = uuid.uuid4() result = None @@ -58,8 +59,8 @@ class ExpertDecoders(Addon): try: result = self.load(self.API_URL, post={'action' : "upload", - 'key' : self.get_config('passkey'), - 'file' : b64encode(data), + 'key' : self.config.get('passkey'), + 'file' : base64.b64encode(data), 'gen_task_id': ticket}, req=req) finally: @@ -73,10 +74,10 @@ class ExpertDecoders(Addon): if not task.isTextual(): return False - if not self.get_config('passkey'): + if not self.config.get('passkey'): return False - if self.pyload.isClientConnected() and self.get_config('check_client'): + if self.pyload.isClientConnected() and self.config.get('check_client'): return False if self.get_credits() > 0: @@ -93,7 +94,7 @@ class ExpertDecoders(Addon): try: res = self.load(self.API_URL, - post={'action': "refund", 'key': self.get_config('passkey'), 'gen_task_id': task.data['ticket']}) + post={'action': "refund", 'key': self.config.get('passkey'), 'gen_task_id': task.data['ticket']}) self.log_info(_("Request refund"), res) except BadHeader, e: diff --git a/module/plugins/hooks/HotFolder.py b/module/plugins/hooks/HotFolder.py index c89083fb1..1af427b25 100644 --- a/module/plugins/hooks/HotFolder.py +++ b/module/plugins/hooks/HotFolder.py @@ -3,17 +3,16 @@ from __future__ import with_statement import os -import shutil import time from module.plugins.internal.Addon import Addon -from module.plugins.internal.utils import encode, fs_join +from module.plugins.internal.misc import encode, fsjoin, move_tree class HotFolder(Addon): __name__ = "HotFolder" __type__ = "hook" - __version__ = "0.20" + __version__ = "0.21" __status__ = "testing" __config__ = [("activated", "bool", "Activated" , False ), @@ -32,14 +31,14 @@ class HotFolder(Addon): def periodical(self): - folder = encode(self.get_config('folder')) - file = encode(self.get_config('file')) + folder = encode(self.config.get('folder')) + file = encode(self.config.get('file')) try: if not os.path.isdir(os.path.join(folder, "finished")): os.makedirs(os.path.join(folder, "finished")) - if self.get_config('watchfile'): + if self.config.get('watchfile'): with open(file, "a+") as f: f.seek(0) content = f.read().strip() @@ -50,7 +49,7 @@ class HotFolder(Addon): name = "%s_%s.txt" % (file, time.strftime("%H-%M-%S_%d%b%Y")) - with open(fs_join(folder, "finished", name), "wb") as f: + with open(fsjoin(folder, "finished", name), "wb") as f: f.write(content) self.pyload.api.addPackage(f.name, [f.name], 1) @@ -61,8 +60,8 @@ class HotFolder(Addon): if not os.path.isfile(path) or f.endswith("~") or f.startswith("#") or f.startswith("."): continue - newpath = os.path.join(folder, "finished", "tmp_" + f if self.get_config('delete') else f) - shutil.move(path, newpath) + newpath = os.path.join(folder, "finished", "tmp_" + f if self.config.get('delete') else f) + move_tree(path, newpath) self.log_info(_("Added %s from HotFolder") % f) self.pyload.api.addPackage(f, [newpath], 1) diff --git a/module/plugins/hooks/ImageTyperz.py b/module/plugins/hooks/ImageTyperz.py index 656ad0c25..24e1687a8 100644 --- a/module/plugins/hooks/ImageTyperz.py +++ b/module/plugins/hooks/ImageTyperz.py @@ -2,13 +2,14 @@ from __future__ import with_statement -import pycurl +import base64 import re -from base64 import b64encode +import pycurl from module.network.RequestFactory import getRequest as get_request -from module.plugins.internal.Addon import Addon, threaded +from module.plugins.internal.Addon import Addon +from module.plugins.internal.misc import threaded class ImageTyperzException(Exception): @@ -32,7 +33,7 @@ class ImageTyperzException(Exception): class ImageTyperz(Addon): __name__ = "ImageTyperz" __type__ = "hook" - __version__ = "0.09" + __version__ = "0.10" __status__ = "testing" __config__ = [("activated" , "bool" , "Activated" , False), @@ -54,8 +55,8 @@ class ImageTyperz(Addon): def get_credits(self): res = self.load(self.GETCREDITS_URL, post={'action': "REQUESTBALANCE", - 'username': self.get_config('username'), - 'password': self.get_config('password')}) + 'username': self.config.get('username'), + 'password': self.config.get('password')}) if res.startswith('ERROR'): raise ImageTyperzException(res) @@ -77,19 +78,19 @@ class ImageTyperz(Addon): try: #@NOTE: Workaround multipart-post bug in HTTPRequest.py - if re.match("^\w*$", self.get_config('password')): + if re.match("^\w*$", self.config.get('password')): multipart = True data = (pycurl.FORM_FILE, captcha) else: multipart = False with open(captcha, 'rb') as f: data = f.read() - data = b64encode(data) + data = base64.b64encode(data) res = self.load(self.SUBMIT_URL, post={'action': "UPLOADCAPTCHA", - 'username': self.get_config('username'), - 'password': self.get_config('password'), 'file': data}, + 'username': self.config.get('username'), + 'password': self.config.get('password'), 'file': data}, multipart=multipart, req=req) finally: @@ -114,10 +115,10 @@ class ImageTyperz(Addon): if not task.isTextual(): return False - if not self.get_config('username') or not self.get_config('password'): + if not self.config.get('username') or not self.config.get('password'): return False - if self.pyload.isClientConnected() and self.get_config('check_client'): + if self.pyload.isClientConnected() and self.config.get('check_client'): return False if self.get_credits() > 0: @@ -134,8 +135,8 @@ class ImageTyperz(Addon): if task.data['service'] is self.classname and "ticket" in task.data: res = self.load(self.RESPOND_URL, post={'action': "SETBADIMAGE", - 'username': self.get_config('username'), - 'password': self.get_config('password'), + 'username': self.config.get('username'), + 'password': self.config.get('password'), 'imageid': task.data['ticket']}) if res == "SUCCESS": @@ -145,7 +146,7 @@ class ImageTyperz(Addon): @threaded - def _process_captcha(self, task): + def _process_captcha(self, task) c = task.captchaFile try: ticket, result = self.submit(c) diff --git a/module/plugins/hooks/JustPremium.py b/module/plugins/hooks/JustPremium.py index 3f7388020..2492498cb 100644 --- a/module/plugins/hooks/JustPremium.py +++ b/module/plugins/hooks/JustPremium.py @@ -8,7 +8,7 @@ from module.plugins.internal.Addon import Addon class JustPremium(Addon): __name__ = "JustPremium" __type__ = "hook" - __version__ = "0.25" + __version__ = "0.26" __status__ = "testing" __config__ = [("activated", "bool", "Activated" , False), @@ -37,9 +37,9 @@ class JustPremium(Addon): and hosterdict[hoster]['new_name'] in premiumplugins) excluded = map(lambda domain: "".join(part.capitalize() for part in re.split(r'(\.|\d+)', domain) if part != '.'), - self.get_config('excluded').replace(' ', '').replace(',', '|').replace(';', '|').split('|')) + self.config.get('excluded').replace(' ', '').replace(',', '|').replace(';', '|').split('|')) included = map(lambda domain: "".join(part.capitalize() for part in re.split(r'(\.|\d+)', domain) if part != '.'), - self.get_config('included').replace(' ', '').replace(',', '|').replace(';', '|').split('|')) + self.config.get('included').replace(' ', '').replace(',', '|').replace(';', '|').split('|')) hosterlist = (premiumplugins | multihosters).union(excluded).difference(included) diff --git a/module/plugins/hooks/LogMarker.py b/module/plugins/hooks/LogMarker.py index 829db4d41..e51fa6e3d 100644 --- a/module/plugins/hooks/LogMarker.py +++ b/module/plugins/hooks/LogMarker.py @@ -2,14 +2,14 @@ import datetime -from module.plugins.internal.Addon import Addon, Expose -from module.plugins.internal.utils import seconds_to_nexthour +from module.plugins.internal.Addon import Addon +from module.plugins.internal.misc import Expose, seconds_to_nexthour class LogMarker(Addon): __name__ = "LogMarker" __type__ = "hook" - __version__ = "0.04" + __version__ = "0.05" __status__ = "testing" __config__ = [("activated", "bool", "Activated" , False), @@ -26,12 +26,12 @@ class LogMarker(Addon): def periodical(self): - if self.get_config('mark_day') and datetime.datetime.today().hour is 0: + if self.config.get('mark_day') and datetime.datetime.today().hour is 0: self.log_info("------------------------------------------------") self.log_info(_("------------------- DAY MARK -------------------")) self.log_info("------------------------------------------------") - elif self.get_config('mark_hour'): + elif self.config.get('mark_hour'): self.log_info("------------------------------------------------") self.log_info(_("------------------- HOUR MARK ------------------")) self.log_info("------------------------------------------------") diff --git a/module/plugins/hooks/MultiHome.py b/module/plugins/hooks/MultiHome.py index 353753c1a..c8c5f4fa7 100644 --- a/module/plugins/hooks/MultiHome.py +++ b/module/plugins/hooks/MultiHome.py @@ -44,7 +44,7 @@ class Interface(object): class MultiHome(Addon): __name__ = "MultiHome" __type__ = "hook" - __version__ = "0.15" + __version__ = "0.16" __status__ = "testing" __config__ = [("activated" , "bool", "Activated" , False ), @@ -59,11 +59,11 @@ class MultiHome(Addon): self.register = {} self.interfaces = [] - self.parse_interfaces(self.get_config('interfaces').split(";")) + self.parse_interfaces(self.config.get('interfaces').split(";")) if not self.interfaces: self.parse_interfaces([self.pyload.config.get("download", "interface")]) - self.set_config("interfaces", self.to_config()) + self.config.set("interfaces", self.to_config()) def to_config(self): diff --git a/module/plugins/hooks/RestartFailed.py b/module/plugins/hooks/RestartFailed.py index 0e35c4629..33573a317 100644 --- a/module/plugins/hooks/RestartFailed.py +++ b/module/plugins/hooks/RestartFailed.py @@ -6,7 +6,7 @@ from module.plugins.internal.Addon import Addon class RestartFailed(Addon): __name__ = "RestartFailed" __type__ = "hook" - __version__ = "1.63" + __version__ = "1.64" __status__ = "testing" __config__ = [("activated", "bool", "Activated" , False), @@ -26,4 +26,4 @@ class RestartFailed(Addon): def activate(self): - self.set_interval(self.get_config('interval') * 60) + self.set_interval(self.config.get('interval') * 60) diff --git a/module/plugins/hooks/TransmissionRPC.py b/module/plugins/hooks/TransmissionRPC.py index 7914d5c44..0bc163d98 100644 --- a/module/plugins/hooks/TransmissionRPC.py +++ b/module/plugins/hooks/TransmissionRPC.py @@ -5,16 +5,16 @@ import re import pycurl -from module.plugins.internal.utils import json from module.network.HTTPRequest import BadHeader from module.network.RequestFactory import getRequest as get_request from module.plugins.internal.Addon import Addon +from module.plugins.internal.misc import json class TransmissionRPC(Addon): __name__ = "TransmissionRPC" __type__ = "hook" - __version__ = "0.16" + __version__ = "0.17" __status__ = "testing" __pattern__ = r"https?://.+\.torrent|magnet:\?.+" @@ -41,7 +41,7 @@ class TransmissionRPC(Addon): def send_to_transmission(self, url): - transmission_rpc_url = self.get_config('rpc_url') + transmission_rpc_url = self.config.get('rpc_url') client_request_id = self.classname + "".join(random.choice('0123456789ABCDEF') for _i in xrange(4)) req = get_request() diff --git a/module/plugins/hooks/UnSkipOnFail.py b/module/plugins/hooks/UnSkipOnFail.py index 6842cbc51..3dd9b70c4 100644 --- a/module/plugins/hooks/UnSkipOnFail.py +++ b/module/plugins/hooks/UnSkipOnFail.py @@ -7,7 +7,7 @@ from module.plugins.internal.Addon import Addon class UnSkipOnFail(Addon): __name__ = "UnSkipOnFail" __type__ = "hook" - __version__ = "0.10" + __version__ = "0.11" __status__ = "testing" __config__ = [("activated", "bool", "Activated", True)] @@ -18,10 +18,6 @@ class UnSkipOnFail(Addon): def download_failed(self, pyfile): - #: Check if pyfile is still "failed", maybe might has been restarted in meantime - if pyfile.status != 8: - return - msg = _("Looking for skipped duplicates of: %s (pid:%s)") self.log_info(msg % (pyfile.name, pyfile.package().id)) @@ -36,7 +32,7 @@ class UnSkipOnFail(Addon): #: It creates a temporary PyFile object using #: "link" data, changes its status, and tells #: The pyload.files-manager to save its data. - pylink = self._pyfile(link) + pylink = self.create_pyFile(link) pylink.setCustomStatus(_("unskipped"), "queued") @@ -57,15 +53,13 @@ class UnSkipOnFail(Addon): the data for "pyfile" iotselöf. It does MOT check the link's status. """ - queue = self.pyload.api.getQueue() #: Get packages (w/o files, as most file data is useless here) - - for package in queue: + for pinfo in self.pyload.api.getQueue(): #: Check if package-folder equals pyfile's package folder - if package.folder is not pyfile.package().folder: + if pinfo.folder is not pyfile.package().folder: continue #: Now get packaged data w/ files/links - pdata = self.pyload.api.getPackageData(package.pid) + pdata = self.pyload.api.getPackageData(pinfo.pid) for link in pdata.links: #: Check if link == "skipped" if link.status != 4: @@ -77,7 +71,7 @@ class UnSkipOnFail(Addon): return link - def _pyfile(self, link): + def create_pyFile(self, link): return PyFile(self.pyload.files, link.fid, link.url, diff --git a/module/plugins/hooks/UserAgentSwitcher.py b/module/plugins/hooks/UserAgentSwitcher.py index 402dd001d..4b0b13c93 100644 --- a/module/plugins/hooks/UserAgentSwitcher.py +++ b/module/plugins/hooks/UserAgentSwitcher.py @@ -3,13 +3,13 @@ import pycurl from module.plugins.internal.Addon import Addon -from module.plugins.internal.utils import encode +from module.plugins.internal.misc import encode class UserAgentSwitcher(Addon): __name__ = "UserAgentSwitcher" __type__ = "hook" - __version__ = "0.12" + __version__ = "0.13" __status__ = "testing" __config__ = [("activated" , "bool", "Activated" , True ), @@ -23,9 +23,9 @@ class UserAgentSwitcher(Addon): def download_preparing(self, pyfile): - connecttimeout = self.get_config('connecttimeout') - maxredirs = self.get_config('maxredirs') - useragent = self.get_config('useragent') + connecttimeout = self.config.get('connecttimeout') + maxredirs = self.config.get('maxredirs') + useragent = self.config.get('useragent') if connecttimeout: pyfile.plugin.req.http.c.setopt(pycurl.CONNECTTIMEOUT, connecttimeout) -- cgit v1.2.3