summaryrefslogtreecommitdiffstats
path: root/module/plugins/hooks/ClickAndLoad.py
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-10-02 13:27:19 +0200
committerGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-10-02 13:27:19 +0200
commitf74af3cf7d4904aad59ebd636baba37f65e92dae (patch)
tree4e5a3dbc5db6d933e1edf5a2e3567596de1a6396 /module/plugins/hooks/ClickAndLoad.py
parentFix https://github.com/pyload/pyload/issues/1932 (diff)
downloadpyload-f74af3cf7d4904aad59ebd636baba37f65e92dae.tar.xz
[ClickAndLoad] Queue destination support
Diffstat (limited to 'module/plugins/hooks/ClickAndLoad.py')
-rw-r--r--module/plugins/hooks/ClickAndLoad.py30
1 files changed, 22 insertions, 8 deletions
diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py
index 591be8b59..bc691bf7c 100644
--- a/module/plugins/hooks/ClickAndLoad.py
+++ b/module/plugins/hooks/ClickAndLoad.py
@@ -29,12 +29,13 @@ def forward(source, destination):
class ClickAndLoad(Addon):
__name__ = "ClickAndLoad"
__type__ = "hook"
- __version__ = "0.45"
+ __version__ = "0.46"
__status__ = "testing"
- __config__ = [("activated", "bool", "Activated" , True),
- ("port" , "int" , "Port" , 9666),
- ("extern" , "bool", "Listen on the public network interface", True)]
+ __config__ = [("activated", "bool", "Activated" , True ),
+ ("port" , "int" , "Port" , 9666 ),
+ ("extern" , "bool", "Listen on the public network interface", True ),
+ ("queue" , "bool", "Add packages to queue" , False)]
__description__ = """Click'n'Load hook plugin"""
__license__ = "GPLv3"
@@ -54,6 +55,19 @@ class ClickAndLoad(Addon):
@threaded
+ def forward(source, destination, queue=False):
+ if queue:
+ old_ids = set(id for pack.id in self.pyload.api.getCollector())
+
+ forward(source, destination)
+
+ if queue:
+ new_ids = set(id for pack.id in self.pyload.api.getCollector())
+ for id in new_ids - old_ids:
+ self.pyload.api.pushToQueue(id)
+
+
+ @threaded
def proxy(self, ip, webport, cnlport):
time.sleep(10) #@TODO: Remove in 0.4.10 (implement addon delay on startup)
@@ -85,18 +99,18 @@ class ClickAndLoad(Addon):
except NameError:
self.log_error(_("Missing SSL lib"), _("Please disable HTTPS in pyLoad settings"))
- client_socket.close() #: Reset the connection.
+ client_socket.close()
continue
except Exception, e:
self.log_error(_("SSL error: %s") % e.message)
- client_socket.close() #: Reset the connection.
+ client_socket.close()
continue
server_socket.connect(("127.0.0.1", webport))
- self.manager.startThread(forward, client_socket, server_socket)
- self.manager.startThread(forward, server_socket, client_socket)
+ self.forward(client_socket, server_socket, self.get_config('queue'))
+ self.forward(server_socket, client_socket)
except socket.timeout:
self.log_debug("Connection timed out, retrying...")