summaryrefslogtreecommitdiffstats
path: root/module/plugins/hooks
diff options
context:
space:
mode:
Diffstat (limited to 'module/plugins/hooks')
-rw-r--r--module/plugins/hooks/BypassCaptcha.py10
-rwxr-xr-xmodule/plugins/hooks/Captcha9kw.py5
-rw-r--r--module/plugins/hooks/CaptchaBrotherhood.py9
-rw-r--r--module/plugins/hooks/Checksum.py4
-rw-r--r--module/plugins/hooks/DeathByCaptcha.py12
-rw-r--r--module/plugins/hooks/DownloadScheduler.py3
-rw-r--r--module/plugins/hooks/ExpertDecoders.py4
-rw-r--r--module/plugins/hooks/ExtractArchive.py2
-rw-r--r--module/plugins/hooks/HotFolder.py1
-rw-r--r--module/plugins/hooks/IRCInterface.py24
-rw-r--r--module/plugins/hooks/ImageTyperz.py8
-rw-r--r--module/plugins/hooks/LinkdecrypterCom.py1
-rw-r--r--module/plugins/hooks/MergeFiles.py1
-rw-r--r--module/plugins/hooks/MultiHome.py8
-rw-r--r--module/plugins/hooks/PremiumTo.py1
-rw-r--r--module/plugins/hooks/PremiumizeMe.py1
-rw-r--r--module/plugins/hooks/RPNetBiz.py1
-rw-r--r--module/plugins/hooks/RehostTo.py1
-rw-r--r--module/plugins/hooks/RestartFailed.py3
-rw-r--r--module/plugins/hooks/UnSkipOnFail.py2
-rw-r--r--module/plugins/hooks/UpdateManager.py12
-rw-r--r--module/plugins/hooks/WindowsPhoneToastNotify.py3
-rw-r--r--module/plugins/hooks/XMPPInterface.py20
23 files changed, 136 insertions, 0 deletions
diff --git a/module/plugins/hooks/BypassCaptcha.py b/module/plugins/hooks/BypassCaptcha.py
index 984aac919..a07b2fc66 100644
--- a/module/plugins/hooks/BypassCaptcha.py
+++ b/module/plugins/hooks/BypassCaptcha.py
@@ -13,12 +13,15 @@ class BypassCaptchaException(Exception):
def __init__(self, err):
self.err = err
+
def getCode(self):
return self.err
+
def __str__(self):
return "<BypassCaptchaException %s>" % self.err
+
def __repr__(self):
return "<BypassCaptchaException %s>" % self.err
@@ -49,12 +52,14 @@ class BypassCaptcha(Hook):
def setup(self):
self.info = {}
+
def getCredits(self):
response = getURL(self.GETCREDITS_URL, post={"key": self.getConfig("passkey")})
data = dict([x.split(' ', 1) for x in response.splitlines()])
return int(data['Left'])
+
def submit(self, captcha, captchaType="file", match=None):
req = getRequest()
@@ -81,6 +86,7 @@ class BypassCaptcha(Hook):
return ticket, result
+
def respond(self, ticket, success):
try:
response = getURL(self.RESPOND_URL, post={"task_id": ticket, "key": self.getConfig("passkey"),
@@ -88,6 +94,7 @@ class BypassCaptcha(Hook):
except BadHeader, e:
self.logError(_("Could not send response."), e
+
def newCaptchaTask(self, task):
if "service" in task.data:
return False
@@ -110,14 +117,17 @@ class BypassCaptcha(Hook):
else:
self.logInfo(_("Your %s account has not enough credits") % self.__name__)
+
def captchaCorrect(self, task):
if task.data['service'] == self.__name__ and "ticket" in task.data:
self.respond(task.data['ticket'], True)
+
def captchaInvalid(self, task):
if task.data['service'] == self.__name__ and "ticket" in task.data:
self.respond(task.data['ticket'], False)
+
def processCaptcha(self, task):
c = task.captchaFile
try:
diff --git a/module/plugins/hooks/Captcha9kw.py b/module/plugins/hooks/Captcha9kw.py
index 6485db22b..947aff121 100755
--- a/module/plugins/hooks/Captcha9kw.py
+++ b/module/plugins/hooks/Captcha9kw.py
@@ -41,6 +41,7 @@ class Captcha9kw(Hook):
self.API_URL = "https" + self.API_URL if self.getConfig("https") else "http" + self.API_URL
self.info = {}
+
def getCredits(self):
response = getURL(self.API_URL, get={"apikey": self.getConfig("passkey"), "pyload": "1", "source": "pyload",
"action": "usercaptchaguthaben"})
@@ -53,6 +54,7 @@ class Captcha9kw(Hook):
self.logError(response)
return 0
+
def processCaptcha(self, task):
result = None
@@ -100,6 +102,7 @@ class Captcha9kw(Hook):
self.logError(_("Bad upload"), response)
return False
+
def newCaptchaTask(self, task):
if not task.isTextual() and not task.isPositional():
return False
@@ -118,6 +121,7 @@ class Captcha9kw(Hook):
else:
self.logError(_("Your Captcha 9kw.eu Account has not enough credits"))
+
def captchaCorrect(self, task):
if "ticket" in task.data:
@@ -137,6 +141,7 @@ class Captcha9kw(Hook):
else:
self.logError(_("No CaptchaID for correct request (task %s) found.") % task)
+
def captchaInvalid(self, task):
if "ticket" in task.data:
diff --git a/module/plugins/hooks/CaptchaBrotherhood.py b/module/plugins/hooks/CaptchaBrotherhood.py
index 3157fead8..da8fcbafe 100644
--- a/module/plugins/hooks/CaptchaBrotherhood.py
+++ b/module/plugins/hooks/CaptchaBrotherhood.py
@@ -23,12 +23,15 @@ class CaptchaBrotherhoodException(Exception):
def __init__(self, err):
self.err = err
+
def getCode(self):
return self.err
+
def __str__(self):
return "<CaptchaBrotherhoodException %s>" % self.err
+
def __repr__(self):
return "<CaptchaBrotherhoodException %s>" % self.err
@@ -55,6 +58,7 @@ class CaptchaBrotherhood(Hook):
def setup(self):
self.info = {}
+
def getCredits(self):
response = getURL(self.API_URL + "askCredits.aspx",
get={"username": self.getConfig("username"), "password": self.getConfig("passkey")})
@@ -66,6 +70,7 @@ class CaptchaBrotherhood(Hook):
self.info['credits'] = credits
return credits
+
def submit(self, captcha, captchaType="file", match=None):
try:
img = Image.open(captcha)
@@ -116,6 +121,7 @@ class CaptchaBrotherhood(Hook):
raise CaptchaBrotherhoodException("No solution received in time")
+
def get_api(self, api, ticket):
response = getURL("%s%s.aspx" % (self.API_URL, api),
get={"username": self.getConfig("username"),
@@ -126,6 +132,7 @@ class CaptchaBrotherhood(Hook):
return response
+
def newCaptchaTask(self, task):
if "service" in task.data:
return False
@@ -147,10 +154,12 @@ class CaptchaBrotherhood(Hook):
else:
self.logInfo(_("Your CaptchaBrotherhood Account has not enough credits"))
+
def captchaInvalid(self, task):
if task.data['service'] == self.__name__ and "ticket" in task.data:
response = self.get_api("complainCaptcha", task.data['ticket'])
+
def processCaptcha(self, task):
c = task.captchaFile
try:
diff --git a/module/plugins/hooks/Checksum.py b/module/plugins/hooks/Checksum.py
index 32597beeb..4a7cfd661 100644
--- a/module/plugins/hooks/Checksum.py
+++ b/module/plugins/hooks/Checksum.py
@@ -67,12 +67,14 @@ class Checksum(Hook):
if not self.getConfig("check_checksum"):
self.logInfo(_("Checksum validation is disabled in plugin configuration"))
+
def setup(self):
self.algorithms = sorted(
getattr(hashlib, "algorithms", ("md5", "sha1", "sha224", "sha256", "sha384", "sha512")), reverse=True)
self.algorithms.extend(["crc32", "adler32"])
self.formats = self.algorithms + ["sfv", "crc", "hash"]
+
def downloadFinished(self, pyfile):
"""
Compute checksum for the downloaded file and compare it with the hash provided by the hoster.
@@ -130,6 +132,7 @@ class Checksum(Hook):
else:
self.logWarning(_("Unable to validate checksum for file"), pyfile.name)
+
def checkFailed(self, pyfile, local_file, msg):
check_action = self.getConfig("check_action")
if check_action == "retry":
@@ -145,6 +148,7 @@ class Checksum(Hook):
return
pyfile.plugin.fail(reason=msg)
+
def packageFinished(self, pypack):
download_folder = save_join(self.config['general']['download_folder'], pypack.folder, "")
diff --git a/module/plugins/hooks/DeathByCaptcha.py b/module/plugins/hooks/DeathByCaptcha.py
index 2548506cb..99d7f7401 100644
--- a/module/plugins/hooks/DeathByCaptcha.py
+++ b/module/plugins/hooks/DeathByCaptcha.py
@@ -25,21 +25,26 @@ class DeathByCaptchaException(Exception):
'invalid-request': 'Invalid request',
'timed-out': 'No CAPTCHA solution received in time'}
+
def __init__(self, err):
self.err = err
+
def getCode(self):
return self.err
+
def getDesc(self):
if self.err in self.DBC_ERRORS.keys():
return self.DBC_ERRORS[self.err]
else:
return self.err
+
def __str__(self):
return "<DeathByCaptchaException %s>" % self.err
+
def __repr__(self):
return "<DeathByCaptchaException %s>" % self.err
@@ -66,6 +71,7 @@ class DeathByCaptcha(Hook):
def setup(self):
self.info = {}
+
def call_api(self, api="captcha", post=False, multipart=False):
req = getRequest()
req.c.setopt(HTTPHEADER, ["Accept: application/json", "User-Agent: pyLoad %s" % self.core.version])
@@ -106,6 +112,7 @@ class DeathByCaptcha(Hook):
return response
+
def getCredits(self):
response = self.call_api("user", True)
@@ -116,12 +123,14 @@ class DeathByCaptcha(Hook):
else:
raise DeathByCaptchaException(response)
+
def getStatus(self):
response = self.call_api("status", False)
if 'is_service_overloaded' in response and response['is_service_overloaded']:
raise DeathByCaptchaException('service-overload')
+
def submit(self, captcha, captchaType="file", match=None):
#workaround multipart-post bug in HTTPRequest.py
if re.match("^\w*$", self.getConfig("passkey")):
@@ -152,6 +161,7 @@ class DeathByCaptcha(Hook):
return ticket, result
+
def newCaptchaTask(self, task):
if "service" in task.data:
return False
@@ -183,6 +193,7 @@ class DeathByCaptcha(Hook):
task.setWaiting(180)
start_new_thread(self.processCaptcha, (task,))
+
def captchaInvalid(self, task):
if task.data['service'] == self.__name__ and "ticket" in task.data:
try:
@@ -192,6 +203,7 @@ class DeathByCaptcha(Hook):
except Exception, e:
self.logError(e)
+
def processCaptcha(self, task):
c = task.captchaFile
try:
diff --git a/module/plugins/hooks/DownloadScheduler.py b/module/plugins/hooks/DownloadScheduler.py
index c7a0155dd..70930ab67 100644
--- a/module/plugins/hooks/DownloadScheduler.py
+++ b/module/plugins/hooks/DownloadScheduler.py
@@ -26,9 +26,11 @@ class DownloadScheduler(Hook):
def setup(self):
self.cb = None # callback to scheduler job; will be by removed hookmanager when hook unloaded
+
def coreReady(self):
self.updateSchedule()
+
def updateSchedule(self, schedule=None):
if schedule is None:
schedule = self.getConfig("timetable")
@@ -56,6 +58,7 @@ class DownloadScheduler(Hook):
self.core.scheduler.removeJob(self.cb)
self.cb = self.core.scheduler.addJob(next_time, self.updateSchedule, threaded=False)
+
def setDownloadSpeed(self, speed):
if speed == 0:
abort = self.getConfig("abort")
diff --git a/module/plugins/hooks/ExpertDecoders.py b/module/plugins/hooks/ExpertDecoders.py
index 712b19677..e786cc35a 100644
--- a/module/plugins/hooks/ExpertDecoders.py
+++ b/module/plugins/hooks/ExpertDecoders.py
@@ -33,6 +33,7 @@ class ExpertDecoders(Hook):
def setup(self):
self.info = {}
+
def getCredits(self):
response = getURL(self.API_URL, post={"key": self.getConfig("passkey"), "action": "balance"})
@@ -44,6 +45,7 @@ class ExpertDecoders(Hook):
self.logError(response)
return 0
+
def processCaptcha(self, task):
task.data['ticket'] = ticket = uuid4()
result = None
@@ -65,6 +67,7 @@ class ExpertDecoders(Hook):
self.logDebug("Result %s : %s" % (ticket, result))
task.setResult(result)
+
def newCaptchaTask(self, task):
if not task.isTextual():
return False
@@ -83,6 +86,7 @@ class ExpertDecoders(Hook):
else:
self.logInfo(_("Your ExpertDecoders Account has not enough credits"))
+
def captchaInvalid(self, task):
if "ticket" in task.data:
diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py
index f6958941e..649689f6e 100644
--- a/module/plugins/hooks/ExtractArchive.py
+++ b/module/plugins/hooks/ExtractArchive.py
@@ -14,6 +14,7 @@ if sys.version_info < (2, 7) and os.name != "nt":
import errno
from subprocess import Popen
+
def _eintr_retry_call(func, *args):
while True:
try:
@@ -23,6 +24,7 @@ if sys.version_info < (2, 7) and os.name != "nt":
continue
raise
+
# unsued timeout option for older python version
def wait(self, timeout=0):
"""Wait for child process to terminate. Returns returncode
diff --git a/module/plugins/hooks/HotFolder.py b/module/plugins/hooks/HotFolder.py
index 34a9ff49b..688dcbf48 100644
--- a/module/plugins/hooks/HotFolder.py
+++ b/module/plugins/hooks/HotFolder.py
@@ -28,6 +28,7 @@ class HotFolder(Hook):
def setup(self):
self.interval = 10
+
def periodical(self):
if not exists(join(self.getConfig("folder"), "finished")):
makedirs(join(self.getConfig("folder"), "finished"))
diff --git a/module/plugins/hooks/IRCInterface.py b/module/plugins/hooks/IRCInterface.py
index d648db7cf..59977b8af 100644
--- a/module/plugins/hooks/IRCInterface.py
+++ b/module/plugins/hooks/IRCInterface.py
@@ -44,6 +44,7 @@ class IRCInterface(Thread, Hook):
# self.sm = core.server_methods
self.api = core.api # todo, only use api
+
def coreReady(self):
self.abort = False
self.more = []
@@ -51,6 +52,7 @@ class IRCInterface(Thread, Hook):
self.start()
+
def packageFinished(self, pypack):
try:
if self.getConfig("info_pack"):
@@ -58,6 +60,7 @@ class IRCInterface(Thread, Hook):
except:
pass
+
def downloadFinished(self, pyfile):
try:
if self.getConfig("info_file"):
@@ -66,6 +69,7 @@ class IRCInterface(Thread, Hook):
except:
pass
+
def newCaptchaTask(self, task):
if self.getConfig("captcha") and task.isTextual():
task.handler.append(self)
@@ -78,6 +82,7 @@ class IRCInterface(Thread, Hook):
self.response(_("New Captcha Request: %s") % url)
self.response(_("Answer with 'c %s text on the captcha'") % task.id)
+
def run(self):
# connect to IRC etc.
self.sock = socket.socket()
@@ -99,6 +104,7 @@ class IRCInterface(Thread, Hook):
print_exc()
self.sock.close()
+
def main_loop(self):
readbuffer = ""
while True:
@@ -137,6 +143,7 @@ class IRCInterface(Thread, Hook):
self.handle_events(msg)
+
def handle_events(self, msg):
if not msg['origin'].split("!", 1)[0] in self.getConfig("owner").split():
return
@@ -179,6 +186,7 @@ class IRCInterface(Thread, Hook):
except Exception, e:
self.logError(repr(e))
+
def response(self, msg, origin=""):
if origin == "":
for t in self.getConfig("owner").split():
@@ -186,11 +194,13 @@ class IRCInterface(Thread, Hook):
else:
self.sock.send("PRIVMSG %s :%s\r\n" % (origin.split("!", 1)[0], msg))
+
#### Events
def event_pass(self, args):
return []
+
def event_status(self, args):
downloads = self.api.statusDownloads()
if not downloads:
@@ -216,6 +226,7 @@ class IRCInterface(Thread, Hook):
))
return lines
+
def event_queue(self, args):
ps = self.api.getQueueData()
@@ -228,6 +239,7 @@ class IRCInterface(Thread, Hook):
return lines
+
def event_collector(self, args):
ps = self.api.getCollectorData()
if not ps:
@@ -239,6 +251,7 @@ class IRCInterface(Thread, Hook):
return lines
+
def event_info(self, args):
if not args:
return ["ERROR: Use info like this: info <id>"]
@@ -252,6 +265,7 @@ class IRCInterface(Thread, Hook):
return ['LINK #%s: %s (%s) [%s][%s]' % (info.fid, info.name, info.format_size, info.statusmsg, info.plugin)]
+
def event_packinfo(self, args):
if not args:
return ["ERROR: Use packinfo like this: packinfo <id>"]
@@ -283,6 +297,7 @@ class IRCInterface(Thread, Hook):
return lines
+
def event_more(self, args):
if not self.more:
return ["No more information to display."]
@@ -293,14 +308,17 @@ class IRCInterface(Thread, Hook):
return lines
+
def event_start(self, args):
self.api.unpauseServer()
return ["INFO: Starting downloads."]
+
def event_stop(self, args):
self.api.pauseServer()
return ["INFO: No new downloads will be started."]
+
def event_add(self, args):
if len(args) < 2:
return ['ERROR: Add links like this: "add <packagename|id> links". ',
@@ -326,6 +344,7 @@ class IRCInterface(Thread, Hook):
id = self.api.addPackage(pack, links, 1)
return ["INFO: Created new Package %s [#%d] with %d links." % (pack, id, len(links))]
+
def event_del(self, args):
if len(args) < 2:
return ["ERROR: Use del command like this: del -p|-l <id> [...] (-p indicates that the ids are from packages, -l indicates that the ids are from links)"]
@@ -341,6 +360,7 @@ class IRCInterface(Thread, Hook):
else:
return ["ERROR: Use del command like this: del <-p|-l> <id> [...] (-p indicates that the ids are from packages, -l indicates that the ids are from links)"]
+
def event_push(self, args):
if not args:
return ["ERROR: Push package to queue like this: push <package id>"]
@@ -354,6 +374,7 @@ class IRCInterface(Thread, Hook):
self.api.pushToQueue(id)
return ["INFO: Pushed package #%d to queue." % id]
+
def event_pull(self, args):
if not args:
return ["ERROR: Pull package from queue like this: pull <package id>."]
@@ -365,6 +386,7 @@ class IRCInterface(Thread, Hook):
self.api.pullFromQueue(id)
return ["INFO: Pulled package #%d from queue to collector." % id]
+
def event_c(self, args):
""" captcha answer """
if not args:
@@ -377,6 +399,7 @@ class IRCInterface(Thread, Hook):
task.setResult(" ".join(args[1:]))
return ["INFO: Result %s saved." % " ".join(args[1:])]
+
def event_help(self, args):
lines = ["The following commands are available:",
"add <package|packid> <links> [...] Adds link to package. (creates new package if it does not exist)",
@@ -400,5 +423,6 @@ class IRCError(Exception):
def __init__(self, value):
self.value = value
+
def __str__(self):
return repr(self.value)
diff --git a/module/plugins/hooks/ImageTyperz.py b/module/plugins/hooks/ImageTyperz.py
index b7ee6b105..3eb0acd64 100644
--- a/module/plugins/hooks/ImageTyperz.py
+++ b/module/plugins/hooks/ImageTyperz.py
@@ -17,12 +17,15 @@ class ImageTyperzException(Exception):
def __init__(self, err):
self.err = err
+
def getCode(self):
return self.err
+
def __str__(self):
return "<ImageTyperzException %s>" % self.err
+
def __repr__(self):
return "<ImageTyperzException %s>" % self.err
@@ -51,6 +54,7 @@ class ImageTyperz(Hook):
def setup(self):
self.info = {}
+
def getCredits(self):
response = getURL(self.GETCREDITS_URL, post={"action": "REQUESTBALANCE", "username": self.getConfig("username"),
"password": self.getConfig("passkey")})
@@ -66,6 +70,7 @@ class ImageTyperz(Hook):
self.logInfo(_("Account balance: $%s left") % response)
return balance
+
def submit(self, captcha, captchaType="file", match=None):
req = getRequest()
#raise timeout threshold
@@ -100,6 +105,7 @@ class ImageTyperz(Hook):
return ticket, result
+
def newCaptchaTask(self, task):
if "service" in task.data:
return False
@@ -122,6 +128,7 @@ class ImageTyperz(Hook):
else:
self.logInfo(_("Your %s account has not enough credits") % self.__name__)
+
def captchaInvalid(self, task):
if task.data['service'] == self.__name__ and "ticket" in task.data:
response = getURL(self.RESPOND_URL, post={"action": "SETBADIMAGE", "username": self.getConfig("username"),
@@ -133,6 +140,7 @@ class ImageTyperz(Hook):
else:
self.logError(_("Bad captcha solution received, refund request failed"), response)
+
def processCaptcha(self, task):
c = task.captchaFile
try:
diff --git a/module/plugins/hooks/LinkdecrypterCom.py b/module/plugins/hooks/LinkdecrypterCom.py
index de08e406a..463a5af96 100644
--- a/module/plugins/hooks/LinkdecrypterCom.py
+++ b/module/plugins/hooks/LinkdecrypterCom.py
@@ -25,6 +25,7 @@ class LinkdecrypterCom(Hook):
except Exception, e:
self.logError(e)
+
def loadPatterns(self):
page = getURL("http://linkdecrypter.com/")
m = re.search(r'<b>Supported\(\d+\)</b>: <i>([^+<]*)', page)
diff --git a/module/plugins/hooks/MergeFiles.py b/module/plugins/hooks/MergeFiles.py
index 5a23ff862..0eab0037c 100644
--- a/module/plugins/hooks/MergeFiles.py
+++ b/module/plugins/hooks/MergeFiles.py
@@ -27,6 +27,7 @@ class MergeFiles(Hook):
# nothing to do
pass
+
@threaded
def packageFinished(self, pack):
files = {}
diff --git a/module/plugins/hooks/MultiHome.py b/module/plugins/hooks/MultiHome.py
index 5cda53bd7..378c493e9 100644
--- a/module/plugins/hooks/MultiHome.py
+++ b/module/plugins/hooks/MultiHome.py
@@ -26,19 +26,23 @@ class MultiHome(Hook):
self.parseInterfaces([self.config['download']['interface']])
self.setConfig("interfaces", self.toConfig())
+
def toConfig(self):
return ";".join([i.adress for i in self.interfaces])
+
def parseInterfaces(self, interfaces):
for interface in interfaces:
if not interface or str(interface).lower() == "none":
continue
self.interfaces.append(Interface(interface))
+
def coreReady(self):
requestFactory = self.core.requestFactory
oldGetRequest = requestFactory.getRequest
+
def getRequest(pluginName, account=None):
iface = self.bestInterface(pluginName, account)
if iface:
@@ -49,6 +53,7 @@ class MultiHome(Hook):
requestFactory.getRequest = getRequest
+
def bestInterface(self, pluginName, account):
best = None
for interface in self.interfaces:
@@ -63,13 +68,16 @@ class Interface(object):
self.adress = adress
self.history = {}
+
def lastPluginAccess(self, pluginName, account):
if (pluginName, account) in self.history:
return self.history[(pluginName, account)]
return 0
+
def useFor(self, pluginName, account):
self.history[(pluginName, account)] = time()
+
def __repr__(self):
return "<Interface - %s>" % self.adress
diff --git a/module/plugins/hooks/PremiumTo.py b/module/plugins/hooks/PremiumTo.py
index e783bac8f..15a357ce3 100644
--- a/module/plugins/hooks/PremiumTo.py
+++ b/module/plugins/hooks/PremiumTo.py
@@ -25,6 +25,7 @@ class PremiumTo(MultiHoster):
get={'username': self.account.username, 'password': self.account.password})
return [x.strip() for x in page.replace("\"", "").split(";")]
+
def coreReady(self):
self.account = self.core.accountManager.getAccountPlugin("PremiumTo")
diff --git a/module/plugins/hooks/PremiumizeMe.py b/module/plugins/hooks/PremiumizeMe.py
index c1a7866c4..1ef82612e 100644
--- a/module/plugins/hooks/PremiumizeMe.py
+++ b/module/plugins/hooks/PremiumizeMe.py
@@ -42,6 +42,7 @@ class PremiumizeMe(MultiHoster):
# Extract hosters from json file
return data['result']['hosterlist']
+
def coreReady(self):
# Get account plugin and check if there is a valid account available
self.account = self.core.accountManager.getAccountPlugin("PremiumizeMe")
diff --git a/module/plugins/hooks/RPNetBiz.py b/module/plugins/hooks/RPNetBiz.py
index f0231d0e7..feba36204 100644
--- a/module/plugins/hooks/RPNetBiz.py
+++ b/module/plugins/hooks/RPNetBiz.py
@@ -40,6 +40,7 @@ class RPNetBiz(MultiHoster):
# Extract hosters from json file
return hoster_list['hosters']
+
def coreReady(self):
# Get account plugin and check if there is a valid account available
self.account = self.core.accountManager.getAccountPlugin("RPNetBiz")
diff --git a/module/plugins/hooks/RehostTo.py b/module/plugins/hooks/RehostTo.py
index f3e1465ee..ea4521a28 100644
--- a/module/plugins/hooks/RehostTo.py
+++ b/module/plugins/hooks/RehostTo.py
@@ -24,6 +24,7 @@ class RehostTo(MultiHoster):
page = getURL("http://rehost.to/api.php?cmd=get_supported_och_dl&long_ses=%s" % self.long_ses)
return [x.strip() for x in page.replace("\"", "").split(",")]
+
def coreReady(self):
self.account = self.core.accountManager.getAccountPlugin("RehostTo")
diff --git a/module/plugins/hooks/RestartFailed.py b/module/plugins/hooks/RestartFailed.py
index 6724ceaa8..ebce60b3f 100644
--- a/module/plugins/hooks/RestartFailed.py
+++ b/module/plugins/hooks/RestartFailed.py
@@ -31,13 +31,16 @@ class RestartFailed(Hook):
else:
self.logDebug("Invalid interval value, kept current")
+
def periodical(self):
self.logInfo(_("Restart failed downloads"))
self.api.restartFailed()
+
def setup(self):
self.api = self.core.api
self.interval = self.MIN_INTERVAL
+
def coreReady(self):
self.pluginConfigChanged(self.__name__, "interval", self.getConfig("interval"))
diff --git a/module/plugins/hooks/UnSkipOnFail.py b/module/plugins/hooks/UnSkipOnFail.py
index f29383b32..e3c0f6af9 100644
--- a/module/plugins/hooks/UnSkipOnFail.py
+++ b/module/plugins/hooks/UnSkipOnFail.py
@@ -32,6 +32,7 @@ class UnSkipOnFail(Hook):
self.logInfo(_('restart "%s" (pid:%s)') % (pyfile_name, lpid))
self.setLinkStatus(link, "queued")
+
def findDuplicates(self, pyfile):
""" Search all packages for duplicate links to "pyfile".
Duplicates are links that would overwrite "pyfile".
@@ -61,6 +62,7 @@ class UnSkipOnFail(Hook):
dups.append(link)
return dups
+
def setLinkStatus(self, link, new_status):
""" Change status of "link" to "new_status".
"link" has to be a valid FileData object,
diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py
index cc086af5c..be1d6e5fc 100644
--- a/module/plugins/hooks/UpdateManager.py
+++ b/module/plugins/hooks/UpdateManager.py
@@ -48,14 +48,17 @@ class UpdateManager(Hook):
if value is True and self.core.debug:
self.periodical2()
+
def coreReady(self):
self.pluginConfigChanged(self.__name__, "interval", self.getConfig("interval"))
x = lambda: self.pluginConfigChanged(self.__name__, "reloadplugins", self.getConfig("reloadplugins"))
self.core.scheduler.addJob(10, x, threaded=False)
+
def unload(self):
self.pluginConfigChanged(self.__name__, "reloadplugins", False)
+
def setup(self):
self.cb2 = None
self.interval = self.MIN_INTERVAL
@@ -63,11 +66,13 @@ class UpdateManager(Hook):
self.info = {'pyload': False, 'version': None, 'plugins': False}
self.mtimes = {} #: store modification time for each plugin
+
def periodical2(self):
if not self.updating:
self.autoreloadPlugins()
self.cb2 = self.core.scheduler.addJob(4, self.periodical2, threaded=False)
+
@Expose
def autoreloadPlugins(self):
""" reload and reindex all modified plugins """
@@ -97,16 +102,19 @@ class UpdateManager(Hook):
return True if self.core.pluginManager.reloadPlugins(reloads) else False
+
def periodical(self):
if not self.info['pyload'] and not (self.getConfig("nodebugupdate") and self.core.debug):
self.updateThread()
+
def server_request(self):
try:
return getURL(self.SERVER_URL, get={'v': self.core.api.getServerVersion()}).splitlines()
except:
self.logWarning(_("Unable to contact server to get updates"))
+
@threaded
def updateThread(self):
self.updating = True
@@ -116,11 +124,13 @@ class UpdateManager(Hook):
else:
self.updating = False
+
@Expose
def updatePlugins(self):
""" simple wrapper for calling plugin update quickly """
return self.update(onlyplugin=True)
+
@Expose
def update(self, onlyplugin=False):
""" check for updates """
@@ -142,6 +152,7 @@ class UpdateManager(Hook):
self.info['version'] = newversion
return exitcode #: 0 = No plugins updated; 1 = Plugins updated; 2 = Plugins updated, but restart required; 3 = No plugins updated, new pyLoad version available
+
def _updatePlugins(self, updates):
""" check for plugin updates """
@@ -240,6 +251,7 @@ class UpdateManager(Hook):
return exitcode #: 0 = No plugins updated; 1 = Plugins updated; 2 = Plugins updated, but restart required
+
@Expose
def removePlugins(self, type_plugins):
""" delete plugins from disk """
diff --git a/module/plugins/hooks/WindowsPhoneToastNotify.py b/module/plugins/hooks/WindowsPhoneToastNotify.py
index eed61adbd..cf7920b74 100644
--- a/module/plugins/hooks/WindowsPhoneToastNotify.py
+++ b/module/plugins/hooks/WindowsPhoneToastNotify.py
@@ -25,12 +25,14 @@ class WindowsPhoneToastNotify(Hook):
def setup(self):
self.info = {}
+
def getXmlData(self):
myxml = ("<?xml version='1.0' encoding='utf-8'?> <wp:Notification xmlns:wp='WPNotification'> "
"<wp:Toast> <wp:Text1>Pyload Mobile</wp:Text1> <wp:Text2>Captcha waiting!</wp:Text2> "
"</wp:Toast> </wp:Notification>")
return myxml
+
def doRequest(self):
URL = self.getConfig("pushUrl")
request = self.getXmlData()
@@ -46,6 +48,7 @@ class WindowsPhoneToastNotify(Hook):
webservice.close()
self.setStorage("LAST_NOTIFY", time.time())
+
def newCaptchaTask(self, task):
if not self.getConfig("pushId") or not self.getConfig("pushUrl"):
return False
diff --git a/module/plugins/hooks/XMPPInterface.py b/module/plugins/hooks/XMPPInterface.py
index b32eeb40b..c4d6e1b66 100644
--- a/module/plugins/hooks/XMPPInterface.py
+++ b/module/plugins/hooks/XMPPInterface.py
@@ -30,6 +30,7 @@ class XMPPInterface(IRCInterface, JabberClient):
implements(IMessageHandlersProvider)
+
def __init__(self, core, manager):
IRCInterface.__init__(self, core, manager)
@@ -58,11 +59,13 @@ class XMPPInterface(IRCInterface, JabberClient):
self,
]
+
def coreReady(self):
self.new_package = {}
self.start()
+
def packageFinished(self, pypack):
try:
if self.getConfig("info_pack"):
@@ -70,6 +73,7 @@ class XMPPInterface(IRCInterface, JabberClient):
except:
pass
+
def downloadFinished(self, pyfile):
try:
if self.getConfig("info_file"):
@@ -78,6 +82,7 @@ class XMPPInterface(IRCInterface, JabberClient):
except:
pass
+
def run(self):
# connect to IRC etc.
self.connect()
@@ -86,21 +91,26 @@ class XMPPInterface(IRCInterface, JabberClient):
except Exception, ex:
self.logError(ex)
+
def stream_state_changed(self, state, arg):
"""This one is called when the state of stream connecting the component
to a server changes. This will usually be used to let the user
know what is going on."""
self.logDebug("*** State changed: %s %r ***" % (state, arg))
+
def disconnected(self):
self.logDebug("Client was disconnected")
+
def stream_closed(self, stream):
self.logDebug("Stream was closed", stream)
+
def stream_error(self, err):
self.logDebug("Stream Error", err)
+
def get_message_handlers(self):
"""Return list of (message_type, message_handler) tuples.
@@ -108,6 +118,7 @@ class XMPPInterface(IRCInterface, JabberClient):
in a client session."""
return [("normal", self.message)]
+
def message(self, stanza):
"""Message handler for the component."""
subject = stanza.get_subject()
@@ -165,9 +176,11 @@ class XMPPInterface(IRCInterface, JabberClient):
else:
return True
+
def response(self, msg, origin=""):
return self.announce(msg)
+
def announce(self, message):
""" send message to all owners"""
for user in self.getConfig("owners").split(";"):
@@ -187,9 +200,11 @@ class XMPPInterface(IRCInterface, JabberClient):
stream.send(m)
+
def beforeReconnecting(self, ip):
self.disconnect()
+
def afterReconnecting(self, ip):
self.connect()
@@ -202,24 +217,29 @@ class VersionHandler(object):
implements(IIqHandlersProvider, IFeaturesProvider)
+
def __init__(self, client):
"""Just remember who created this."""
self.client = client
+
def get_features(self):
"""Return namespace which should the client include in its reply to a
disco#info query."""
return ["jabber:iq:version"]
+
def get_iq_get_handlers(self):
"""Return list of tuples (element_name, namespace, handler) describing
handlers of <iq type='get'/> stanzas"""
return [("query", "jabber:iq:version", self.get_version)]
+
def get_iq_set_handlers(self):
"""Return empty list, as this class provides no <iq type='set'/> stanza handler."""
return []
+
def get_version(self, iq):
"""Handler for jabber:iq:version queries.