summaryrefslogtreecommitdiffstats
path: root/module/plugins/hooks
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-10-04 20:09:55 +0200
committerGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-10-04 20:09:55 +0200
commitcf6531b2c87fea99fd03884636bac4c80d1b475d (patch)
treec39125695c85662d2279af57082b36e1718d574a /module/plugins/hooks
parentFixpack (2) (diff)
downloadpyload-cf6531b2c87fea99fd03884636bac4c80d1b475d.tar.xz
Fixpack (3)
Diffstat (limited to 'module/plugins/hooks')
-rw-r--r--module/plugins/hooks/Checksum.py4
-rw-r--r--module/plugins/hooks/ClickNLoad.py (renamed from module/plugins/hooks/ClickAndLoad.py)4
-rw-r--r--module/plugins/hooks/ExternalScripts.py6
-rw-r--r--module/plugins/hooks/HotFolder.py5
-rw-r--r--module/plugins/hooks/IRCInterface.py4
-rw-r--r--module/plugins/hooks/LinkdecrypterComHook.py2
-rw-r--r--module/plugins/hooks/MultiHome.py71
-rw-r--r--module/plugins/hooks/RestartFailed.py2
-rw-r--r--module/plugins/hooks/SkipRev.py2
-rw-r--r--module/plugins/hooks/XFileSharingPro.py4
10 files changed, 55 insertions, 49 deletions
diff --git a/module/plugins/hooks/Checksum.py b/module/plugins/hooks/Checksum.py
index 2a650768e..fe866563d 100644
--- a/module/plugins/hooks/Checksum.py
+++ b/module/plugins/hooks/Checksum.py
@@ -160,7 +160,8 @@ class Checksum(Addon):
return
elif check_action == "nothing":
return
- pyfile.plugin.fail(msg=msg)
+
+ pyfile.plugin.fail(msg)
def package_finished(self, pypack):
@@ -187,6 +188,7 @@ class Checksum(Addon):
local_file = fs_encode(fs_join(download_folder, data['NAME']))
algorithm = self.methods.get(file_type, file_type)
checksum = compute_checksum(local_file, algorithm)
+
if checksum is data['HASH']:
self.log_info(_('File integrity of "%s" verified by %s checksum (%s)') %
(data['NAME'], algorithm, checksum))
diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickNLoad.py
index aef014d1a..13975ecb5 100644
--- a/module/plugins/hooks/ClickAndLoad.py
+++ b/module/plugins/hooks/ClickNLoad.py
@@ -26,8 +26,8 @@ def forward(source, destination):
#@TODO: IPv6 support
-class ClickAndLoad(Addon):
- __name__ = "ClickAndLoad"
+class ClickNLoad(Addon):
+ __name__ = "ClickNLoad"
__type__ = "hook"
__version__ = "0.48"
__status__ = "testing"
diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py
index 32faebbed..09fe59d0a 100644
--- a/module/plugins/hooks/ExternalScripts.py
+++ b/module/plugins/hooks/ExternalScripts.py
@@ -11,7 +11,7 @@ from module.utils import fs_encode, save_join as fs_join
class ExternalScripts(Addon):
__name__ = "ExternalScripts"
__type__ = "hook"
- __version__ = "0.48"
+ __version__ = "0.49"
__status__ = "testing"
__config__ = [("activated", "bool", "Activated" , True ),
@@ -26,7 +26,6 @@ class ExternalScripts(Addon):
def init(self):
- self.info['oldip'] = None
self.scripts = {}
self.event_list = ["archive_extract_failed", "archive_extracted" ,
@@ -115,13 +114,12 @@ class ExternalScripts(Addon):
for script in self.scripts['before_reconnect']:
args = [ip]
self.call(script, args, lock)
- self.info['oldip'] = ip
def after_reconnect(self, ip, oldip):
lock = self.get_config('lock')
for script in self.scripts['after_reconnect']:
- args = [ip, self.info['oldip']] #@TODO: Use built-in oldip in 0.4.10
+ args = [ip, oldip]
self.call(script, args, lock)
diff --git a/module/plugins/hooks/HotFolder.py b/module/plugins/hooks/HotFolder.py
index d556537aa..aeb432626 100644
--- a/module/plugins/hooks/HotFolder.py
+++ b/module/plugins/hooks/HotFolder.py
@@ -3,10 +3,9 @@
from __future__ import with_statement
import os
+import shutil
import time
-from shutil import move
-
from module.plugins.internal.Addon import Addon
from module.utils import fs_encode, save_join as fs_join
@@ -63,7 +62,7 @@ class HotFolder(Addon):
continue
newpath = os.path.join(folder, "finished", "tmp_" + f if self.get_config('delete') else f)
- move(path, newpath)
+ shutil.move(path, newpath)
self.log_info(_("Added %s from HotFolder") % f)
self.pyload.api.addPackage(f, [newpath], 1)
diff --git a/module/plugins/hooks/IRCInterface.py b/module/plugins/hooks/IRCInterface.py
index c84c0439d..6135b3244 100644
--- a/module/plugins/hooks/IRCInterface.py
+++ b/module/plugins/hooks/IRCInterface.py
@@ -2,12 +2,12 @@
import pycurl
import re
+import select
import socket
import ssl
import time
import traceback
-from select import select
from threading import Thread
from module.Api import PackageDoesNotExists, FileDoesNotExists
@@ -114,7 +114,7 @@ class IRCInterface(Thread, Addon):
readbuffer = ""
while True:
time.sleep(1)
- fdset = select([self.sock], [], [], 0)
+ fdset = select.select([self.sock], [], [], 0)
if self.sock not in fdset[0]:
continue
diff --git a/module/plugins/hooks/LinkdecrypterComHook.py b/module/plugins/hooks/LinkdecrypterComHook.py
index 7d39656d3..a318a78fa 100644
--- a/module/plugins/hooks/LinkdecrypterComHook.py
+++ b/module/plugins/hooks/LinkdecrypterComHook.py
@@ -23,7 +23,7 @@ class LinkdecrypterComHook(Addon):
def get_hosters(self):
- list = re.search(r'>Supported\(\d+\)</b>: <i>(.[\w.-, ]+)',
+ list = re.search(r'>Supported\(\d+\)</b>: <i>(.[\w\-., ]+)',
self.load("http://linkdecrypter.com/").replace("(g)", "")).group(1).split(', ')
try:
list.remove("download.serienjunkies.org")
diff --git a/module/plugins/hooks/MultiHome.py b/module/plugins/hooks/MultiHome.py
index 929ab9a25..b1e3c8ada 100644
--- a/module/plugins/hooks/MultiHome.py
+++ b/module/plugins/hooks/MultiHome.py
@@ -5,6 +5,42 @@ import time
from module.plugins.internal.Addon import Addon
+def get_request(pluginName, account=None):
+ iface = self.best_interface(pluginName, account)
+
+ if not iface:
+ return
+
+ iface.useFor(pluginName, account)
+ requestFactory.iface = lambda: iface.adress
+ self.log_debug("Using address", iface.adress)
+
+ return oldGetRequest(pluginName, account)
+
+
+class Interface(object):
+
+ def __init__(self, adress):
+ self.adress = adress
+ self.history = {}
+
+
+ def last_plugin_access(self, pluginName, account):
+ if (pluginName, account) in self.history:
+ return self.history[(pluginName, account)]
+ else:
+ return 0
+
+
+ def use_for(self, pluginName, account):
+ self.history[(pluginName, account)] = time.time()
+
+
+ def __repr__(self):
+ return "<Interface - %s>" % self.adress
+
+
+
class MultiHome(Addon):
__name__ = "MultiHome"
__type__ = "hook"
@@ -42,44 +78,15 @@ class MultiHome(Addon):
def activate(self):
requestFactory = self.pyload.requestFactory
- oldGetRequest = requestFactory.getRequest
-
-
- def get_request(pluginName, account=None):
- iface = self.best_interface(pluginName, account)
- if iface:
- iface.useFor(pluginName, account)
- requestFactory.iface = lambda: iface.adress
- self.log_debug("Using address", iface.adress)
- return oldGetRequest(pluginName, account)
-
+ oldGetRequest = requestFactory.getRequest
requestFactory.getRequest = get_request
def best_interface(self, pluginName, account):
best = None
+
for interface in self.interfaces:
if not best or interface.lastPluginAccess(pluginName, account) < best.lastPluginAccess(pluginName, account):
best = interface
- return best
-
-
-class Interface(object):
-
- def __init__(self, adress):
- self.adress = adress
- self.history = {}
-
- def last_plugin_access(self, pluginName, account):
- if (pluginName, account) in self.history:
- return self.history[(pluginName, account)]
- return 0
-
-
- def use_for(self, pluginName, account):
- self.history[(pluginName, account)] = time.time()
-
-
- def __repr__(self):
- return "<Interface - %s>" % self.adress
+ return best
diff --git a/module/plugins/hooks/RestartFailed.py b/module/plugins/hooks/RestartFailed.py
index 812b68f76..e1498b0ae 100644
--- a/module/plugins/hooks/RestartFailed.py
+++ b/module/plugins/hooks/RestartFailed.py
@@ -20,7 +20,7 @@ class RestartFailed(Addon):
def periodical(self):
- self.log_debug("Restart failed downloads")
+ self.log_info(_("Restarting all failed downloads..."))
self.pyload.api.restartFailed()
diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py
index 5f9cfa452..1e0a495b4 100644
--- a/module/plugins/hooks/SkipRev.py
+++ b/module/plugins/hooks/SkipRev.py
@@ -74,7 +74,7 @@ class SkipRev(Addon):
pyname = re.compile(r'%s\.part\d+\.rev$' % pyfile.name.rsplit('.', 2)[0].replace('.', '\.'))
for link in self.pyload.api.getPackageData(pyfile.package().id).links:
- if link.status == 4 and pyname.match(link.name):
+ if link.status is 4 and pyname.match(link.name):
pylink = self._pyfile(link)
if revtokeep > -1 or pyfile.name.endswith(".rev"):
diff --git a/module/plugins/hooks/XFileSharingPro.py b/module/plugins/hooks/XFileSharingPro.py
index 04438519b..70bafba67 100644
--- a/module/plugins/hooks/XFileSharingPro.py
+++ b/module/plugins/hooks/XFileSharingPro.py
@@ -23,9 +23,9 @@ class XFileSharingPro(Hook):
__authors__ = [("Walter Purcaro", "vuolter@gmail.com")]
- regexp = {'hoster' : (r'https?://(?:www\.)?(?:\w+\.)*?(?P<DOMAIN>(?:[\d.]+|[\w-^_]{3,}(?:\.[a-zA-Z]{2,}){1,2})(?:\:\d+)?)/(?:embed-)?\w{12}(?:\W|$)',
+ regexp = {'hoster' : (r'https?://(?:www\.)?(?:\w+\.)*?(?P<DOMAIN>(?:[\d.]+|[\w\-^_]{3,}(?:\.[a-zA-Z]{2,}){1,2})(?:\:\d+)?)/(?:embed-)?\w{12}(?:\W|$)',
r'https?://(?:[^/]+\.)?(?P<DOMAIN>%s)/(?:embed-)?\w+'),
- 'crypter': (r'https?://(?:www\.)?(?:\w+\.)*?(?P<DOMAIN>(?:[\d.]+|[\w-^_]{3,}(?:\.[a-zA-Z]{2,}){1,2})(?:\:\d+)?)/(?:user|folder)s?/\w+',
+ 'crypter': (r'https?://(?:www\.)?(?:\w+\.)*?(?P<DOMAIN>(?:[\d.]+|[\w\-^_]{3,}(?:\.[a-zA-Z]{2,}){1,2})(?:\:\d+)?)/(?:user|folder)s?/\w+',
r'https?://(?:[^/]+\.)?(?P<DOMAIN>%s)/(?:user|folder)s?/\w+')}
BUILTIN_HOSTERS = [#WORKING HOSTERS: