From 7a7e3e211e36af06d00e0effbcc37ac59e152427 Mon Sep 17 00:00:00 2001 From: synweap15 Date: Tue, 8 Jul 2014 20:00:23 +0200 Subject: nopremium.pl files added --- module/plugins/hooks/NoPremiumPl.py | 39 +++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 module/plugins/hooks/NoPremiumPl.py (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/NoPremiumPl.py b/module/plugins/hooks/NoPremiumPl.py new file mode 100644 index 000000000..154d748f1 --- /dev/null +++ b/module/plugins/hooks/NoPremiumPl.py @@ -0,0 +1,39 @@ +# !/usr/bin/env python +# -*- coding: utf-8 -*- + +""" +@author: Pawel W. +""" + +from module.plugins.internal.MultiHoster import MultiHoster +from module.network.RequestFactory import getURL + +try: + from json import loads +except ImportError: + from simplejson import loads + +class NoPremiumPl(MultiHoster): + __name__ = "NoPremiumPl" + __version__ = "0.01" + __type__ = "hook" + + __config__ = [("activated", "bool", "Activated", "False"), + ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported):", "all"), + ("hosterList", "str", "Hoster list (comma separated)", ""), + ("unloadFailing", "bool", "Try standard download if download fails", "False"), + ("interval", "int", "Reload supported hosts interval in hours (0 to disable)", "24")] + + __description__ = "NoPremium.pl hook" + __author_name__ = ("goddie") + __author_mail__ = ("dev@nopremium.pl") + + def getHoster(self): + + hostings = loads(getURL("https://www.nopremium.pl/clipboard.php?json=3").strip()) + return [domain for row in hostings for domain in row["domains"] if row["sdownload"] == "0"] + + def getHosterCached(self): + return self.getHoster() + + -- cgit v1.2.3 From 2404538888ced4e6964df55823d0514b1c0ba685 Mon Sep 17 00:00:00 2001 From: synweap15 Date: Tue, 8 Jul 2014 20:03:27 +0200 Subject: rapideo.pl files added --- module/plugins/hooks/RapideoPl.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 module/plugins/hooks/RapideoPl.py (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/RapideoPl.py b/module/plugins/hooks/RapideoPl.py new file mode 100644 index 000000000..5d7673826 --- /dev/null +++ b/module/plugins/hooks/RapideoPl.py @@ -0,0 +1,38 @@ +# !/usr/bin/env python +# -*- coding: utf-8 -*- + +""" +@author: Pawel W. +""" +from module.plugins.internal.MultiHoster import MultiHoster +from module.network.RequestFactory import getURL + +try: + from json import loads +except ImportError: + from simplejson import loads + +class RapideoPl(MultiHoster): + __name__ = "RapideoPl" + __version__ = "0.01" + __type__ = "hook" + + __config__ = [("activated", "bool", "Activated", "False"), + ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported):", "all"), + ("hosterList", "str", "Hoster list (comma separated)", ""), + ("unloadFailing", "bool", "Try standard download if download fails", "False"), + ("interval", "int", "Reload supported hosts interval in hours (0 to disable)", "24")] + + __description__ = "Rapideo.pl hook" + __author_name__ = ("goddie") + __author_mail__ = ("dev@rapideo.pl") + + def getHoster(self): + + hostings = loads(getURL("https://www.rapideo.pl/clipboard.php?json=3").strip()) + return [domain for row in hostings for domain in row["domains"] if row["sdownload"] == "0"] + + def getHosterCached(self): + return self.getHoster() + + -- cgit v1.2.3 From ccf15e75c12ad1e8347fdff834f8c62e5e2ab617 Mon Sep 17 00:00:00 2001 From: synweap15 Date: Tue, 8 Jul 2014 21:33:01 +0200 Subject: remove redundant author information --- module/plugins/hooks/NoPremiumPl.py | 4 ---- 1 file changed, 4 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/NoPremiumPl.py b/module/plugins/hooks/NoPremiumPl.py index 154d748f1..527119c5f 100644 --- a/module/plugins/hooks/NoPremiumPl.py +++ b/module/plugins/hooks/NoPremiumPl.py @@ -1,10 +1,6 @@ # !/usr/bin/env python # -*- coding: utf-8 -*- -""" -@author: Pawel W. -""" - from module.plugins.internal.MultiHoster import MultiHoster from module.network.RequestFactory import getURL -- cgit v1.2.3 From ea1cbeda0006bbf427223686892c9e6f87cfbe94 Mon Sep 17 00:00:00 2001 From: synweap15 Date: Tue, 8 Jul 2014 21:36:14 +0200 Subject: remove redundant author information --- module/plugins/hooks/RapideoPl.py | 3 --- 1 file changed, 3 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/RapideoPl.py b/module/plugins/hooks/RapideoPl.py index 5d7673826..e032b426d 100644 --- a/module/plugins/hooks/RapideoPl.py +++ b/module/plugins/hooks/RapideoPl.py @@ -1,9 +1,6 @@ # !/usr/bin/env python # -*- coding: utf-8 -*- -""" -@author: Pawel W. -""" from module.plugins.internal.MultiHoster import MultiHoster from module.network.RequestFactory import getURL -- cgit v1.2.3 From 2ed13d51ab8cd28f2f3db4caabde9b6d2e2cec25 Mon Sep 17 00:00:00 2001 From: synweap15 Date: Wed, 9 Jul 2014 11:55:23 +0200 Subject: remove enviroment line --- module/plugins/hooks/RapideoPl.py | 1 - 1 file changed, 1 deletion(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/RapideoPl.py b/module/plugins/hooks/RapideoPl.py index e032b426d..fa3df9f84 100644 --- a/module/plugins/hooks/RapideoPl.py +++ b/module/plugins/hooks/RapideoPl.py @@ -1,4 +1,3 @@ -# !/usr/bin/env python # -*- coding: utf-8 -*- from module.plugins.internal.MultiHoster import MultiHoster -- cgit v1.2.3 From e325412cd71ae329f3f0b7084e5989e6ffbdbd18 Mon Sep 17 00:00:00 2001 From: synweap15 Date: Wed, 9 Jul 2014 11:57:05 +0200 Subject: remove enviroment line --- module/plugins/hooks/NoPremiumPl.py | 1 - 1 file changed, 1 deletion(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/NoPremiumPl.py b/module/plugins/hooks/NoPremiumPl.py index 527119c5f..ef36331eb 100644 --- a/module/plugins/hooks/NoPremiumPl.py +++ b/module/plugins/hooks/NoPremiumPl.py @@ -1,4 +1,3 @@ -# !/usr/bin/env python # -*- coding: utf-8 -*- from module.plugins.internal.MultiHoster import MultiHoster -- cgit v1.2.3 From 352301e4892d311d1a4cf6127f6bc70bc23eede3 Mon Sep 17 00:00:00 2001 From: synweap15 Date: Wed, 9 Jul 2014 12:02:59 +0200 Subject: remove blank lines and unused imports --- module/plugins/hooks/NoPremiumPl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/NoPremiumPl.py b/module/plugins/hooks/NoPremiumPl.py index ef36331eb..121e92f91 100644 --- a/module/plugins/hooks/NoPremiumPl.py +++ b/module/plugins/hooks/NoPremiumPl.py @@ -24,8 +24,8 @@ class NoPremiumPl(MultiHoster): __author_mail__ = ("dev@nopremium.pl") def getHoster(self): - hostings = loads(getURL("https://www.nopremium.pl/clipboard.php?json=3").strip()) + return [domain for row in hostings for domain in row["domains"] if row["sdownload"] == "0"] def getHosterCached(self): -- cgit v1.2.3 From ce18793af9864acdf9e9c71b7324d923a53adaad Mon Sep 17 00:00:00 2001 From: synweap15 Date: Wed, 9 Jul 2014 12:05:22 +0200 Subject: fix json loads, dumps on ImportError exception --- module/plugins/hooks/NoPremiumPl.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/NoPremiumPl.py b/module/plugins/hooks/NoPremiumPl.py index 121e92f91..47aa117df 100644 --- a/module/plugins/hooks/NoPremiumPl.py +++ b/module/plugins/hooks/NoPremiumPl.py @@ -4,9 +4,10 @@ from module.plugins.internal.MultiHoster import MultiHoster from module.network.RequestFactory import getURL try: - from json import loads + from json import loads, dumps except ImportError: - from simplejson import loads + from module.common.json_layer import json_loads as loads + from module.common.json_layer import json_dumps as dumps class NoPremiumPl(MultiHoster): __name__ = "NoPremiumPl" -- cgit v1.2.3 From dfd5cb44138494b803f66559747cacc1260b5595 Mon Sep 17 00:00:00 2001 From: synweap15 Date: Wed, 9 Jul 2014 12:15:03 +0200 Subject: simplify json loads, replace crypto with hashlib --- module/plugins/hooks/NoPremiumPl.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/NoPremiumPl.py b/module/plugins/hooks/NoPremiumPl.py index 47aa117df..1357c95e8 100644 --- a/module/plugins/hooks/NoPremiumPl.py +++ b/module/plugins/hooks/NoPremiumPl.py @@ -3,11 +3,9 @@ from module.plugins.internal.MultiHoster import MultiHoster from module.network.RequestFactory import getURL -try: - from json import loads, dumps -except ImportError: - from module.common.json_layer import json_loads as loads - from module.common.json_layer import json_dumps as dumps +from module.common.json_layer import json_loads as loads + + class NoPremiumPl(MultiHoster): __name__ = "NoPremiumPl" -- cgit v1.2.3 From 2e8ed2bf0b357e907f6921c7bb88719bb347367b Mon Sep 17 00:00:00 2001 From: synweap15 Date: Wed, 9 Jul 2014 13:47:49 +0200 Subject: remove blank lines and unused imports --- module/plugins/hooks/RapideoPl.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/RapideoPl.py b/module/plugins/hooks/RapideoPl.py index fa3df9f84..de1a80908 100644 --- a/module/plugins/hooks/RapideoPl.py +++ b/module/plugins/hooks/RapideoPl.py @@ -8,6 +8,7 @@ try: except ImportError: from simplejson import loads + class RapideoPl(MultiHoster): __name__ = "RapideoPl" __version__ = "0.01" @@ -24,8 +25,8 @@ class RapideoPl(MultiHoster): __author_mail__ = ("dev@rapideo.pl") def getHoster(self): - hostings = loads(getURL("https://www.rapideo.pl/clipboard.php?json=3").strip()) + return [domain for row in hostings for domain in row["domains"] if row["sdownload"] == "0"] def getHosterCached(self): -- cgit v1.2.3 From 25d2cceff065a0268a7e183449ef54edf98f1783 Mon Sep 17 00:00:00 2001 From: synweap15 Date: Wed, 9 Jul 2014 13:49:12 +0200 Subject: simplify json loads, replace crypto with hashlib --- module/plugins/hooks/RapideoPl.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/RapideoPl.py b/module/plugins/hooks/RapideoPl.py index de1a80908..0c5327903 100644 --- a/module/plugins/hooks/RapideoPl.py +++ b/module/plugins/hooks/RapideoPl.py @@ -2,12 +2,7 @@ from module.plugins.internal.MultiHoster import MultiHoster from module.network.RequestFactory import getURL - -try: - from json import loads -except ImportError: - from simplejson import loads - +from module.common.json_layer import json_loads as loads class RapideoPl(MultiHoster): __name__ = "RapideoPl" -- cgit v1.2.3 From 88ba5ecd9027ffa7a8bb5eb207085295ad35724d Mon Sep 17 00:00:00 2001 From: synweap15 Date: Wed, 9 Jul 2014 13:49:42 +0200 Subject: newline fix --- module/plugins/hooks/RapideoPl.py | 1 + 1 file changed, 1 insertion(+) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/RapideoPl.py b/module/plugins/hooks/RapideoPl.py index 0c5327903..910dd175b 100644 --- a/module/plugins/hooks/RapideoPl.py +++ b/module/plugins/hooks/RapideoPl.py @@ -4,6 +4,7 @@ from module.plugins.internal.MultiHoster import MultiHoster from module.network.RequestFactory import getURL from module.common.json_layer import json_loads as loads + class RapideoPl(MultiHoster): __name__ = "RapideoPl" __version__ = "0.01" -- cgit v1.2.3 From 0824528da43d0842c15ffa0d4fe132309ca592eb Mon Sep 17 00:00:00 2001 From: synweap15 Date: Wed, 9 Jul 2014 14:05:40 +0200 Subject: newline fix --- module/plugins/hooks/NoPremiumPl.py | 2 -- 1 file changed, 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/NoPremiumPl.py b/module/plugins/hooks/NoPremiumPl.py index 1357c95e8..757af6037 100644 --- a/module/plugins/hooks/NoPremiumPl.py +++ b/module/plugins/hooks/NoPremiumPl.py @@ -2,11 +2,9 @@ from module.plugins.internal.MultiHoster import MultiHoster from module.network.RequestFactory import getURL - from module.common.json_layer import json_loads as loads - class NoPremiumPl(MultiHoster): __name__ = "NoPremiumPl" __version__ = "0.01" -- cgit v1.2.3 From 36b5bfedc2e57bd000831559ca8fb4d7e7899e24 Mon Sep 17 00:00:00 2001 From: tjeh Date: Sun, 20 Jul 2014 21:49:27 +0200 Subject: Added support for Multihosters.com multihoster. --- module/plugins/hooks/MultihostersCom.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 module/plugins/hooks/MultihostersCom.py (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/MultihostersCom.py b/module/plugins/hooks/MultihostersCom.py new file mode 100644 index 000000000..5ada3aa56 --- /dev/null +++ b/module/plugins/hooks/MultihostersCom.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- + +from module.network.RequestFactory import getURL +from module.plugins.internal.MultiHoster import MultiHoster + +class MultihostersCom(MultiHoster): + __name__ = "MultihostersCom" + __version__ = "0.01" + __type__ = "hook" + __config__ = [("activated", "bool", "Activated", False), + ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), + ("hosterList", "str", "Hoster list (comma separated)", ""), + ("unloadFailing", "bool", "Revert to standard download if download fails", False), + ("interval", "int", "Reload interval in hours (0 to disable)", 24)] + + __description__ = """Multihosters.com hook plugin""" + __author_name__ = "tjeh" + __author_mail__ = "tjeh@gmx.net" + + def getHoster(self): + page = getURL("http://www.multihosters.com/jDownloader.ashx?cmd=gethosters") + return [x.strip() for x in page.split(",")] \ No newline at end of file -- cgit v1.2.3 From 3554160654a1cb8e7000ebeea06aecdabc91af8e Mon Sep 17 00:00:00 2001 From: glukgluk Date: Thu, 7 Aug 2014 22:33:47 +0200 Subject: Create JustPremium.py --- module/plugins/hooks/JustPremium.py | 76 +++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 module/plugins/hooks/JustPremium.py (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/JustPremium.py b/module/plugins/hooks/JustPremium.py new file mode 100644 index 000000000..17028ef5e --- /dev/null +++ b/module/plugins/hooks/JustPremium.py @@ -0,0 +1,76 @@ +# -*- coding: utf-8 -*- +""" + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, + or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, see . + + @author: mazleu +""" +from module.plugins.Hook import Hook +from module.plugins.Account import Account +from module.plugins.Hoster import Hoster + + +class JustPremium(Hook): + __name__ = "JustPremium" + __version__ = "0.15" + __description__ = "If you add multiple links with at least one premium hoster link, all non premium links get removed" + __config__ = [("activated", "bool", "Activated", "False"), + ("freehosters","bool", "Allow all freehosters and other unknown sites", "false"), + ("nicehoster", "str", "unblock this hosters (comma seperated)", "Zippyshare.com")] + + __author_name__ = ("mazleu") + __author_mail__ = ("mazleica@gmail.com") + + event_list = ["linksAdded"] + + def coreReady(self) : + accs=str(self.core.accountManager.getAccountInfos()) + global badhosts + global hosts + hosts = "" + while "[{" in accs: + startid=accs.rfind("[], ", 0, accs.find("[{"))+2 + endid=accs.find("}]",startid)+2 + hosts=hosts+","+accs[startid+3:accs.find("'",startid+3)] + accs=accs[0:startid]+accs[endid:] + badhosts=accs.replace("': [], '",",")[2:-6] + hosts=hosts[1:] + hosts=hosts+","+self.getConfig("nicehoster") + self.logDebug("good hosts:",hosts) + self.logDebug("bad hosts:",badhosts) + + + def filterLinks(self, t): + links = self.core.api.checkURLs(t) + hosterlist ="" + bhosters = [x.strip() for x in badhosts.split(",")] + ghosters = [x.strip() for x in hosts.split(",")] + premhoster = False + for hoster in links: + self.logDebug(hoster) + if hoster in ghosters: + premhoster = True + if premhoster : + for hoster in links: + if self.getConfig("freehosters"): + if hoster in bhosters: + for link in links[hoster]: + t.remove(link) + self.logDebug("removed link '%s'because hoster was: '%s' " % (link,hoster)) + else: + if not hoster in ghosters: + for link in links[hoster]: + t.remove(link) + self.logDebug("removed link '%s'because hoster was: '%s' " % (link,hoster)) + def linksAdded(self, links, pid): + self.filterLinks(links) -- cgit v1.2.3 From dabe45332a554aba173c47754d39b514fa77c1bb Mon Sep 17 00:00:00 2001 From: glukgluk Date: Fri, 8 Aug 2014 21:53:56 +0200 Subject: Update JustPremium.py --- module/plugins/hooks/JustPremium.py | 77 +++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 37 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/JustPremium.py b/module/plugins/hooks/JustPremium.py index 17028ef5e..2c5788b75 100644 --- a/module/plugins/hooks/JustPremium.py +++ b/module/plugins/hooks/JustPremium.py @@ -22,55 +22,58 @@ from module.plugins.Hoster import Hoster class JustPremium(Hook): __name__ = "JustPremium" - __version__ = "0.15" + __version__ = "0.16" __description__ = "If you add multiple links with at least one premium hoster link, all non premium links get removed" __config__ = [("activated", "bool", "Activated", "False"), - ("freehosters","bool", "Allow all freehosters and other unknown sites", "false"), + ("freehosters","bool", "Allow all freehosters and other unknown sites", "false"), ("nicehoster", "str", "unblock this hosters (comma seperated)", "Zippyshare.com")] - + __author_name__ = ("mazleu") __author_mail__ = ("mazleica@gmail.com") event_list = ["linksAdded"] - - def coreReady(self) : + + def coreReady(self) : accs=str(self.core.accountManager.getAccountInfos()) - global badhosts - global hosts - hosts = "" - while "[{" in accs: - startid=accs.rfind("[], ", 0, accs.find("[{"))+2 - endid=accs.find("}]",startid)+2 - hosts=hosts+","+accs[startid+3:accs.find("'",startid+3)] - accs=accs[0:startid]+accs[endid:] - badhosts=accs.replace("': [], '",",")[2:-6] - hosts=hosts[1:] - hosts=hosts+","+self.getConfig("nicehoster") - self.logDebug("good hosts:",hosts) - self.logDebug("bad hosts:",badhosts) + global badhosts + global hosts + hosts = "" + while "[{" in accs: + startid=accs.rfind("[], ", 0, accs.find("[{"))+2 + endid=accs.find("}]",startid)+2 + hosts=hosts+","+accs[startid+3:accs.find("'",startid+3)] + accs=accs[0:startid]+accs[endid:] + badhosts=accs.replace("': [], '",",")[2:-6] + hosts=hosts[1:] + hosts=hosts+","+self.getConfig("nicehoster") + self.logDebug("good hosts:",hosts) + self.logDebug("bad hosts:",badhosts) - def filterLinks(self, t): - links = self.core.api.checkURLs(t) + def filterLinks(self, t): + links = self.core.api.checkURLs(t) hosterlist ="" - bhosters = [x.strip() for x in badhosts.split(",")] - ghosters = [x.strip() for x in hosts.split(",")] - premhoster = False - for hoster in links: - self.logDebug(hoster) + bhosters = [x.strip() for x in badhosts.split(",")] + ghosters = [x.strip() for x in hosts.split(",")] + premhoster = False + for hoster in links: + self.logDebug(hoster) if hoster in ghosters: premhoster = True - if premhoster : - for hoster in links: - if self.getConfig("freehosters"): - if hoster in bhosters: - for link in links[hoster]: - t.remove(link) - self.logDebug("removed link '%s'because hoster was: '%s' " % (link,hoster)) - else: - if not hoster in ghosters: - for link in links[hoster]: - t.remove(link) - self.logDebug("removed link '%s'because hoster was: '%s' " % (link,hoster)) + self.logDebug ("Found at least one hoster with account") + if premhoster : + for hoster in links: + if self.getConfig("freehosters"): + if hoster in bhosters: + self.logInfo("remove links from hoster '%s' " % (hoster)) + for link in links[hoster]: + t.remove(link) + self.logDebug("remove link '%s'because hoster was: '%s' " % (link,hoster)) + else: + if not hoster in ghosters: + self.logInfo("remove links from hoster '%s' " % (hoster)) + for link in links[hoster]: + t.remove(link) + self.logDebug("remove link '%s' because hoster was: '%s' " % (link,hoster)) def linksAdded(self, links, pid): self.filterLinks(links) -- cgit v1.2.3 From 168f175ce4765dec7e847c45d95e4babe20a7193 Mon Sep 17 00:00:00 2001 From: synweap15 Date: Mon, 3 Nov 2014 14:42:05 +0100 Subject: New __authors__ key, added __license__ --- module/plugins/hooks/NoPremiumPl.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/NoPremiumPl.py b/module/plugins/hooks/NoPremiumPl.py index 757af6037..f60cb3dd6 100644 --- a/module/plugins/hooks/NoPremiumPl.py +++ b/module/plugins/hooks/NoPremiumPl.py @@ -17,8 +17,8 @@ class NoPremiumPl(MultiHoster): ("interval", "int", "Reload supported hosts interval in hours (0 to disable)", "24")] __description__ = "NoPremium.pl hook" - __author_name__ = ("goddie") - __author_mail__ = ("dev@nopremium.pl") + __license__ = "GPLv3" + __authors__ = [("goddie", "dev@nopremium.pl")] def getHoster(self): hostings = loads(getURL("https://www.nopremium.pl/clipboard.php?json=3").strip()) -- cgit v1.2.3 From 005710831caa04bbe372b54ac357658963fe02bb Mon Sep 17 00:00:00 2001 From: synweap15 Date: Mon, 3 Nov 2014 14:44:44 +0100 Subject: New __authors__ key, added __license__ --- module/plugins/hooks/RapideoPl.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/RapideoPl.py b/module/plugins/hooks/RapideoPl.py index 910dd175b..a5d7a34a5 100644 --- a/module/plugins/hooks/RapideoPl.py +++ b/module/plugins/hooks/RapideoPl.py @@ -17,8 +17,8 @@ class RapideoPl(MultiHoster): ("interval", "int", "Reload supported hosts interval in hours (0 to disable)", "24")] __description__ = "Rapideo.pl hook" - __author_name__ = ("goddie") - __author_mail__ = ("dev@rapideo.pl") + __license__ = "GPLv3" + __authors__ = [("goddie", "dev@rapideo.pl")] def getHoster(self): hostings = loads(getURL("https://www.rapideo.pl/clipboard.php?json=3").strip()) -- cgit v1.2.3 From f71c1ef70a199e42e8a519364d9924e138ffd37c Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 24 Dec 2014 15:48:08 +0100 Subject: [ExtractArchive] Remove empty directory --- module/plugins/hooks/ExtractArchive.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 16942bef0..8b3b4e310 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -58,7 +58,7 @@ from module.utils import save_join, uniqify class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.00" + __version__ = "1.01" __config__ = [("activated" , "bool" , "Activated" , True ), ("fullpath" , "bool" , "Extract full path" , True ), @@ -135,7 +135,7 @@ class ExtractArchive(Hook): self.logInfo(_("Package %s queued for later extracting") % pypack.name) self.queue.append(pid) else: - self.manager.startThread(self.extract, [pid]) + self.extractPackage(pid) @threaded @@ -239,6 +239,7 @@ class ExtractArchive(Hook): new_files = None if new_files is None: + self.logWarning(basename(target), _("No files extracted")) success = False continue @@ -264,6 +265,12 @@ class ExtractArchive(Hook): else: self.logInfo(_("No files found to extract")) + if not matched or not success and subfolder: + try: + os.rmdir(out) + except OSError: + pass + return True if not failed else False -- cgit v1.2.3 From 3a7839e3c8f78c729adde099f071c31abf64ea1b Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 24 Dec 2014 16:48:08 +0100 Subject: [SkipRev] Improve downloadFailed routine --- module/plugins/hooks/SkipRev.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py index 1eaee0118..cc32c365e 100644 --- a/module/plugins/hooks/SkipRev.py +++ b/module/plugins/hooks/SkipRev.py @@ -18,7 +18,7 @@ def _setup(self): class SkipRev(Hook): __name__ = "SkipRev" __type__ = "hook" - __version__ = "0.20" + __version__ = "0.21" __config__ = [("tokeep", "int", "Number of rev files to keep for package (-1 to auto)", -1)] @@ -72,7 +72,7 @@ class SkipRev(Hook): tokeep = self.getConfig("tokeep") if tokeep: - saved = [True for link in self.core.api.getPackageData(pyfile.packageid).links \ + saved = [True for link in self.core.api.getPackageData(pyfile.package().id).links \ if link.name.endswith(".rev") and link.status in (0, 12)].count(True) if not saved or saved < tokeep: #: keep one rev at least in auto mode @@ -84,12 +84,17 @@ class SkipRev(Hook): def downloadFailed(self, pyfile): + #: Check if pyfile is still "failed", + # maybe might has been restarted in meantime + if pyfile.status != 8: + return + tokeep = self.getConfig("tokeep") if not tokeep: return - for link in self.core.api.getPackageData(pyfile.packageid).links: + for link in self.core.api.getPackageData(pyfile.package().id).links: if link.status is 4 and link.name.endswith(".rev"): pylink = self._pyfile(link) -- cgit v1.2.3 From 429f8b54b11b1df9d99aa8f3fe222e47d98a5faf Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 24 Dec 2014 16:49:01 +0100 Subject: [UnSkipOnFail] Rewritten --- module/plugins/hooks/UnSkipOnFail.py | 127 ++++++++++++++++++----------------- 1 file changed, 65 insertions(+), 62 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/UnSkipOnFail.py b/module/plugins/hooks/UnSkipOnFail.py index d3baccfc2..87c21dda7 100644 --- a/module/plugins/hooks/UnSkipOnFail.py +++ b/module/plugins/hooks/UnSkipOnFail.py @@ -1,22 +1,19 @@ # -*- coding: utf-8 -*- -from os.path import basename - from module.PyFile import PyFile from module.plugins.Hook import Hook -from module.utils import fs_encode class UnSkipOnFail(Hook): __name__ = "UnSkipOnFail" __type__ = "hook" - __version__ = "0.02" + __version__ = "0.03" __config__ = [("activated", "bool", "Activated", True)] - __description__ = """When a download fails, restart skipped duplicates""" + __description__ = """Queue skipped duplicates""" __license__ = "GPLv3" - __authors__ = [("hagg", None)] + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] #@TODO: Remove in 0.4.10 @@ -25,68 +22,74 @@ class UnSkipOnFail(Hook): def downloadFailed(self, pyfile): - pyfile_name = basename(pyfile.name) - pid = pyfile.package().id - msg = _('look for skipped duplicates for %s (pid:%s)') - self.logInfo(msg % (pyfile_name, pid)) - dups = self.findDuplicates(pyfile) - for link in dups: - # check if link is "skipped"(=4) - if link.status == 4: - lpid = link.packageID - self.logInfo(_('restart "%s" (pid:%s)') % (pyfile_name, lpid)) - self.setLinkStatus(link, "queued") - - - def findDuplicates(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.logInfo(msg % (pyfile.name, pyfile.package().id)) + + dup = self.findDuplicate(pyfile) + if dup: + self.logInfo(_("Queue found duplicate: %s (pid:%s)") % (dup.name, dup.packageID)) + + #: Change status of "link" to "new_status". + # "link" has to be a valid FileData object, + # "new_status" has to be a valid status name + # (i.e. "queued" for this Plugin) + # It creates a temporary PyFile object using + # "link" data, changes its status, and tells + # the core.files-manager to save its data. + pylink = _pyfile(link) + + pylink.setCustomStatus("UnSkipOnFail", "queued") + + self.core.files.save() + pylink.release() + + else: + self.logInfo(_("No duplicates found")) + + + def findDuplicate(self, pyfile): """ Search all packages for duplicate links to "pyfile". Duplicates are links that would overwrite "pyfile". To test on duplicity the package-folder and link-name - of twolinks are compared (basename(link.name)). + of twolinks are compared (link.name). So this method returns a list of all links with equal package-folders and filenames as "pyfile", but except the data for "pyfile" iotselöf. It does MOT check the link's status. """ - dups = [] - pyfile_name = fs_encode(basename(pyfile.name)) - # get packages (w/o files, as most file data is useless here) - queue = self.core.api.getQueue() + queue = self.api.getQueue() #: get packages (w/o files, as most file data is useless here) + for package in queue: - # check if package-folder equals pyfile's package folder - if fs_encode(package.folder) == fs_encode(pyfile.package().folder): - # now get packaged data w/ files/links - pdata = self.core.api.getPackageData(package.pid) - if pdata.links: - for link in pdata.links: - link_name = fs_encode(basename(link.name)) - # check if link name collides with pdata's name - if link_name == pyfile_name: - # at last check if it is not pyfile itself - if link.fid != pyfile.id: - 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, - "new_status" has to be a valid status name - (i.e. "queued" for this Plugin) - It creates a temporary PyFile object using - "link" data, changes its status, and tells - the core.files-manager to save its data. - """ - pyfile = PyFile(self.core.files, - link.fid, - link.url, - link.name, - link.size, - link.status, - link.error, - link.plugin, - link.packageID, - link.order) - pyfile.setStatus(new_status) - self.core.files.save() - pyfile.release() + #: check if package-folder equals pyfile's package folder + if package.folder != pyfile.package().folder: + continue + + #: now get packaged data w/ files/links + pdata = self.api.getPackageData(package.pid) + for link in pdata.links: + #: check if link is "skipped" + if link.status != 4: + continue + + #: check if link name collides with pdata's name + #: AND at last check if it is not pyfile itself + if link.name == pyfile.name and link.fid != pyfile.id: + return link + + + def _pyfile(self, link): + return PyFile(self.core.files, + link.fid, + link.url, + link.name, + link.size, + link.status, + link.error, + link.plugin, + link.packageID, + link.order) -- cgit v1.2.3 From 22285c54c80b59ac17dd6a74dcb2044729258f43 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 24 Dec 2014 16:50:22 +0100 Subject: [UnSkipOnFail] Rewritten (2) --- module/plugins/hooks/UnSkipOnFail.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/UnSkipOnFail.py b/module/plugins/hooks/UnSkipOnFail.py index 87c21dda7..fad29b17b 100644 --- a/module/plugins/hooks/UnSkipOnFail.py +++ b/module/plugins/hooks/UnSkipOnFail.py @@ -11,7 +11,7 @@ class UnSkipOnFail(Hook): __config__ = [("activated", "bool", "Activated", True)] - __description__ = """Queue skipped duplicates""" + __description__ = """Queue skipped duplicates when download fails""" __license__ = "GPLv3" __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] -- cgit v1.2.3 From 8930bf1dc4e3915c46b413d5d61868dabf7d24d3 Mon Sep 17 00:00:00 2001 From: pbr85at Date: Thu, 25 Dec 2014 12:46:13 +0100 Subject: Update UnSkipOnFail.py indent error --- module/plugins/hooks/UnSkipOnFail.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/UnSkipOnFail.py b/module/plugins/hooks/UnSkipOnFail.py index fad29b17b..37f193f5d 100644 --- a/module/plugins/hooks/UnSkipOnFail.py +++ b/module/plugins/hooks/UnSkipOnFail.py @@ -52,7 +52,7 @@ class UnSkipOnFail(Hook): self.logInfo(_("No duplicates found")) - def findDuplicate(self, pyfile): + def findDuplicate(self, pyfile): """ Search all packages for duplicate links to "pyfile". Duplicates are links that would overwrite "pyfile". To test on duplicity the package-folder and link-name -- cgit v1.2.3 From d442ce97a7ba66d90527cfbee313dc5640975def Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Thu, 25 Dec 2014 16:07:09 +0100 Subject: [ClickAndLoad] Revert initPeriodical --- module/plugins/hooks/ClickAndLoad.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 27d99c71c..04aac2f10 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -52,7 +52,7 @@ def forward(source, destination): class ClickAndLoad(Hook): __name__ = "ClickAndLoad" __type__ = "hook" - __version__ = "0.23" + __version__ = "0.24" __config__ = [("activated", "bool", "Activated", True), ("extern", "bool", "Allow external link adding", False)] @@ -63,11 +63,6 @@ class ClickAndLoad(Hook): ("mkaay", "mkaay@mkaay.de")] - #@TODO: Remove in 0.4.10 - def initPeriodical(self): - pass - - def coreReady(self): self.port = int(self.config['webinterface']['port']) if self.config['webinterface']['activated']: -- cgit v1.2.3 From 37c4fdbe85bd193ec69e222330f05b7adf742145 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Thu, 25 Dec 2014 16:08:32 +0100 Subject: [UnSkipOnFail] Bump up version --- module/plugins/hooks/UnSkipOnFail.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/UnSkipOnFail.py b/module/plugins/hooks/UnSkipOnFail.py index 37f193f5d..88557e831 100644 --- a/module/plugins/hooks/UnSkipOnFail.py +++ b/module/plugins/hooks/UnSkipOnFail.py @@ -7,7 +7,7 @@ from module.plugins.Hook import Hook class UnSkipOnFail(Hook): __name__ = "UnSkipOnFail" __type__ = "hook" - __version__ = "0.03" + __version__ = "0.04" __config__ = [("activated", "bool", "Activated", True)] -- cgit v1.2.3 From 4c63928557398891c30d3e2b7c962a07b3483315 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 26 Dec 2014 04:18:41 +0100 Subject: Rename AbstractExtractor to Extractor --- module/plugins/hooks/ExtractArchive.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 8b3b4e310..af78ffc93 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -51,14 +51,14 @@ if os.name != "nt": from pwd import getpwnam from module.plugins.Hook import Hook, threaded, Expose -from module.plugins.internal.AbstractExtractor import ArchiveError, CRCError, PasswordError +from module.plugins.internal.Extractor import ArchiveError, CRCError, PasswordError from module.utils import save_join, uniqify class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.01" + __version__ = "1.02" __config__ = [("activated" , "bool" , "Activated" , True ), ("fullpath" , "bool" , "Extract full path" , True ), -- cgit v1.2.3 From 60c4c83ed84f5bf7f638f99d21e74af314935280 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 26 Dec 2014 04:20:27 +0100 Subject: [UnSkipOnFail] Fixup --- module/plugins/hooks/UnSkipOnFail.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/UnSkipOnFail.py b/module/plugins/hooks/UnSkipOnFail.py index 88557e831..1becb937a 100644 --- a/module/plugins/hooks/UnSkipOnFail.py +++ b/module/plugins/hooks/UnSkipOnFail.py @@ -7,7 +7,7 @@ from module.plugins.Hook import Hook class UnSkipOnFail(Hook): __name__ = "UnSkipOnFail" __type__ = "hook" - __version__ = "0.04" + __version__ = "0.05" __config__ = [("activated", "bool", "Activated", True)] @@ -62,7 +62,7 @@ class UnSkipOnFail(Hook): the data for "pyfile" iotselöf. It does MOT check the link's status. """ - queue = self.api.getQueue() #: get packages (w/o files, as most file data is useless here) + queue = self.core.api.getQueue() #: get packages (w/o files, as most file data is useless here) for package in queue: #: check if package-folder equals pyfile's package folder @@ -70,7 +70,7 @@ class UnSkipOnFail(Hook): continue #: now get packaged data w/ files/links - pdata = self.api.getPackageData(package.pid) + pdata = self.core.api.getPackageData(package.pid) for link in pdata.links: #: check if link is "skipped" if link.status != 4: -- cgit v1.2.3 From 575ce629081995766a231f0a9f3e97e3b79d23b1 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 27 Dec 2014 21:20:59 +0100 Subject: Update MultiHook based hooks --- module/plugins/hooks/AlldebridCom.py | 11 +++++------ module/plugins/hooks/DebridItaliaCom.py | 13 ++++++------- module/plugins/hooks/EasybytezCom.py | 8 ++++---- module/plugins/hooks/FastixRu.py | 11 +++++------ module/plugins/hooks/FreeWayMe.py | 13 ++++++------- module/plugins/hooks/LinksnappyCom.py | 13 ++++++------- module/plugins/hooks/MegaDebridEu.py | 9 ++++----- module/plugins/hooks/MultishareCz.py | 11 +++++------ module/plugins/hooks/MyfastfileCom.py | 13 ++++++------- module/plugins/hooks/NoPremiumPl.py | 2 +- module/plugins/hooks/OverLoadMe.py | 13 ++++++------- module/plugins/hooks/PremiumTo.py | 11 +++++------ module/plugins/hooks/PremiumizeMe.py | 13 ++++++------- module/plugins/hooks/RPNetBiz.py | 13 ++++++------- module/plugins/hooks/RealdebridCom.py | 13 ++++++------- module/plugins/hooks/RehostTo.py | 13 ++++++------- module/plugins/hooks/SimplyPremiumCom.py | 13 ++++++------- module/plugins/hooks/SimplydebridCom.py | 11 +++++------ module/plugins/hooks/UnrestrictLi.py | 13 ++++++------- module/plugins/hooks/XFileSharingPro.py | 22 +++++++++++----------- module/plugins/hooks/ZeveraCom.py | 11 +++++------ 21 files changed, 116 insertions(+), 134 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/AlldebridCom.py b/module/plugins/hooks/AlldebridCom.py index d5986053f..88a637de7 100644 --- a/module/plugins/hooks/AlldebridCom.py +++ b/module/plugins/hooks/AlldebridCom.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- -from module.network.RequestFactory import getURL from module.plugins.internal.MultiHook import MultiHook @@ -10,9 +9,9 @@ class AlldebridCom(MultiHook): __version__ = "0.14" __config__ = [("https", "bool", "Enable HTTPS", False), - ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), - ("hosterList", "str", "Hoster list (comma separated)", ""), - ("unloadFailing", "bool", "Revert to stanard download if download fails", False), + ("mode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), + ("pluginlist", "str", "Hoster list (comma separated)", ""), + ("revertfailed", "bool", "Revert to stanard download if download fails", False), ("interval", "int", "Reload interval in hours (0 to disable)", 24)] __description__ = """Alldebrid.com hook plugin""" @@ -20,8 +19,8 @@ class AlldebridCom(MultiHook): __authors__ = [("Andy Voigt", "spamsales@online.de")] - def getHoster(self): + def getHosters(self): https = "https" if self.getConfig("https") else "http" - page = getURL(https + "://www.alldebrid.com/api.php", get={'action': "get_host"}).replace("\"", "").strip() + page = self.getURL(https + "://www.alldebrid.com/api.php", get={'action': "get_host"}).replace("\"", "").strip() return [x.strip() for x in page.split(",") if x.strip()] diff --git a/module/plugins/hooks/DebridItaliaCom.py b/module/plugins/hooks/DebridItaliaCom.py index e31bc98d7..d18be5384 100644 --- a/module/plugins/hooks/DebridItaliaCom.py +++ b/module/plugins/hooks/DebridItaliaCom.py @@ -2,18 +2,17 @@ import re -from module.network.RequestFactory import getURL from module.plugins.internal.MultiHook import MultiHook class DebridItaliaCom(MultiHook): __name__ = "DebridItaliaCom" __type__ = "hook" - __version__ = "0.10" + __version__ = "0.11" - __config__ = [("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), - ("hosterList", "str", "Hoster list (comma separated)", ""), - ("unloadFailing", "bool", "Revert to standard download if download fails", False), + __config__ = [("mode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), + ("pluginlist", "str", "Hoster list (comma separated)", ""), + ("revertfailed", "bool", "Revert to standard download if download fails", False), ("interval", "int", "Reload interval in hours (0 to disable)", 24)] __description__ = """Debriditalia.com hook plugin""" @@ -22,5 +21,5 @@ class DebridItaliaCom(MultiHook): ("Walter Purcaro", "vuolter@gmail.com")] - def getHoster(self): - return getURL("http://debriditalia.com/api.php", get={'hosts': ""}).replace('"', '').split(',') + def getHosters(self): + return self.getURL("http://debriditalia.com/api.php", get={'hosts': ""}).replace('"', '').split(',') diff --git a/module/plugins/hooks/EasybytezCom.py b/module/plugins/hooks/EasybytezCom.py index 0dab2a7fe..16149580c 100644 --- a/module/plugins/hooks/EasybytezCom.py +++ b/module/plugins/hooks/EasybytezCom.py @@ -8,17 +8,17 @@ from module.plugins.internal.MultiHook import MultiHook class EasybytezCom(MultiHook): __name__ = "EasybytezCom" __type__ = "hook" - __version__ = "0.04" + __version__ = "0.05" - __config__ = [("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), - ("hosterList", "str", "Hoster list (comma separated)", "")] + __config__ = [("mode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), + ("pluginlist", "str", "Hoster list (comma separated)", "")] __description__ = """EasyBytez.com hook plugin""" __license__ = "GPLv3" __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] - def getHoster(self): + def getHosters(self): self.account = self.core.accountManager.getAccountPlugin(self.__name__) user = self.account.selectAccount()[0] diff --git a/module/plugins/hooks/FastixRu.py b/module/plugins/hooks/FastixRu.py index 73297eb23..a4b423fb7 100644 --- a/module/plugins/hooks/FastixRu.py +++ b/module/plugins/hooks/FastixRu.py @@ -1,17 +1,16 @@ # -*- coding: utf-8 -*- from module.common.json_layer import json_loads -from module.network.RequestFactory import getURL from module.plugins.internal.MultiHook import MultiHook class FastixRu(MultiHook): __name__ = "FastixRu" __type__ = "hook" - __version__ = "0.03" + __version__ = "0.04" - __config__ = [("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), - ("unloadFailing", "bool", "Revert to standard download if download fails", False), + __config__ = [("mode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), + ("revertfailed", "bool", "Revert to standard download if download fails", False), ("interval", "int", "Reload interval in hours (0 to disable)", 24)] __description__ = """Fastix.ru hook plugin""" @@ -19,8 +18,8 @@ class FastixRu(MultiHook): __authors__ = [("Massimo Rosamilia", "max@spiritix.eu")] - def getHoster(self): - page = getURL("http://fastix.ru/api_v2", + def getHosters(self): + page = self.getURL("http://fastix.ru/api_v2", get={'apikey': "5182964c3f8f9a7f0b00000a_kelmFB4n1IrnCDYuIFn2y", 'sub' : "allowed_sources"}) host_list = json_loads(page) diff --git a/module/plugins/hooks/FreeWayMe.py b/module/plugins/hooks/FreeWayMe.py index 0b71fc35b..f2a4f2d34 100644 --- a/module/plugins/hooks/FreeWayMe.py +++ b/module/plugins/hooks/FreeWayMe.py @@ -1,17 +1,16 @@ # -*- coding: utf-8 -*- -from module.network.RequestFactory import getURL from module.plugins.internal.MultiHook import MultiHook class FreeWayMe(MultiHook): __name__ = "FreeWayMe" __type__ = "hook" - __version__ = "0.12" + __version__ = "0.13" - __config__ = [("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported):", "all"), - ("hosterList", "str", "Hoster list (comma separated)", ""), - ("unloadFailing", "bool", "Revert to stanard download if download fails", False), + __config__ = [("mode", "all;listed;unlisted", "Use for hosters (if supported):", "all"), + ("pluginlist", "str", "Hoster list (comma separated)", ""), + ("revertfailed", "bool", "Revert to stanard download if download fails", False), ("interval", "int", "Reload interval in hours (0 to disable)", 24)] __description__ = """FreeWay.me hook plugin""" @@ -19,7 +18,7 @@ class FreeWayMe(MultiHook): __authors__ = [("Nicolas Giese", "james@free-way.me")] - def getHoster(self): - hostis = getURL("https://www.free-way.me/ajax/jd.php", get={'id': 3}).replace("\"", "").strip() + def getHosters(self): + hostis = self.getURL("https://www.free-way.me/ajax/jd.php", get={'id': 3}).replace("\"", "").strip() self.logDebug("Hosters", hostis) return [x.strip() for x in hostis.split(",") if x.strip()] diff --git a/module/plugins/hooks/LinksnappyCom.py b/module/plugins/hooks/LinksnappyCom.py index 96bf1c0d1..a1c4b90f7 100644 --- a/module/plugins/hooks/LinksnappyCom.py +++ b/module/plugins/hooks/LinksnappyCom.py @@ -1,18 +1,17 @@ # -*- coding: utf-8 -*- from module.common.json_layer import json_loads -from module.network.RequestFactory import getURL from module.plugins.internal.MultiHook import MultiHook class LinksnappyCom(MultiHook): __name__ = "LinksnappyCom" __type__ = "hook" - __version__ = "0.02" + __version__ = "0.03" - __config__ = [("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), - ("hosterList", "str", "Hoster list (comma separated)", ""), - ("unloadFailing", "bool", "Revert to standard download if download fails", False), + __config__ = [("mode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), + ("pluginlist", "str", "Hoster list (comma separated)", ""), + ("revertfailed", "bool", "Revert to standard download if download fails", False), ("interval", "int", "Reload interval in hours (0 to disable)", 24)] __description__ = """Linksnappy.com hook plugin""" @@ -20,8 +19,8 @@ class LinksnappyCom(MultiHook): __authors__ = [("stickell", "l.stickell@yahoo.it")] - def getHoster(self): - json_data = getURL("http://gen.linksnappy.com/lseAPI.php", get={'act': "FILEHOSTS"}) + def getHosters(self): + json_data = self.getURL("http://gen.linksnappy.com/lseAPI.php", get={'act': "FILEHOSTS"}) json_data = json_loads(json_data) return json_data['return'].keys() diff --git a/module/plugins/hooks/MegaDebridEu.py b/module/plugins/hooks/MegaDebridEu.py index f3a0c31ea..5fb7e1ea6 100644 --- a/module/plugins/hooks/MegaDebridEu.py +++ b/module/plugins/hooks/MegaDebridEu.py @@ -1,24 +1,23 @@ # -*- coding: utf-8 -*- from module.common.json_layer import json_loads -from module.network.RequestFactory import getURL from module.plugins.internal.MultiHook import MultiHook class MegaDebridEu(MultiHook): __name__ = "MegaDebridEu" __type__ = "hook" - __version__ = "0.03" + __version__ = "0.04" - __config__ = [("unloadFailing", "bool", "Revert to standard download if download fails", False)] + __config__ = [("revertfailed", "bool", "Revert to standard download if download fails", False)] __description__ = """mega-debrid.eu hook plugin""" __license__ = "GPLv3" __authors__ = [("D.Ducatel", "dducatel@je-geek.fr")] - def getHoster(self): - reponse = getURL("http://www.mega-debrid.eu/api.php", get={'action': "getHosters"}) + def getHosters(self): + reponse = self.getURL("http://www.mega-debrid.eu/api.php", get={'action': "getHosters"}) json_data = json_loads(reponse) if json_data['response_code'] == "ok": diff --git a/module/plugins/hooks/MultishareCz.py b/module/plugins/hooks/MultishareCz.py index 5ec5b63b6..2dadf5dc1 100644 --- a/module/plugins/hooks/MultishareCz.py +++ b/module/plugins/hooks/MultishareCz.py @@ -2,17 +2,16 @@ import re -from module.network.RequestFactory import getURL from module.plugins.internal.MultiHook import MultiHook class MultishareCz(MultiHook): __name__ = "MultishareCz" __type__ = "hook" - __version__ = "0.05" + __version__ = "0.06" - __config__ = [("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), - ("hosterList", "str", "Hoster list (comma separated)", "uloz.to")] + __config__ = [("mode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), + ("pluginlist", "str", "Hoster list (comma separated)", "uloz.to")] __description__ = """MultiShare.cz hook plugin""" __license__ = "GPLv3" @@ -22,6 +21,6 @@ class MultishareCz(MultiHook): HOSTER_PATTERN = r']*?alt="([^"]+)">\s*[^>]*?alt="OK"' - def getHoster(self): - page = getURL("http://www.multishare.cz/monitoring/") + def getHosters(self): + page = self.getURL("http://www.multishare.cz/monitoring/") return re.findall(self.HOSTER_PATTERN, page) diff --git a/module/plugins/hooks/MyfastfileCom.py b/module/plugins/hooks/MyfastfileCom.py index ec7c4e55b..2fda0d3bf 100644 --- a/module/plugins/hooks/MyfastfileCom.py +++ b/module/plugins/hooks/MyfastfileCom.py @@ -1,18 +1,17 @@ # -*- coding: utf-8 -*- from module.common.json_layer import json_loads -from module.network.RequestFactory import getURL from module.plugins.internal.MultiHook import MultiHook class MyfastfileCom(MultiHook): __name__ = "MyfastfileCom" __type__ = "hook" - __version__ = "0.03" + __version__ = "0.04" - __config__ = [("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), - ("hosterList", "str", "Hoster list (comma separated)", ""), - ("unloadFailing", "bool", "Revert to standard download if download fails", False), + __config__ = [("mode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), + ("pluginlist", "str", "Hoster list (comma separated)", ""), + ("revertfailed", "bool", "Revert to standard download if download fails", False), ("interval", "int", "Reload interval in hours (0 to disable)", 24)] __description__ = """Myfastfile.com hook plugin""" @@ -20,8 +19,8 @@ class MyfastfileCom(MultiHook): __authors__ = [("stickell", "l.stickell@yahoo.it")] - def getHoster(self): - json_data = getURL("http://myfastfile.com/api.php", get={'hosts': ""}, decode=True) + def getHosters(self): + json_data = self.getURL("http://myfastfile.com/api.php", get={'hosts': ""}, decode=True) self.logDebug("JSON data", json_data) json_data = json_loads(json_data) diff --git a/module/plugins/hooks/NoPremiumPl.py b/module/plugins/hooks/NoPremiumPl.py index f60cb3dd6..84a019b8d 100644 --- a/module/plugins/hooks/NoPremiumPl.py +++ b/module/plugins/hooks/NoPremiumPl.py @@ -3,7 +3,7 @@ from module.plugins.internal.MultiHoster import MultiHoster from module.network.RequestFactory import getURL from module.common.json_layer import json_loads as loads - + class NoPremiumPl(MultiHoster): __name__ = "NoPremiumPl" diff --git a/module/plugins/hooks/OverLoadMe.py b/module/plugins/hooks/OverLoadMe.py index 378ce0a65..eb3da319a 100644 --- a/module/plugins/hooks/OverLoadMe.py +++ b/module/plugins/hooks/OverLoadMe.py @@ -1,18 +1,17 @@ # -*- coding: utf-8 -*- -from module.network.RequestFactory import getURL from module.plugins.internal.MultiHook import MultiHook class OverLoadMe(MultiHook): __name__ = "OverLoadMe" __type__ = "hook" - __version__ = "0.02" + __version__ = "0.03" __config__ = [("https", "bool", "Enable HTTPS", True), - ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported):", "all"), - ("hosterList", "str", "Hoster list (comma separated)", ""), - ("unloadFailing", "bool", "Revert to standard download if download fails", False), + ("mode", "all;listed;unlisted", "Use for hosters (if supported):", "all"), + ("pluginlist", "str", "Hoster list (comma separated)", ""), + ("revertfailed", "bool", "Revert to standard download if download fails", False), ("interval", "int", "Reload interval in hours (0 to disable)", 12)] __description__ = """Over-Load.me hook plugin""" @@ -20,9 +19,9 @@ class OverLoadMe(MultiHook): __authors__ = [("marley", "marley@over-load.me")] - def getHoster(self): + def getHosters(self): https = "https" if self.getConfig("https") else "http" - page = getURL(https + "://api.over-load.me/hoster.php", + page = self.getURL(https + "://api.over-load.me/hoster.php", get={'auth': "0001-cb1f24dadb3aa487bda5afd3b76298935329be7700cd7-5329be77-00cf-1ca0135f"}).replace("\"", "").strip() self.logDebug("Hosterlist", page) diff --git a/module/plugins/hooks/PremiumTo.py b/module/plugins/hooks/PremiumTo.py index 3087db552..348bb6789 100644 --- a/module/plugins/hooks/PremiumTo.py +++ b/module/plugins/hooks/PremiumTo.py @@ -1,16 +1,15 @@ # -*- coding: utf-8 -*- -from module.network.RequestFactory import getURL from module.plugins.internal.MultiHook import MultiHook class PremiumTo(MultiHook): __name__ = "PremiumTo" __type__ = "hook" - __version__ = "0.05" + __version__ = "0.06" - __config__ = [("hosterListMode", "all;listed;unlisted", "Use for downloads from supported hosters:", "all"), - ("hosterList", "str", "Hoster list (comma separated)", "")] + __config__ = [("mode", "all;listed;unlisted", "Use for downloads from supported hosters:", "all"), + ("pluginlist", "str", "Hoster list (comma separated)", "")] __description__ = """Premium.to hook plugin""" __license__ = "GPLv3" @@ -19,8 +18,8 @@ class PremiumTo(MultiHook): ("stickell", "l.stickell@yahoo.it")] - def getHoster(self): - page = getURL("http://premium.to/api/hosters.php", + def getHosters(self): + page = self.getURL("http://premium.to/api/hosters.php", get={'username': self.account.username, 'password': self.account.password}) return [x.strip() for x in page.replace("\"", "").split(";")] diff --git a/module/plugins/hooks/PremiumizeMe.py b/module/plugins/hooks/PremiumizeMe.py index b37728e06..e23f13895 100644 --- a/module/plugins/hooks/PremiumizeMe.py +++ b/module/plugins/hooks/PremiumizeMe.py @@ -1,18 +1,17 @@ # -*- coding: utf-8 -*- from module.common.json_layer import json_loads -from module.network.RequestFactory import getURL from module.plugins.internal.MultiHook import MultiHook class PremiumizeMe(MultiHook): __name__ = "PremiumizeMe" __type__ = "hook" - __version__ = "0.14" + __version__ = "0.15" - __config__ = [("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported):", "all"), - ("hosterList", "str", "Hoster list (comma separated)", ""), - ("unloadFailing", "bool", "Revert to stanard download if download fails", False), + __config__ = [("mode", "all;listed;unlisted", "Use for hosters (if supported):", "all"), + ("pluginlist", "str", "Hoster list (comma separated)", ""), + ("revertfailed", "bool", "Revert to stanard download if download fails", False), ("interval", "int", "Reload interval in hours (0 to disable)", 24)] __description__ = """Premiumize.me hook plugin""" @@ -20,7 +19,7 @@ class PremiumizeMe(MultiHook): __authors__ = [("Florian Franzen", "FlorianFranzen@gmail.com")] - def getHoster(self): + def getHosters(self): # If no accounts are available there will be no hosters available if not self.account or not self.account.canUse(): return [] @@ -30,7 +29,7 @@ class PremiumizeMe(MultiHook): # Get supported hosters list from premiumize.me using the # json API v1 (see https://secure.premiumize.me/?show=api) - answer = getURL("https://api.premiumize.me/pm-api/v1.php", + answer = self.getURL("https://api.premiumize.me/pm-api/v1.php", get={'method': "hosterlist", 'params[login]': user, 'params[pass]': data['password']}) data = json_loads(answer) diff --git a/module/plugins/hooks/RPNetBiz.py b/module/plugins/hooks/RPNetBiz.py index c54f7d445..5af355fcc 100644 --- a/module/plugins/hooks/RPNetBiz.py +++ b/module/plugins/hooks/RPNetBiz.py @@ -1,18 +1,17 @@ # -*- coding: utf-8 -*- from module.common.json_layer import json_loads -from module.network.RequestFactory import getURL from module.plugins.internal.MultiHook import MultiHook class RPNetBiz(MultiHook): __name__ = "RPNetBiz" __type__ = "hook" - __version__ = "0.11" + __version__ = "0.12" - __config__ = [("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported):", "all"), - ("hosterList", "str", "Hoster list (comma separated)", ""), - ("unloadFailing", "bool", "Revert to stanard download if download fails", False), + __config__ = [("mode", "all;listed;unlisted", "Use for hosters (if supported):", "all"), + ("pluginlist", "str", "Hoster list (comma separated)", ""), + ("revertfailed", "bool", "Revert to stanard download if download fails", False), ("interval", "int", "Reload interval in hours (0 to disable)", 24)] __description__ = """RPNet.biz hook plugin""" @@ -20,7 +19,7 @@ class RPNetBiz(MultiHook): __authors__ = [("Dman", "dmanugm@gmail.com")] - def getHoster(self): + def getHosters(self): # No hosts supported if no account if not self.account or not self.account.canUse(): return [] @@ -28,7 +27,7 @@ class RPNetBiz(MultiHook): # Get account data (user, data) = self.account.selectAccount() - res = getURL("https://premium.rpnet.biz/client_api.php", + res = self.getURL("https://premium.rpnet.biz/client_api.php", get={'username': user, 'password': data['password'], 'action': "showHosterList"}) hoster_list = json_loads(res) diff --git a/module/plugins/hooks/RealdebridCom.py b/module/plugins/hooks/RealdebridCom.py index 066aa52c4..05a6df1dd 100644 --- a/module/plugins/hooks/RealdebridCom.py +++ b/module/plugins/hooks/RealdebridCom.py @@ -1,18 +1,17 @@ # -*- coding: utf-8 -*- -from module.network.RequestFactory import getURL from module.plugins.internal.MultiHook import MultiHook class RealdebridCom(MultiHook): __name__ = "RealdebridCom" __type__ = "hook" - __version__ = "0.44" + __version__ = "0.45" __config__ = [("https", "bool", "Enable HTTPS", False), - ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported):", "all"), - ("hosterList", "str", "Hoster list (comma separated)", ""), - ("unloadFailing", "bool", "Revert to stanard download if download fails", False), + ("mode", "all;listed;unlisted", "Use for hosters (if supported):", "all"), + ("pluginlist", "str", "Hoster list (comma separated)", ""), + ("revertfailed", "bool", "Revert to stanard download if download fails", False), ("interval", "int", "Reload interval in hours (0 to disable)", 24)] __description__ = """Real-Debrid.com hook plugin""" @@ -20,8 +19,8 @@ class RealdebridCom(MultiHook): __authors__ = [("Devirex Hazzard", "naibaf_11@yahoo.de")] - def getHoster(self): + def getHosters(self): https = "https" if self.getConfig("https") else "http" - page = getURL(https + "://real-debrid.com/api/hosters.php").replace("\"", "").strip() + page = self.getURL(https + "://real-debrid.com/api/hosters.php").replace("\"", "").strip() return [x.strip() for x in page.split(",") if x.strip()] diff --git a/module/plugins/hooks/RehostTo.py b/module/plugins/hooks/RehostTo.py index 48afa2342..207449e6a 100644 --- a/module/plugins/hooks/RehostTo.py +++ b/module/plugins/hooks/RehostTo.py @@ -1,17 +1,16 @@ # -*- coding: utf-8 -*- -from module.network.RequestFactory import getURL from module.plugins.internal.MultiHook import MultiHook class RehostTo(MultiHook): __name__ = "RehostTo" __type__ = "hook" - __version__ = "0.44" + __version__ = "0.45" - __config__ = [("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), - ("hosterList", "str", "Hoster list (comma separated)", ""), - ("unloadFailing", "bool", "Revert to stanard download if download fails", False), + __config__ = [("mode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), + ("pluginlist", "str", "Hoster list (comma separated)", ""), + ("revertfailed", "bool", "Revert to stanard download if download fails", False), ("interval", "int", "Reload interval in hours (0 to disable)", 24)] __description__ = """Rehost.to hook plugin""" @@ -19,8 +18,8 @@ class RehostTo(MultiHook): __authors__ = [("RaNaN", "RaNaN@pyload.org")] - def getHoster(self): - page = getURL("http://rehost.to/api.php", + def getHosters(self): + page = self.getURL("http://rehost.to/api.php", get={'cmd': "get_supported_och_dl", 'long_ses': self.long_ses}) return [x.strip() for x in page.replace("\"", "").split(",")] diff --git a/module/plugins/hooks/SimplyPremiumCom.py b/module/plugins/hooks/SimplyPremiumCom.py index 10a1655c2..5f2d2a42c 100644 --- a/module/plugins/hooks/SimplyPremiumCom.py +++ b/module/plugins/hooks/SimplyPremiumCom.py @@ -1,19 +1,18 @@ # -*- coding: utf-8 -*- from module.common.json_layer import json_loads -from module.network.RequestFactory import getURL from module.plugins.internal.MultiHook import MultiHook class SimplyPremiumCom(MultiHook): __name__ = "SimplyPremiumCom" __type__ = "hook" - __version__ = "0.03" + __version__ = "0.04" __config__ = [("activated", "bool", "Activated", "False"), - ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), - ("hosterList", "str", "Hoster list (comma separated)", ""), - ("unloadFailing", "bool", "Revert to standard download if download fails", "False"), + ("mode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), + ("pluginlist", "str", "Hoster list (comma separated)", ""), + ("revertfailed", "bool", "Revert to standard download if download fails", "False"), ("interval", "int", "Reload interval in hours (0 to disable)", "24")] __description__ = """Simply-Premium.com hook plugin""" @@ -21,8 +20,8 @@ class SimplyPremiumCom(MultiHook): __authors__ = [("EvolutionClip", "evolutionclip@live.de")] - def getHoster(self): - json_data = getURL("http://www.simply-premium.com/api/hosts.php", get={'format': "json", 'online': 1}) + def getHosters(self): + json_data = self.getURL("http://www.simply-premium.com/api/hosts.php", get={'format': "json", 'online': 1}) json_data = json_loads(json_data) host_list = [element['regex'] for element in json_data['result']] diff --git a/module/plugins/hooks/SimplydebridCom.py b/module/plugins/hooks/SimplydebridCom.py index 48568f870..13c957294 100644 --- a/module/plugins/hooks/SimplydebridCom.py +++ b/module/plugins/hooks/SimplydebridCom.py @@ -1,22 +1,21 @@ # -*- coding: utf-8 -*- -from module.network.RequestFactory import getURL from module.plugins.internal.MultiHook import MultiHook class SimplydebridCom(MultiHook): __name__ = "SimplydebridCom" __type__ = "hook" - __version__ = "0.02" + __version__ = "0.03" - __config__ = [("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), - ("hosterList", "str", "Hoster list (comma separated)", "")] + __config__ = [("mode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), + ("pluginlist", "str", "Hoster list (comma separated)", "")] __description__ = """Simply-Debrid.com hook plugin""" __license__ = "GPLv3" __authors__ = [("Kagenoshin", "kagenoshin@gmx.ch")] - def getHoster(self): - page = getURL("http://simply-debrid.com/api.php", get={'list': 1}) + def getHosters(self): + page = self.getURL("http://simply-debrid.com/api.php", get={'list': 1}) return [x.strip() for x in page.rstrip(';').replace("\"", "").split(";")] diff --git a/module/plugins/hooks/UnrestrictLi.py b/module/plugins/hooks/UnrestrictLi.py index 245264d44..e481e8449 100644 --- a/module/plugins/hooks/UnrestrictLi.py +++ b/module/plugins/hooks/UnrestrictLi.py @@ -1,18 +1,17 @@ # -*- coding: utf-8 -*- from module.common.json_layer import json_loads -from module.network.RequestFactory import getURL from module.plugins.internal.MultiHook import MultiHook class UnrestrictLi(MultiHook): __name__ = "UnrestrictLi" __type__ = "hook" - __version__ = "0.03" + __version__ = "0.04" - __config__ = [("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), - ("hosterList", "str", "Hoster list (comma separated)", ""), - ("unloadFailing", "bool", "Revert to standard download if download fails", False), + __config__ = [("mode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), + ("pluginlist", "str", "Hoster list (comma separated)", ""), + ("revertfailed", "bool", "Revert to standard download if download fails", False), ("interval", "int", "Reload interval in hours (0 to disable)", 24), ("history", "bool", "Delete History", False)] @@ -21,8 +20,8 @@ class UnrestrictLi(MultiHook): __authors__ = [("stickell", "l.stickell@yahoo.it")] - def getHoster(self): - json_data = getURL("http://unrestrict.li/api/jdownloader/hosts.php", get={'format': "json"}) + def getHosters(self): + json_data = self.getURL("http://unrestrict.li/api/jdownloader/hosts.php", get={'format': "json"}) json_data = json_loads(json_data) host_list = [element['host'] for element in json_data['result']] diff --git a/module/plugins/hooks/XFileSharingPro.py b/module/plugins/hooks/XFileSharingPro.py index 589143547..79e373ad3 100644 --- a/module/plugins/hooks/XFileSharingPro.py +++ b/module/plugins/hooks/XFileSharingPro.py @@ -28,16 +28,16 @@ class XFileSharingPro(Hook): 'crypter': (r'https?://(?:www\.)?([\w.^_]+(?:\.[a-zA-Z]{2,})(?:\:\d+)?)/(?:user|folder)s?/\w+', r'https?://(?:[^/]+\.)?(%s)/(?:user|folder)s?/\w+')} - HOSTER_LIST = [#WORKING HOSTERS: - "eyesfile.ca", "file4safe.com", "fileband.com", "filedwon.com", "filevice.com", "hostingbulk.com", - "ravishare.com", "salefiles.com", "sharesix.com", "thefile.me", "verzend.be", "xvidstage.com", - #NOT TESTED: - "101shared.com", "4upfiles.com", "filemaze.ws", "filenuke.com", "linkzhost.com", "mightyupload.com", - "rockdizfile.com", "sharebeast.com", "sharerepo.com", "shareswift.com", "uploadbaz.com", "uploadc.com", - "vidbull.com", "zalaa.com", "zomgupload.com", - #NOT WORKING: - "amonshare.com", "banicrazy.info", "boosterking.com", "host4desi.com", "laoupload.com", "rd-fs.com"] - CRYPTER_LIST = [] + HOSTER_BUILTIN = [#WORKING HOSTERS: + "eyesfile.ca", "file4safe.com", "fileband.com", "filedwon.com", "filevice.com", "hostingbulk.com", + "ravishare.com", "salefiles.com", "sharesix.com", "thefile.me", "verzend.be", "xvidstage.com", + #NOT TESTED: + "101shared.com", "4upfiles.com", "filemaze.ws", "filenuke.com", "linkzhost.com", "mightyupload.com", + "rockdizfile.com", "sharebeast.com", "sharerepo.com", "shareswift.com", "uploadbaz.com", "uploadc.com", + "vidbull.com", "zalaa.com", "zomgupload.com", + #NOT WORKING: + "amonshare.com", "banicrazy.info", "boosterking.com", "host4desi.com", "laoupload.com", "rd-fs.com"] + CRYPTER_BUILTIN = [] # def pluginConfigChanged(self.__name__, plugin, name, value): @@ -68,7 +68,7 @@ class XFileSharingPro(Hook): plugin_list = set([x.strip() for x in s.split(',')]) if use_builtin_list: - plugin_list |= set([x.lower() for x in getattr(self, "%s_LIST" % type.upper())]) + plugin_list |= set([x.lower() for x in getattr(self, "%s_BUILTIN" % type.upper())]) plugin_list -= set(('', u'')) diff --git a/module/plugins/hooks/ZeveraCom.py b/module/plugins/hooks/ZeveraCom.py index 6ca696f38..51f759b1c 100644 --- a/module/plugins/hooks/ZeveraCom.py +++ b/module/plugins/hooks/ZeveraCom.py @@ -1,22 +1,21 @@ # -*- coding: utf-8 -*- -from module.network.RequestFactory import getURL from module.plugins.internal.MultiHook import MultiHook class ZeveraCom(MultiHook): __name__ = "ZeveraCom" __type__ = "hook" - __version__ = "0.03" + __version__ = "0.04" - __config__ = [("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), - ("hosterList", "str", "Hoster list (comma separated)", "")] + __config__ = [("mode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), + ("pluginlist", "str", "Hoster list (comma separated)", "")] __description__ = """Real-Debrid.com hook plugin""" __license__ = "GPLv3" __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] - def getHoster(self): - page = getURL("http://www.zevera.com/jDownloader.ashx", get={'cmd': "gethosters"}) + def getHosters(self): + page = self.getURL("http://www.zevera.com/jDownloader.ashx", get={'cmd': "gethosters"}) return [x.strip() for x in page.replace("\"", "").split(",")] -- cgit v1.2.3 From c0a7430ef5218da41787de001de04d3ded89d8b5 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 27 Dec 2014 21:21:47 +0100 Subject: [LinkdecrypterCom] Extend MultiHook --- module/plugins/hooks/LinkdecrypterCom.py | 64 +++++++------------------------- 1 file changed, 13 insertions(+), 51 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/LinkdecrypterCom.py b/module/plugins/hooks/LinkdecrypterCom.py index b0ce335d0..8592efd3d 100644 --- a/module/plugins/hooks/LinkdecrypterCom.py +++ b/module/plugins/hooks/LinkdecrypterCom.py @@ -2,64 +2,26 @@ import re -from module.network.RequestFactory import getURL -from module.plugins.Hook import Hook -from module.utils import remove_chars +from module.plugins.internal.MultiHook import MultiHook -class LinkdecrypterCom(Hook): +class LinkdecrypterCom(MultiHook): __name__ = "LinkdecrypterCom" __type__ = "hook" - __version__ = "0.21" + __version__ = "1.00" + + __config__ = [("mode" , "all;listed;unlisted", "Use for crypters (if supported)" , "all"), + ("pluginlist" , "str" , "Crypter list (comma separated)" , "" ), + ("interval" , "int" , "Reload interval in hours (0 to disable)" , 12 )] __description__ = """Linkdecrypter.com hook plugin""" __license__ = "GPLv3" - __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] - + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - #@TODO: Remove in 0.4.10 - def initPeriodical(self): - pass - - def coreReady(self): + def getCrypters(self): try: - self.loadPatterns() - except Exception, e: - self.logError(e) - - - def loadPatterns(self): - html = getURL("http://linkdecrypter.com/") - - m = re.search(r'', html) - if m is None: - self.logError(_("Linkdecrypter site is down")) - return - - m = re.search(r'<b>Supported\(\d+\)</b>: <i>([^+<]*)', html) - if m is None: - self.logError(_("Crypter list not found")) - return - - builtin = [name.lower() for name in self.core.pluginManager.crypterPlugins.keys()] - builtin.append("downloadserienjunkiesorg") - - crypter_pattern = re.compile("(\w[\w.-]+)") - online = [] - for crypter in m.group(1).split(', '): - m = re.match(crypter_pattern, crypter) - if m and remove_chars(m.group(1), "-.") not in builtin: - online.append(m.group(1).replace(".", "\\.")) - - if not online: - self.logError(_("Crypter list is empty")) - return - - regexp = r'https?://([^.]+\.)*?(%s)/.*' % '|'.join(online) - - dict = self.core.pluginManager.crypterPlugins[self.__name__] - dict['pattern'] = regexp - dict['re'] = re.compile(regexp) - - self.logDebug("Loaded pattern: %s" % regexp) + html = self.getURL("http://linkdecrypter.com/") + return re.search(r'>Supported\(\d+\)</b>: <i>(.+?) \+ RSDF', html).group(1).split(', ') + except Exception: + return list() -- cgit v1.2.3 From 9410d10fd0491fcd1b5a073109085f16917ec2aa Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sat, 27 Dec 2014 21:23:59 +0100 Subject: [AlldebridCom] Bump up version --- module/plugins/hooks/AlldebridCom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/AlldebridCom.py b/module/plugins/hooks/AlldebridCom.py index 88a637de7..cd279e733 100644 --- a/module/plugins/hooks/AlldebridCom.py +++ b/module/plugins/hooks/AlldebridCom.py @@ -6,7 +6,7 @@ from module.plugins.internal.MultiHook import MultiHook class AlldebridCom(MultiHook): __name__ = "AlldebridCom" __type__ = "hook" - __version__ = "0.14" + __version__ = "0.15" __config__ = [("https", "bool", "Enable HTTPS", False), ("mode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), -- cgit v1.2.3 From b9c2bcfc1862b4bef6feff224603420ab2eed6d9 Mon Sep 17 00:00:00 2001 From: synweap15 <shamdog+github@gmail.com> Date: Tue, 30 Dec 2014 21:25:24 +0100 Subject: fix MultiHoster to MultiHook transition --- module/plugins/hooks/NoPremiumPl.py | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/NoPremiumPl.py b/module/plugins/hooks/NoPremiumPl.py index 84a019b8d..7742e03f7 100644 --- a/module/plugins/hooks/NoPremiumPl.py +++ b/module/plugins/hooks/NoPremiumPl.py @@ -1,31 +1,28 @@ # -*- coding: utf-8 -*- -from module.plugins.internal.MultiHoster import MultiHoster -from module.network.RequestFactory import getURL +from module.plugins.internal.MultiHook import MultiHook from module.common.json_layer import json_loads as loads -class NoPremiumPl(MultiHoster): +class NoPremiumPl(MultiHook): __name__ = "NoPremiumPl" __version__ = "0.01" __type__ = "hook" - __config__ = [("activated", "bool", "Activated", "False"), + __config__ = [("activated", "bool", "Activated", False), ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported):", "all"), ("hosterList", "str", "Hoster list (comma separated)", ""), - ("unloadFailing", "bool", "Try standard download if download fails", "False"), - ("interval", "int", "Reload supported hosts interval in hours (0 to disable)", "24")] + ("unloadFailing", "bool", "Try standard download if download fails", False), + ("interval", "int", "Reload supported hosts interval in hours (0 to disable)", 24)] __description__ = "NoPremium.pl hook" __license__ = "GPLv3" __authors__ = [("goddie", "dev@nopremium.pl")] - def getHoster(self): - hostings = loads(getURL("https://www.nopremium.pl/clipboard.php?json=3").strip()) - - return [domain for row in hostings for domain in row["domains"] if row["sdownload"] == "0"] - - def getHosterCached(self): - return self.getHoster() + def getHosters(self): + hostings = loads(self.getURL("https://www.nopremium.pl/clipboard.php?json=3").strip()) + hostings_domains = [domain for row in hostings for domain in row["domains"] if row["sdownload"] == "0"] + self.logDebug(hostings_domains) + return hostings_domains -- cgit v1.2.3 From 2a6404851c5ce4e9421b183805fd3c55cd5641f3 Mon Sep 17 00:00:00 2001 From: synweap15 <shamdog+github@gmail.com> Date: Tue, 30 Dec 2014 21:28:40 +0100 Subject: version bump --- module/plugins/hooks/NoPremiumPl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/NoPremiumPl.py b/module/plugins/hooks/NoPremiumPl.py index 7742e03f7..2347fc58a 100644 --- a/module/plugins/hooks/NoPremiumPl.py +++ b/module/plugins/hooks/NoPremiumPl.py @@ -6,7 +6,7 @@ from module.common.json_layer import json_loads as loads class NoPremiumPl(MultiHook): __name__ = "NoPremiumPl" - __version__ = "0.01" + __version__ = "0.02" __type__ = "hook" __config__ = [("activated", "bool", "Activated", False), -- cgit v1.2.3 From 90383d08cfc77253a645f10e56dd3ac322cb8507 Mon Sep 17 00:00:00 2001 From: synweap15 <shamdog+github@gmail.com> Date: Tue, 30 Dec 2014 21:37:20 +0100 Subject: transition to multihook fix --- module/plugins/hooks/RapideoPl.py | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/RapideoPl.py b/module/plugins/hooks/RapideoPl.py index a5d7a34a5..9eb454897 100644 --- a/module/plugins/hooks/RapideoPl.py +++ b/module/plugins/hooks/RapideoPl.py @@ -1,31 +1,28 @@ # -*- coding: utf-8 -*- -from module.plugins.internal.MultiHoster import MultiHoster -from module.network.RequestFactory import getURL +from module.plugins.internal.MultiHook import MultiHook from module.common.json_layer import json_loads as loads -class RapideoPl(MultiHoster): +class RapideoPl(MultiHook): __name__ = "RapideoPl" - __version__ = "0.01" + __version__ = "0.02" __type__ = "hook" - __config__ = [("activated", "bool", "Activated", "False"), + __config__ = [("activated", "bool", "Activated", False), ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported):", "all"), ("hosterList", "str", "Hoster list (comma separated)", ""), - ("unloadFailing", "bool", "Try standard download if download fails", "False"), - ("interval", "int", "Reload supported hosts interval in hours (0 to disable)", "24")] + ("unloadFailing", "bool", "Try standard download if download fails", False), + ("interval", "int", "Reload supported hosts interval in hours (0 to disable)", 24)] __description__ = "Rapideo.pl hook" __license__ = "GPLv3" __authors__ = [("goddie", "dev@rapideo.pl")] - def getHoster(self): - hostings = loads(getURL("https://www.rapideo.pl/clipboard.php?json=3").strip()) - - return [domain for row in hostings for domain in row["domains"] if row["sdownload"] == "0"] - - def getHosterCached(self): - return self.getHoster() + def getHosters(self): + hostings = loads(self.getURL("https://www.rapideo.pl/clipboard.php?json=3").strip()) + hostings_domains = [domain for row in hostings for domain in row["domains"] if row["sdownload"] == "0"] + self.logDebug(hostings_domains) + return hostings_domains -- cgit v1.2.3 From be51f9235eb555be07b9d5cc0a34c73b75ac0cfe Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Wed, 31 Dec 2014 00:05:39 +0100 Subject: Handle methods get pyfile argument --- module/plugins/hooks/CaptchaBrotherhood.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/CaptchaBrotherhood.py b/module/plugins/hooks/CaptchaBrotherhood.py index b6e38d8bb..6d4127871 100644 --- a/module/plugins/hooks/CaptchaBrotherhood.py +++ b/module/plugins/hooks/CaptchaBrotherhood.py @@ -94,10 +94,10 @@ class CaptchaBrotherhood(Hook): req = getRequest() url = "%ssendNewCaptcha.aspx?%s" % (self.API_URL, - urlencode({"username": self.getConfig("username"), - "password": self.getConfig("passkey"), - "captchaSource": "pyLoad", - "timeout": "80"})) + urlencode({'username' : self.getConfig("username"), + 'password' : self.getConfig("passkey"), + 'captchaSource': "pyLoad", + 'timeout' : "80"})) req.c.setopt(pycurl.URL, url) req.c.setopt(pycurl.POST, 1) -- cgit v1.2.3 From 8b50b2a435d20fd7e1211cdd8c651838993efff1 Mon Sep 17 00:00:00 2001 From: Lukas Kalbertodt <lukas.kalbertodt@gmail.com> Date: Wed, 31 Dec 2014 01:24:13 +0100 Subject: Update RealdebridCom.py --- module/plugins/hooks/RealdebridCom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/RealdebridCom.py b/module/plugins/hooks/RealdebridCom.py index 05a6df1dd..bac18e6c3 100644 --- a/module/plugins/hooks/RealdebridCom.py +++ b/module/plugins/hooks/RealdebridCom.py @@ -11,7 +11,7 @@ class RealdebridCom(MultiHook): __config__ = [("https", "bool", "Enable HTTPS", False), ("mode", "all;listed;unlisted", "Use for hosters (if supported):", "all"), ("pluginlist", "str", "Hoster list (comma separated)", ""), - ("revertfailed", "bool", "Revert to stanard download if download fails", False), + ("revertfailed", "bool", "Revert to standard download if download fails", False), ("interval", "int", "Reload interval in hours (0 to disable)", 24)] __description__ = """Real-Debrid.com hook plugin""" -- cgit v1.2.3 From 08f9ab64b9e2f2b7f4c41cc1629a96af7febb740 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Wed, 31 Dec 2014 02:33:33 +0100 Subject: Tiny code cosmetics --- module/plugins/hooks/AlldebridCom.py | 2 +- module/plugins/hooks/FreeWayMe.py | 2 +- module/plugins/hooks/PremiumizeMe.py | 2 +- module/plugins/hooks/RPNetBiz.py | 2 +- module/plugins/hooks/RehostTo.py | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/AlldebridCom.py b/module/plugins/hooks/AlldebridCom.py index cd279e733..e1f63c31b 100644 --- a/module/plugins/hooks/AlldebridCom.py +++ b/module/plugins/hooks/AlldebridCom.py @@ -11,7 +11,7 @@ class AlldebridCom(MultiHook): __config__ = [("https", "bool", "Enable HTTPS", False), ("mode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), ("pluginlist", "str", "Hoster list (comma separated)", ""), - ("revertfailed", "bool", "Revert to stanard download if download fails", False), + ("revertfailed", "bool", "Revert to standard download if download fails", False), ("interval", "int", "Reload interval in hours (0 to disable)", 24)] __description__ = """Alldebrid.com hook plugin""" diff --git a/module/plugins/hooks/FreeWayMe.py b/module/plugins/hooks/FreeWayMe.py index f2a4f2d34..6cbea3417 100644 --- a/module/plugins/hooks/FreeWayMe.py +++ b/module/plugins/hooks/FreeWayMe.py @@ -10,7 +10,7 @@ class FreeWayMe(MultiHook): __config__ = [("mode", "all;listed;unlisted", "Use for hosters (if supported):", "all"), ("pluginlist", "str", "Hoster list (comma separated)", ""), - ("revertfailed", "bool", "Revert to stanard download if download fails", False), + ("revertfailed", "bool", "Revert to standard download if download fails", False), ("interval", "int", "Reload interval in hours (0 to disable)", 24)] __description__ = """FreeWay.me hook plugin""" diff --git a/module/plugins/hooks/PremiumizeMe.py b/module/plugins/hooks/PremiumizeMe.py index e23f13895..c0717afc7 100644 --- a/module/plugins/hooks/PremiumizeMe.py +++ b/module/plugins/hooks/PremiumizeMe.py @@ -11,7 +11,7 @@ class PremiumizeMe(MultiHook): __config__ = [("mode", "all;listed;unlisted", "Use for hosters (if supported):", "all"), ("pluginlist", "str", "Hoster list (comma separated)", ""), - ("revertfailed", "bool", "Revert to stanard download if download fails", False), + ("revertfailed", "bool", "Revert to standard download if download fails", False), ("interval", "int", "Reload interval in hours (0 to disable)", 24)] __description__ = """Premiumize.me hook plugin""" diff --git a/module/plugins/hooks/RPNetBiz.py b/module/plugins/hooks/RPNetBiz.py index 5af355fcc..bbbe8e128 100644 --- a/module/plugins/hooks/RPNetBiz.py +++ b/module/plugins/hooks/RPNetBiz.py @@ -11,7 +11,7 @@ class RPNetBiz(MultiHook): __config__ = [("mode", "all;listed;unlisted", "Use for hosters (if supported):", "all"), ("pluginlist", "str", "Hoster list (comma separated)", ""), - ("revertfailed", "bool", "Revert to stanard download if download fails", False), + ("revertfailed", "bool", "Revert to standard download if download fails", False), ("interval", "int", "Reload interval in hours (0 to disable)", 24)] __description__ = """RPNet.biz hook plugin""" diff --git a/module/plugins/hooks/RehostTo.py b/module/plugins/hooks/RehostTo.py index 207449e6a..c3b626bf7 100644 --- a/module/plugins/hooks/RehostTo.py +++ b/module/plugins/hooks/RehostTo.py @@ -10,7 +10,7 @@ class RehostTo(MultiHook): __config__ = [("mode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), ("pluginlist", "str", "Hoster list (comma separated)", ""), - ("revertfailed", "bool", "Revert to stanard download if download fails", False), + ("revertfailed", "bool", "Revert to standard download if download fails", False), ("interval", "int", "Reload interval in hours (0 to disable)", 24)] __description__ = """Rehost.to hook plugin""" -- cgit v1.2.3 From d5ad6ab1c1b8b088e7a4083b1fb7bab72d5679c3 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Wed, 31 Dec 2014 18:44:38 +0100 Subject: [ExtractArchive] Fix https://github.com/pyload/pyload/issues/778 --- module/plugins/hooks/ExtractArchive.py | 50 ++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 15 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index af78ffc93..73d8bdb0b 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -58,7 +58,7 @@ from module.utils import save_join, uniqify class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.02" + __version__ = "1.03" __config__ = [("activated" , "bool" , "Activated" , True ), ("fullpath" , "bool" , "Extract full path" , True ), @@ -72,7 +72,7 @@ class ExtractArchive(Hook): ("extensions" , "str" , "Extract the following extensions" , "7z,bz2,bzip2,gz,gzip,lha,lzh,lzma,rar,tar,taz,tbz,tbz2,tgz,xar,xz,z,zip"), ("excludefiles" , "str" , "Don't extract the following files" , "*.nfo,*.DS_Store,index.dat,thumb.db" ), ("recursive" , "bool" , "Extract archives in archives" , True ), - ("queue" , "bool" , "Wait for all downloads to be finished" , True ), + ("queue" , "bool" , "Wait for all downloads to be finished" , False ), ("renice" , "int" , "CPU Priority" , 0 )] __description__ = """Extract different kind of archives""" @@ -88,6 +88,10 @@ class ExtractArchive(Hook): pass + def coreReady(self): + self.extracting = False + + def setup(self): self.plugins = [] self.passwords = [] @@ -123,34 +127,50 @@ class ExtractArchive(Hook): self.queue = [] + def periodical(self): + if not self.queue or self.extracting: + return + + local = copy(self.queue) + self.queue[:] = [] + + self.extractPackages(*local) + + @Expose def extractPackage(self, id): - """ Extract package with given id""" - self.manager.startThread(self.extract, [id]) + """ Extract package wrapper""" + self.extractPackages(id) + + + @Expose + def extractPackages(self, *ids): + """ Extract packages with given id""" + self.manager.startThread(self.extract, ids) def packageFinished(self, pypack): - pid = pypack.id - if self.getConfig("queue"): + if self.getConfig("queue") or self.extracting: self.logInfo(_("Package %s queued for later extracting") % pypack.name) - self.queue.append(pid) + self.queue.append(pypack.id) else: - self.extractPackage(pid) + self.extractPackage(pypack.id) @threaded def allDownloadsProcessed(self, thread): local = copy(self.queue) + self.queue[:] = [] - del self.queue[:] - - if self.extract(local, thread): #: check only if all gone fine, no failed reporting for now + if self.extract(local): #: check only if all gone fine, no failed reporting for now self.manager.dispatchEvent("all_archives_extracted") self.manager.dispatchEvent("all_archives_processed") - def extract(self, ids, thread=None): + def extract(self, ids): + self.extracting = True + processed = [] extracted = [] failed = [] @@ -232,7 +252,7 @@ class ExtractArchive(Hook): keepbroken) klass.init() - new_files = self._extract(klass, fid, thread) + new_files = self._extract(klass, fid) except Exception, e: self.logError(basename(target), e) @@ -271,14 +291,14 @@ class ExtractArchive(Hook): except OSError: pass + self.extracting = False return True if not failed else False - def _extract(self, plugin, fid, thread): + def _extract(self, plugin, fid): pyfile = self.core.files.getFile(fid) pyfile.setCustomStatus(_("extracting")) - thread.addActive(pyfile) # keep this file until everything is done try: progress = lambda x: pyfile.setProgress(x) -- cgit v1.2.3 From 60e9c46f32d97d01d728c8515985b58ba33fdafd Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Thu, 1 Jan 2015 01:48:37 +0100 Subject: [SimpleHoster] Fix https://github.com/pyload/pyload/issues/997 --- module/plugins/hooks/ExtractArchive.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 73d8bdb0b..2e9efa2b0 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -189,7 +189,7 @@ class ExtractArchive(Hook): keepbroken = self.getConfig("keepbroken") if extensions: - self.logDebug("Extensions allowed: %s" % "|.".join(extensions)) + self.logDebug("Extensions: %s" % "|.".join(extensions)) # reload from txt file self.reloadPasswords() -- cgit v1.2.3 From e0cba81ae8d59ee24e1cd1f1cf1697c5e61118ce Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Fri, 2 Jan 2015 02:37:18 +0100 Subject: [PremiumTo] Fixup --- module/plugins/hooks/PremiumTo.py | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/PremiumTo.py b/module/plugins/hooks/PremiumTo.py index 348bb6789..a4203c8bb 100644 --- a/module/plugins/hooks/PremiumTo.py +++ b/module/plugins/hooks/PremiumTo.py @@ -6,7 +6,7 @@ from module.plugins.internal.MultiHook import MultiHook class PremiumTo(MultiHook): __name__ = "PremiumTo" __type__ = "hook" - __version__ = "0.06" + __version__ = "0.07" __config__ = [("mode", "all;listed;unlisted", "Use for downloads from supported hosters:", "all"), ("pluginlist", "str", "Hoster list (comma separated)", "")] @@ -22,15 +22,3 @@ class PremiumTo(MultiHook): page = self.getURL("http://premium.to/api/hosters.php", 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") - - user = self.account.selectAccount()[0] - - if not user: - self.logError(_("Please add your premium.to account first and restart pyLoad")) - return - - return MultiHook.coreReady(self) -- cgit v1.2.3 From 354ecbc78898efb4a31a7272e5ea1f5e00a53327 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sun, 4 Jan 2015 19:52:02 +0100 Subject: [ClickAndLoad] Updated --- module/plugins/hooks/ClickAndLoad.py | 104 ++++++++++++++++++----------------- 1 file changed, 54 insertions(+), 50 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 04aac2f10..8ef31ec1e 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -1,41 +1,10 @@ # -*- coding: utf-8 -*- import socket -import thread - -from module.plugins.Hook import Hook - - -def proxy(self, *settings): - thread.start_new_thread(server, (self,) + settings) - lock = thread.allocate_lock() - lock.acquire() - lock.acquire() - - -def server(self, *settings): - try: - dock_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - dock_socket.bind((settings[0], settings[2])) - dock_socket.listen(5) - while True: - client_socket = dock_socket.accept()[0] - server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - server_socket.connect(("127.0.0.1", settings[1])) - thread.start_new_thread(forward, (client_socket, server_socket)) - thread.start_new_thread(forward, (server_socket, client_socket)) - except socket.error, e: - if hasattr(e, "errno"): - errno = e.errno - else: - errno = e.args[0] - if errno == 98: - self.logWarning(_("Click'N'Load: Port 9666 already in use")) - return - thread.start_new_thread(server, (self,) + settings) - except: - thread.start_new_thread(server, (self,) + settings) +from threading import Thread, Lock + +from module.plugins.Hook import Hook, threaded def forward(source, destination): @@ -45,33 +14,68 @@ def forward(source, destination): if string: destination.sendall(string) else: - #source.shutdown(socket.SHUT_RD) destination.shutdown(socket.SHUT_WR) class ClickAndLoad(Hook): __name__ = "ClickAndLoad" __type__ = "hook" - __version__ = "0.24" + __version__ = "0.25" - __config__ = [("activated", "bool", "Activated", True), - ("extern", "bool", "Allow external link adding", False)] + __config__ = [("activated", "bool", "Activated" , True ), + ("port" , "int" , "Port" , 9666 ), + ("extern" , "bool", "Listen for requests coming from WAN (internet)", False)] __description__ = """Click'N'Load hook plugin""" __license__ = "GPLv3" __authors__ = [("RaNaN", "RaNaN@pyload.de"), - ("mkaay", "mkaay@mkaay.de")] + ("Walter Purcaro", "vuolter@gmail.com")] def coreReady(self): - self.port = int(self.config['webinterface']['port']) - if self.config['webinterface']['activated']: - try: - if self.getConfig("extern"): - ip = "0.0.0.0" - else: - ip = "127.0.0.1" - - thread.start_new_thread(proxy, (self, ip, self.port, 9666)) - except: - self.logError(_("ClickAndLoad port already in use")) + if not self.config['webinterface']['activated']: + return + + ip = "0.0.0.0" if self.getConfig("extern") else "127.0.0.1" + webport = int(self.config['webinterface']['port']) + cnlport = self.getConfig('port') + + self.proxy(ip, webport, cnlport) + + + @threaded + def proxy(self, ip, webport, cnlport): + hookManager.startThread(self.server, ip, webport, cnlport) + lock = Lock() + lock.acquire() + lock.acquire() + + + def server(self, ip, webport, cnlport): + try: + dock_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + dock_socket.bind((ip, cnlport)) + dock_socket.listen(5) + + while True: + server_socket = dock_socket.accept()[0] + client_socket = socket.create_connection(("127.0.0.1", webport)) + + hookManager.startThread(forward, server_socket, client_socket) + hookManager.startThread(forward, client_socket, server_socket) + + except socket.error, e: + if hasattr(e, "errno"): + errno = e.errno + else: + errno = e.args[0] + + if errno == 98: + self.logWarning(_("Port %s already in use") % cnlport) + else: + self.logError(e) + self.server(ip, webport, cnlport) + + except Exception, e: + self.logError(e) + self.server(ip, webport, cnlport) -- cgit v1.2.3 From 80ecab8f0c664bc43b9db10bee0cb815a96c1039 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sun, 4 Jan 2015 20:20:34 +0100 Subject: Improve processCaptcha thread in hook plugins --- module/plugins/hooks/BypassCaptcha.py | 10 +++++----- module/plugins/hooks/Captcha9kw.py | 6 +++--- module/plugins/hooks/CaptchaBrotherhood.py | 10 +++++----- module/plugins/hooks/DeathByCaptcha.py | 10 +++++----- module/plugins/hooks/ExpertDecoders.py | 10 +++++----- module/plugins/hooks/ImageTyperz.py | 10 +++++----- 6 files changed, 28 insertions(+), 28 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/BypassCaptcha.py b/module/plugins/hooks/BypassCaptcha.py index a32de7f42..8e0d9d36e 100644 --- a/module/plugins/hooks/BypassCaptcha.py +++ b/module/plugins/hooks/BypassCaptcha.py @@ -1,11 +1,10 @@ # -*- coding: utf-8 -*- from pycurl import FORM_FILE, LOW_SPEED_TIME -from thread import start_new_thread from module.network.HTTPRequest import BadHeader from module.network.RequestFactory import getURL, getRequest -from module.plugins.Hook import Hook +from module.plugins.Hook import Hook, threaded class BypassCaptchaException(Exception): @@ -29,7 +28,7 @@ class BypassCaptchaException(Exception): class BypassCaptcha(Hook): __name__ = "BypassCaptcha" __type__ = "hook" - __version__ = "0.05" + __version__ = "0.06" __config__ = [("force", "bool", "Force BC even if client is connected", False), ("passkey", "password", "Passkey", "")] @@ -116,7 +115,7 @@ class BypassCaptcha(Hook): task.handler.append(self) task.data['service'] = self.__name__ task.setWaiting(100) - start_new_thread(self.processCaptcha, (task,)) + self._processCaptcha(task) else: self.logInfo(_("Your %s account has not enough credits") % self.__name__) @@ -132,7 +131,8 @@ class BypassCaptcha(Hook): self.respond(task.data['ticket'], False) - def processCaptcha(self, task): + @threaded + def _processCaptcha(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 33ad00c49..6eb4ef305 100755 --- a/module/plugins/hooks/Captcha9kw.py +++ b/module/plugins/hooks/Captcha9kw.py @@ -5,19 +5,18 @@ from __future__ import with_statement import re from base64 import b64encode -from thread import start_new_thread from time import sleep from module.network.HTTPRequest import BadHeader from module.network.RequestFactory import getURL -from module.plugins.Hook import Hook +from module.plugins.Hook import Hook, threaded class Captcha9kw(Hook): __name__ = "Captcha9kw" __type__ = "hook" - __version__ = "0.26" + __version__ = "0.27" __config__ = [("activated" , "bool" , "Activated" , True ), ("ssl" , "bool" , "Use HTTPS" , True ), @@ -68,6 +67,7 @@ class Captcha9kw(Hook): return 0 + @threaded def _processCaptcha(self, task): try: with open(task.captchaFile, 'rb') as f: diff --git a/module/plugins/hooks/CaptchaBrotherhood.py b/module/plugins/hooks/CaptchaBrotherhood.py index 6d4127871..9a9f05b29 100644 --- a/module/plugins/hooks/CaptchaBrotherhood.py +++ b/module/plugins/hooks/CaptchaBrotherhood.py @@ -10,12 +10,11 @@ try: except ImportError: import Image -from thread import start_new_thread from time import sleep from urllib import urlencode from module.network.RequestFactory import getURL, getRequest -from module.plugins.Hook import Hook +from module.plugins.Hook import Hook, threaded class CaptchaBrotherhoodException(Exception): @@ -39,7 +38,7 @@ class CaptchaBrotherhoodException(Exception): class CaptchaBrotherhood(Hook): __name__ = "CaptchaBrotherhood" __type__ = "hook" - __version__ = "0.06" + __version__ = "0.07" __config__ = [("username", "str", "Username", ""), ("force", "bool", "Force CT even if client is connected", False), @@ -154,7 +153,7 @@ class CaptchaBrotherhood(Hook): task.handler.append(self) task.data['service'] = self.__name__ task.setWaiting(100) - start_new_thread(self.processCaptcha, (task,)) + self._processCaptcha(task) else: self.logInfo(_("Your CaptchaBrotherhood Account has not enough credits")) @@ -164,7 +163,8 @@ class CaptchaBrotherhood(Hook): res = self.get_api("complainCaptcha", task.data['ticket']) - def processCaptcha(self, task): + @threaded + def _processCaptcha(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 f03ac4567..98412c218 100644 --- a/module/plugins/hooks/DeathByCaptcha.py +++ b/module/plugins/hooks/DeathByCaptcha.py @@ -6,13 +6,12 @@ import re from base64 import b64encode from pycurl import FORM_FILE, HTTPHEADER -from thread import start_new_thread from time import sleep from module.common.json_layer import json_loads from module.network.HTTPRequest import BadHeader from module.network.RequestFactory import getRequest -from module.plugins.Hook import Hook +from module.plugins.Hook import Hook, threaded class DeathByCaptchaException(Exception): @@ -52,7 +51,7 @@ class DeathByCaptchaException(Exception): class DeathByCaptcha(Hook): __name__ = "DeathByCaptcha" __type__ = "hook" - __version__ = "0.04" + __version__ = "0.05" __config__ = [("username", "str", "Username", ""), ("passkey", "password", "Password", ""), @@ -195,7 +194,7 @@ class DeathByCaptcha(Hook): task.handler.append(self) task.data['service'] = self.__name__ task.setWaiting(180) - start_new_thread(self.processCaptcha, (task,)) + self._processCaptcha(task) def captchaInvalid(self, task): @@ -210,7 +209,8 @@ class DeathByCaptcha(Hook): self.logError(e) - def processCaptcha(self, task): + @threaded + def _processCaptcha(self, task): c = task.captchaFile try: ticket, result = self.submit(c) diff --git a/module/plugins/hooks/ExpertDecoders.py b/module/plugins/hooks/ExpertDecoders.py index 54de8eb53..c80401003 100644 --- a/module/plugins/hooks/ExpertDecoders.py +++ b/module/plugins/hooks/ExpertDecoders.py @@ -4,18 +4,17 @@ from __future__ import with_statement from base64 import b64encode from pycurl import LOW_SPEED_TIME -from thread import start_new_thread from uuid import uuid4 from module.network.HTTPRequest import BadHeader from module.network.RequestFactory import getURL, getRequest -from module.plugins.Hook import Hook +from module.plugins.Hook import Hook, threaded class ExpertDecoders(Hook): __name__ = "ExpertDecoders" __type__ = "hook" - __version__ = "0.03" + __version__ = "0.04" __config__ = [("force", "bool", "Force CT even if client is connected", False), ("passkey", "password", "Access key", "")] @@ -50,7 +49,8 @@ class ExpertDecoders(Hook): return 0 - def processCaptcha(self, task): + @threaded + def _processCaptcha(self, task): task.data['ticket'] = ticket = uuid4() result = None @@ -85,7 +85,7 @@ class ExpertDecoders(Hook): if self.getCredits() > 0: task.handler.append(self) task.setWaiting(100) - start_new_thread(self.processCaptcha, (task,)) + self._processCaptcha(task) else: self.logInfo(_("Your ExpertDecoders Account has not enough credits")) diff --git a/module/plugins/hooks/ImageTyperz.py b/module/plugins/hooks/ImageTyperz.py index f89d64c37..d448d1be9 100644 --- a/module/plugins/hooks/ImageTyperz.py +++ b/module/plugins/hooks/ImageTyperz.py @@ -6,10 +6,9 @@ import re from base64 import b64encode from pycurl import FORM_FILE, LOW_SPEED_TIME -from thread import start_new_thread from module.network.RequestFactory import getURL, getRequest -from module.plugins.Hook import Hook +from module.plugins.Hook import Hook, threaded class ImageTyperzException(Exception): @@ -33,7 +32,7 @@ class ImageTyperzException(Exception): class ImageTyperz(Hook): __name__ = "ImageTyperz" __type__ = "hook" - __version__ = "0.05" + __version__ = "0.06" __config__ = [("username", "str", "Username", ""), ("passkey", "password", "Password", ""), @@ -130,7 +129,7 @@ class ImageTyperz(Hook): task.handler.append(self) task.data['service'] = self.__name__ task.setWaiting(100) - start_new_thread(self.processCaptcha, (task,)) + self._processCaptcha(task) else: self.logInfo(_("Your %s account has not enough credits") % self.__name__) @@ -150,7 +149,8 @@ class ImageTyperz(Hook): self.logError(_("Bad captcha solution received, refund request failed"), res) - def processCaptcha(self, task): + @threaded + def _processCaptcha(self, task): c = task.captchaFile try: ticket, result = self.submit(c) -- cgit v1.2.3 From 7979d0833573a107baae8c45330b8b5874630a76 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sun, 4 Jan 2015 20:26:13 +0100 Subject: Spare code improvements --- module/plugins/hooks/EasybytezCom.py | 5 ++--- module/plugins/hooks/PremiumizeMe.py | 20 ++------------------ module/plugins/hooks/RPNetBiz.py | 20 ++------------------ module/plugins/hooks/RehostTo.py | 15 ++++----------- 4 files changed, 10 insertions(+), 50 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/EasybytezCom.py b/module/plugins/hooks/EasybytezCom.py index 16149580c..1606c9f30 100644 --- a/module/plugins/hooks/EasybytezCom.py +++ b/module/plugins/hooks/EasybytezCom.py @@ -8,7 +8,7 @@ from module.plugins.internal.MultiHook import MultiHook class EasybytezCom(MultiHook): __name__ = "EasybytezCom" __type__ = "hook" - __version__ = "0.05" + __version__ = "0.06" __config__ = [("mode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), ("pluginlist", "str", "Hoster list (comma separated)", "")] @@ -19,8 +19,7 @@ class EasybytezCom(MultiHook): def getHosters(self): - self.account = self.core.accountManager.getAccountPlugin(self.__name__) - user = self.account.selectAccount()[0] + user, data = self.account.selectAccount() try: req = self.account.getAccountRequest(user) diff --git a/module/plugins/hooks/PremiumizeMe.py b/module/plugins/hooks/PremiumizeMe.py index c0717afc7..d334ddd25 100644 --- a/module/plugins/hooks/PremiumizeMe.py +++ b/module/plugins/hooks/PremiumizeMe.py @@ -7,7 +7,7 @@ from module.plugins.internal.MultiHook import MultiHook class PremiumizeMe(MultiHook): __name__ = "PremiumizeMe" __type__ = "hook" - __version__ = "0.15" + __version__ = "0.16" __config__ = [("mode", "all;listed;unlisted", "Use for hosters (if supported):", "all"), ("pluginlist", "str", "Hoster list (comma separated)", ""), @@ -20,12 +20,8 @@ class PremiumizeMe(MultiHook): def getHosters(self): - # If no accounts are available there will be no hosters available - if not self.account or not self.account.canUse(): - return [] - # Get account data - (user, data) = self.account.selectAccount() + user, data = self.account.selectAccount() # Get supported hosters list from premiumize.me using the # json API v1 (see https://secure.premiumize.me/?show=api) @@ -39,15 +35,3 @@ class PremiumizeMe(MultiHook): # 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") - if not self.account.canUse(): - self.account = None - self.logError(_("Please add a valid premiumize.me account first and restart pyLoad")) - return - - # Run the overwriten core ready which actually enables the multihoster hook - return MultiHook.coreReady(self) diff --git a/module/plugins/hooks/RPNetBiz.py b/module/plugins/hooks/RPNetBiz.py index bbbe8e128..9c88e6c01 100644 --- a/module/plugins/hooks/RPNetBiz.py +++ b/module/plugins/hooks/RPNetBiz.py @@ -7,7 +7,7 @@ from module.plugins.internal.MultiHook import MultiHook class RPNetBiz(MultiHook): __name__ = "RPNetBiz" __type__ = "hook" - __version__ = "0.12" + __version__ = "0.13" __config__ = [("mode", "all;listed;unlisted", "Use for hosters (if supported):", "all"), ("pluginlist", "str", "Hoster list (comma separated)", ""), @@ -20,12 +20,8 @@ class RPNetBiz(MultiHook): def getHosters(self): - # No hosts supported if no account - if not self.account or not self.account.canUse(): - return [] - # Get account data - (user, data) = self.account.selectAccount() + user, data = self.account.selectAccount() res = self.getURL("https://premium.rpnet.biz/client_api.php", get={'username': user, 'password': data['password'], 'action': "showHosterList"}) @@ -37,15 +33,3 @@ class RPNetBiz(MultiHook): # 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") - if not self.account.canUse(): - self.account = None - self.logError(_("Please enter your %s account or deactivate this plugin") % "rpnet") - return - - # Run the overwriten core ready which actually enables the multihoster hook - return MultiHook.coreReady(self) diff --git a/module/plugins/hooks/RehostTo.py b/module/plugins/hooks/RehostTo.py index c3b626bf7..527770eb6 100644 --- a/module/plugins/hooks/RehostTo.py +++ b/module/plugins/hooks/RehostTo.py @@ -6,7 +6,7 @@ from module.plugins.internal.MultiHook import MultiHook class RehostTo(MultiHook): __name__ = "RehostTo" __type__ = "hook" - __version__ = "0.45" + __version__ = "0.46" __config__ = [("mode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), ("pluginlist", "str", "Hoster list (comma separated)", ""), @@ -25,16 +25,9 @@ class RehostTo(MultiHook): def coreReady(self): - self.account = self.core.accountManager.getAccountPlugin("RehostTo") + super(RehostTo, self).coreReady() - user = self.account.selectAccount()[0] + user, data = self.account.selectAccount() - if not user: - self.logError(_("Please add your rehost.to account first and restart pyLoad")) - return - - data = self.account.getAccountInfo(user) - self.ses = data['ses'] + self.ses = data['ses'] self.long_ses = data['long_ses'] - - return MultiHook.coreReady(self) -- cgit v1.2.3 From 75b6540be746d66d3fba3ab364c78addbc50c485 Mon Sep 17 00:00:00 2001 From: Smoozed <github@smoozed.com> Date: Mon, 5 Jan 2015 16:49:39 +0100 Subject: Added multihoster smoozed.com --- module/plugins/hooks/SmoozedCom.py | 43 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 module/plugins/hooks/SmoozedCom.py (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/SmoozedCom.py b/module/plugins/hooks/SmoozedCom.py new file mode 100644 index 000000000..0aff36c0f --- /dev/null +++ b/module/plugins/hooks/SmoozedCom.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- + +from module.plugins.internal.MultiHook import MultiHook + + +class SmoozedCom(MultiHook): + __name__ = "SmoozedCom" + __type__ = "hook" + __version__ = "0.01" + + __config__ = [("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported):", "all"), + ("hosterList", "str", "Hoster list (comma separated)", ""), + ("unloadFailing", "bool", "Revert to stanard download if download fails", False), + ("interval", "int", "Reload interval in hours (0 to disable)", 24)] + + __description__ = """Smoozed.com hook plugin""" + __license__ = "GPLv3" + __authors__ = [] + + + def getHosters(self): + # If no accounts are available there will be no hosters available + if not self.account or not self.account.canUse(): + return [] + + # Get account data + (user, data) = self.account.selectAccount() + account_info = self.account.getAccountInfo(user, True) + + # Return hoster list + return account_info["hoster"] + + + def coreReady(self): + # Get account plugin and check if there is a valid account available + self.account = self.core.accountManager.getAccountPlugin("SmoozedCom") + if not self.account.canUse(): + self.account = None + self.logError(_("Please add a valid premiumize.me account first and restart pyLoad")) + return + + # Run the overwriten core ready which actually enables the multihook hook + return MultiHook.coreReady(self) -- cgit v1.2.3 From e977be3c78ea9d976e9b2338244b214a4b3a5199 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Thu, 8 Jan 2015 23:40:17 +0100 Subject: "New Year" Update: hook plugins --- module/plugins/hooks/AlldebridCom.py | 17 +++++++------ module/plugins/hooks/CaptchaBrotherhood.py | 8 +++--- module/plugins/hooks/DeathByCaptcha.py | 14 +++++------ module/plugins/hooks/DebridItaliaCom.py | 15 +++++++----- module/plugins/hooks/EasybytezCom.py | 13 +++++++--- module/plugins/hooks/FastixRu.py | 12 ++++++--- module/plugins/hooks/FreeWayMe.py | 13 ++++++---- module/plugins/hooks/LinkdecrypterCom.py | 9 ++++--- module/plugins/hooks/LinksnappyCom.py | 15 +++++++----- module/plugins/hooks/MegaDebridEu.py | 12 ++++++--- module/plugins/hooks/MultihostersCom.py | 30 ++++++++++------------- module/plugins/hooks/MultishareCz.py | 13 +++++++--- module/plugins/hooks/MyfastfileCom.py | 15 +++++++----- module/plugins/hooks/NoPremiumPl.py | 33 +++++++++++++------------ module/plugins/hooks/OverLoadMe.py | 17 +++++++------ module/plugins/hooks/PremiumTo.py | 11 ++++++--- module/plugins/hooks/PremiumizeMe.py | 15 +++++++----- module/plugins/hooks/PutdriveCom.py | 18 ++++++++++++++ module/plugins/hooks/RPNetBiz.py | 15 +++++++----- module/plugins/hooks/RapideoPl.py | 33 +++++++++++++------------ module/plugins/hooks/RealdebridCom.py | 17 +++++++------ module/plugins/hooks/RehostTo.py | 15 +++++++----- module/plugins/hooks/SimplyPremiumCom.py | 16 ++++++------ module/plugins/hooks/SimplydebridCom.py | 11 ++++++--- module/plugins/hooks/SmoozedCom.py | 39 +++++++++--------------------- module/plugins/hooks/UnrestrictLi.py | 19 ++++++++------- module/plugins/hooks/XFileSharingPro.py | 21 ++++++++-------- module/plugins/hooks/ZeveraCom.py | 20 +++++++++------ 28 files changed, 280 insertions(+), 206 deletions(-) create mode 100644 module/plugins/hooks/PutdriveCom.py (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/AlldebridCom.py b/module/plugins/hooks/AlldebridCom.py index e1f63c31b..dddd97c0c 100644 --- a/module/plugins/hooks/AlldebridCom.py +++ b/module/plugins/hooks/AlldebridCom.py @@ -6,13 +6,16 @@ from module.plugins.internal.MultiHook import MultiHook class AlldebridCom(MultiHook): __name__ = "AlldebridCom" __type__ = "hook" - __version__ = "0.15" + __version__ = "0.16" - __config__ = [("https", "bool", "Enable HTTPS", False), - ("mode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), - ("pluginlist", "str", "Hoster list (comma separated)", ""), - ("revertfailed", "bool", "Revert to standard download if download fails", False), - ("interval", "int", "Reload interval in hours (0 to disable)", 24)] + __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), + ("revertfailed" , "bool" , "Revert to standard download if fails", True ), + ("retry" , "int" , "Number of retries before revert" , 10 ), + ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), + ("reload" , "bool" , "Reload plugin list" , True ), + ("reloadinterval", "int" , "Reload interval in hours" , 12 ), + ("ssl" , "bool" , "Use HTTPS" , True )] __description__ = """Alldebrid.com hook plugin""" __license__ = "GPLv3" @@ -20,7 +23,7 @@ class AlldebridCom(MultiHook): def getHosters(self): - https = "https" if self.getConfig("https") else "http" + https = "https" if self.getConfig("ssl") else "http" page = self.getURL(https + "://www.alldebrid.com/api.php", get={'action': "get_host"}).replace("\"", "").strip() return [x.strip() for x in page.split(",") if x.strip()] diff --git a/module/plugins/hooks/CaptchaBrotherhood.py b/module/plugins/hooks/CaptchaBrotherhood.py index 9a9f05b29..3c08f5e36 100644 --- a/module/plugins/hooks/CaptchaBrotherhood.py +++ b/module/plugins/hooks/CaptchaBrotherhood.py @@ -38,7 +38,7 @@ class CaptchaBrotherhoodException(Exception): class CaptchaBrotherhood(Hook): __name__ = "CaptchaBrotherhood" __type__ = "hook" - __version__ = "0.07" + __version__ = "0.08" __config__ = [("username", "str", "Username", ""), ("force", "bool", "Force CT even if client is connected", False), @@ -118,14 +118,14 @@ class CaptchaBrotherhood(Hook): for _i in xrange(15): sleep(5) - res = self.get_api("askCaptchaResult", ticket) + res = self.api_response("askCaptchaResult", ticket) if res.startswith("OK-answered"): return ticket, res[12:] raise CaptchaBrotherhoodException("No solution received in time") - def get_api(self, api, ticket): + def api_response(self, api, ticket): res = getURL("%s%s.aspx" % (self.API_URL, api), get={"username": self.getConfig("username"), "password": self.getConfig("passkey"), @@ -160,7 +160,7 @@ class CaptchaBrotherhood(Hook): def captchaInvalid(self, task): if task.data['service'] == self.__name__ and "ticket" in task.data: - res = self.get_api("complainCaptcha", task.data['ticket']) + res = self.api_response("complainCaptcha", task.data['ticket']) @threaded diff --git a/module/plugins/hooks/DeathByCaptcha.py b/module/plugins/hooks/DeathByCaptcha.py index 98412c218..050b6fe15 100644 --- a/module/plugins/hooks/DeathByCaptcha.py +++ b/module/plugins/hooks/DeathByCaptcha.py @@ -51,7 +51,7 @@ class DeathByCaptchaException(Exception): class DeathByCaptcha(Hook): __name__ = "DeathByCaptcha" __type__ = "hook" - __version__ = "0.05" + __version__ = "0.06" __config__ = [("username", "str", "Username", ""), ("passkey", "password", "Password", ""), @@ -75,7 +75,7 @@ class DeathByCaptcha(Hook): self.info = {} #@TODO: Remove in 0.4.10 - def call_api(self, api="captcha", post=False, multipart=False): + def api_response(self, api="captcha", post=False, multipart=False): req = getRequest() req.c.setopt(HTTPHEADER, ["Accept: application/json", "User-Agent: pyLoad %s" % self.core.version]) @@ -117,7 +117,7 @@ class DeathByCaptcha(Hook): def getCredits(self): - res = self.call_api("user", True) + res = self.api_response("user", True) if 'is_banned' in res and res['is_banned']: raise DeathByCaptchaException('banned') @@ -128,7 +128,7 @@ class DeathByCaptcha(Hook): def getStatus(self): - res = self.call_api("status", False) + res = self.api_response("status", False) if 'is_service_overloaded' in res and res['is_service_overloaded']: raise DeathByCaptchaException('service-overload') @@ -145,7 +145,7 @@ class DeathByCaptcha(Hook): data = f.read() data = "base64:" + b64encode(data) - res = self.call_api("captcha", {"captchafile": data}, multipart) + res = self.api_response("captcha", {"captchafile": data}, multipart) if "captcha" not in res: raise DeathByCaptchaException(res) @@ -153,7 +153,7 @@ class DeathByCaptcha(Hook): for _i in xrange(24): sleep(5) - res = self.call_api("captcha/%d" % ticket, False) + res = self.api_response("captcha/%d" % ticket, False) if res['text'] and res['is_correct']: break else: @@ -200,7 +200,7 @@ class DeathByCaptcha(Hook): def captchaInvalid(self, task): if task.data['service'] == self.__name__ and "ticket" in task.data: try: - res = self.call_api("captcha/%d/report" % task.data['ticket'], True) + res = self.api_response("captcha/%d/report" % task.data['ticket'], True) except DeathByCaptchaException, e: self.logError(e.getDesc()) diff --git a/module/plugins/hooks/DebridItaliaCom.py b/module/plugins/hooks/DebridItaliaCom.py index d18be5384..719f3dd3a 100644 --- a/module/plugins/hooks/DebridItaliaCom.py +++ b/module/plugins/hooks/DebridItaliaCom.py @@ -8,12 +8,15 @@ from module.plugins.internal.MultiHook import MultiHook class DebridItaliaCom(MultiHook): __name__ = "DebridItaliaCom" __type__ = "hook" - __version__ = "0.11" - - __config__ = [("mode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), - ("pluginlist", "str", "Hoster list (comma separated)", ""), - ("revertfailed", "bool", "Revert to standard download if download fails", False), - ("interval", "int", "Reload interval in hours (0 to disable)", 24)] + __version__ = "0.12" + + __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), + ("revertfailed" , "bool" , "Revert to standard download if fails", True ), + ("retry" , "int" , "Number of retries before revert" , 10 ), + ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), + ("reload" , "bool" , "Reload plugin list" , True ), + ("reloadinterval", "int" , "Reload interval in hours" , 12 )] __description__ = """Debriditalia.com hook plugin""" __license__ = "GPLv3" diff --git a/module/plugins/hooks/EasybytezCom.py b/module/plugins/hooks/EasybytezCom.py index 1606c9f30..c460de7b7 100644 --- a/module/plugins/hooks/EasybytezCom.py +++ b/module/plugins/hooks/EasybytezCom.py @@ -8,10 +8,15 @@ from module.plugins.internal.MultiHook import MultiHook class EasybytezCom(MultiHook): __name__ = "EasybytezCom" __type__ = "hook" - __version__ = "0.06" - - __config__ = [("mode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), - ("pluginlist", "str", "Hoster list (comma separated)", "")] + __version__ = "0.07" + + __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), + ("revertfailed" , "bool" , "Revert to standard download if fails", True ), + ("retry" , "int" , "Number of retries before revert" , 10 ), + ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), + ("reload" , "bool" , "Reload plugin list" , True ), + ("reloadinterval", "int" , "Reload interval in hours" , 12 )] __description__ = """EasyBytez.com hook plugin""" __license__ = "GPLv3" diff --git a/module/plugins/hooks/FastixRu.py b/module/plugins/hooks/FastixRu.py index a4b423fb7..25126fbd3 100644 --- a/module/plugins/hooks/FastixRu.py +++ b/module/plugins/hooks/FastixRu.py @@ -7,11 +7,15 @@ from module.plugins.internal.MultiHook import MultiHook class FastixRu(MultiHook): __name__ = "FastixRu" __type__ = "hook" - __version__ = "0.04" + __version__ = "0.05" - __config__ = [("mode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), - ("revertfailed", "bool", "Revert to standard download if download fails", False), - ("interval", "int", "Reload interval in hours (0 to disable)", 24)] + __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), + ("revertfailed" , "bool" , "Revert to standard download if fails", True ), + ("retry" , "int" , "Number of retries before revert" , 10 ), + ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), + ("reload" , "bool" , "Reload plugin list" , True ), + ("reloadinterval", "int" , "Reload interval in hours" , 12 )] __description__ = """Fastix.ru hook plugin""" __license__ = "GPLv3" diff --git a/module/plugins/hooks/FreeWayMe.py b/module/plugins/hooks/FreeWayMe.py index 6cbea3417..6fec037d8 100644 --- a/module/plugins/hooks/FreeWayMe.py +++ b/module/plugins/hooks/FreeWayMe.py @@ -6,12 +6,15 @@ from module.plugins.internal.MultiHook import MultiHook class FreeWayMe(MultiHook): __name__ = "FreeWayMe" __type__ = "hook" - __version__ = "0.13" + __version__ = "0.14" - __config__ = [("mode", "all;listed;unlisted", "Use for hosters (if supported):", "all"), - ("pluginlist", "str", "Hoster list (comma separated)", ""), - ("revertfailed", "bool", "Revert to standard download if download fails", False), - ("interval", "int", "Reload interval in hours (0 to disable)", 24)] + __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), + ("revertfailed" , "bool" , "Revert to standard download if fails", True ), + ("retry" , "int" , "Number of retries before revert" , 10 ), + ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), + ("reload" , "bool" , "Reload plugin list" , True ), + ("reloadinterval", "int" , "Reload interval in hours" , 12 )] __description__ = """FreeWay.me hook plugin""" __license__ = "GPLv3" diff --git a/module/plugins/hooks/LinkdecrypterCom.py b/module/plugins/hooks/LinkdecrypterCom.py index 8592efd3d..d4924a687 100644 --- a/module/plugins/hooks/LinkdecrypterCom.py +++ b/module/plugins/hooks/LinkdecrypterCom.py @@ -8,11 +8,12 @@ from module.plugins.internal.MultiHook import MultiHook class LinkdecrypterCom(MultiHook): __name__ = "LinkdecrypterCom" __type__ = "hook" - __version__ = "1.00" + __version__ = "1.01" - __config__ = [("mode" , "all;listed;unlisted", "Use for crypters (if supported)" , "all"), - ("pluginlist" , "str" , "Crypter list (comma separated)" , "" ), - ("interval" , "int" , "Reload interval in hours (0 to disable)" , 12 )] + __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), + ("reload" , "bool" , "Reload plugin list" , True ), + ("reloadinterval", "int" , "Reload interval in hours" , 12 )] __description__ = """Linkdecrypter.com hook plugin""" __license__ = "GPLv3" diff --git a/module/plugins/hooks/LinksnappyCom.py b/module/plugins/hooks/LinksnappyCom.py index a1c4b90f7..5eb0c7f6d 100644 --- a/module/plugins/hooks/LinksnappyCom.py +++ b/module/plugins/hooks/LinksnappyCom.py @@ -7,12 +7,15 @@ from module.plugins.internal.MultiHook import MultiHook class LinksnappyCom(MultiHook): __name__ = "LinksnappyCom" __type__ = "hook" - __version__ = "0.03" - - __config__ = [("mode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), - ("pluginlist", "str", "Hoster list (comma separated)", ""), - ("revertfailed", "bool", "Revert to standard download if download fails", False), - ("interval", "int", "Reload interval in hours (0 to disable)", 24)] + __version__ = "0.04" + + __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), + ("revertfailed" , "bool" , "Revert to standard download if fails", True ), + ("retry" , "int" , "Number of retries before revert" , 10 ), + ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), + ("reload" , "bool" , "Reload plugin list" , True ), + ("reloadinterval", "int" , "Reload interval in hours" , 12 )] __description__ = """Linksnappy.com hook plugin""" __license__ = "GPLv3" diff --git a/module/plugins/hooks/MegaDebridEu.py b/module/plugins/hooks/MegaDebridEu.py index 5fb7e1ea6..f67fa7ac0 100644 --- a/module/plugins/hooks/MegaDebridEu.py +++ b/module/plugins/hooks/MegaDebridEu.py @@ -7,11 +7,17 @@ from module.plugins.internal.MultiHook import MultiHook class MegaDebridEu(MultiHook): __name__ = "MegaDebridEu" __type__ = "hook" - __version__ = "0.04" + __version__ = "0.05" - __config__ = [("revertfailed", "bool", "Revert to standard download if download fails", False)] + __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), + ("revertfailed" , "bool" , "Revert to standard download if fails", True ), + ("retry" , "int" , "Number of retries before revert" , 10 ), + ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), + ("reload" , "bool" , "Reload plugin list" , True ), + ("reloadinterval", "int" , "Reload interval in hours" , 12 )] - __description__ = """mega-debrid.eu hook plugin""" + __description__ = """Mega-debrid.eu hook plugin""" __license__ = "GPLv3" __authors__ = [("D.Ducatel", "dducatel@je-geek.fr")] diff --git a/module/plugins/hooks/MultihostersCom.py b/module/plugins/hooks/MultihostersCom.py index 5ada3aa56..bf88cfae7 100644 --- a/module/plugins/hooks/MultihostersCom.py +++ b/module/plugins/hooks/MultihostersCom.py @@ -1,22 +1,18 @@ # -*- coding: utf-8 -*- -from module.network.RequestFactory import getURL -from module.plugins.internal.MultiHoster import MultiHoster +from module.plugins.hooks.ZeveraCom import ZeveraCom -class MultihostersCom(MultiHoster): - __name__ = "MultihostersCom" - __version__ = "0.01" - __type__ = "hook" - __config__ = [("activated", "bool", "Activated", False), - ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), - ("hosterList", "str", "Hoster list (comma separated)", ""), - ("unloadFailing", "bool", "Revert to standard download if download fails", False), - ("interval", "int", "Reload interval in hours (0 to disable)", 24)] - __description__ = """Multihosters.com hook plugin""" - __author_name__ = "tjeh" - __author_mail__ = "tjeh@gmx.net" +class MultihostersCom(ZeveraCom): + __name__ = "MultihostersCom" + __type__ = "hook" + __version__ = "0.02" + + __config__ = [("mode" , "all;listed;unlisted", "Use for plugins (if supported)" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), + ("revertfailed", "bool" , "Revert to standard download if download fails", False), + ("interval" , "int" , "Reload interval in hours (0 to disable)" , 12 )] - def getHoster(self): - page = getURL("http://www.multihosters.com/jDownloader.ashx?cmd=gethosters") - return [x.strip() for x in page.split(",")] \ No newline at end of file + __description__ = """Multihosters.com hook plugin""" + __license__ = "GPLv3" + __authors__ = [("tjeh", "tjeh@gmx.net")] diff --git a/module/plugins/hooks/MultishareCz.py b/module/plugins/hooks/MultishareCz.py index 2dadf5dc1..8349e0de8 100644 --- a/module/plugins/hooks/MultishareCz.py +++ b/module/plugins/hooks/MultishareCz.py @@ -8,10 +8,15 @@ from module.plugins.internal.MultiHook import MultiHook class MultishareCz(MultiHook): __name__ = "MultishareCz" __type__ = "hook" - __version__ = "0.06" - - __config__ = [("mode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), - ("pluginlist", "str", "Hoster list (comma separated)", "uloz.to")] + __version__ = "0.07" + + __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), + ("revertfailed" , "bool" , "Revert to standard download if fails", True ), + ("retry" , "int" , "Number of retries before revert" , 10 ), + ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), + ("reload" , "bool" , "Reload plugin list" , True ), + ("reloadinterval", "int" , "Reload interval in hours" , 12 )] __description__ = """MultiShare.cz hook plugin""" __license__ = "GPLv3" diff --git a/module/plugins/hooks/MyfastfileCom.py b/module/plugins/hooks/MyfastfileCom.py index 2fda0d3bf..86408cb6d 100644 --- a/module/plugins/hooks/MyfastfileCom.py +++ b/module/plugins/hooks/MyfastfileCom.py @@ -7,12 +7,15 @@ from module.plugins.internal.MultiHook import MultiHook class MyfastfileCom(MultiHook): __name__ = "MyfastfileCom" __type__ = "hook" - __version__ = "0.04" - - __config__ = [("mode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), - ("pluginlist", "str", "Hoster list (comma separated)", ""), - ("revertfailed", "bool", "Revert to standard download if download fails", False), - ("interval", "int", "Reload interval in hours (0 to disable)", 24)] + __version__ = "0.05" + + __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), + ("revertfailed" , "bool" , "Revert to standard download if fails", True ), + ("retry" , "int" , "Number of retries before revert" , 10 ), + ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), + ("reload" , "bool" , "Reload plugin list" , True ), + ("reloadinterval", "int" , "Reload interval in hours" , 12 )] __description__ = """Myfastfile.com hook plugin""" __license__ = "GPLv3" diff --git a/module/plugins/hooks/NoPremiumPl.py b/module/plugins/hooks/NoPremiumPl.py index 2347fc58a..1727bec70 100644 --- a/module/plugins/hooks/NoPremiumPl.py +++ b/module/plugins/hooks/NoPremiumPl.py @@ -1,28 +1,31 @@ # -*- coding: utf-8 -*- +from module.common.json_layer import json_loads from module.plugins.internal.MultiHook import MultiHook -from module.common.json_layer import json_loads as loads class NoPremiumPl(MultiHook): - __name__ = "NoPremiumPl" - __version__ = "0.02" - __type__ = "hook" + __name__ = "NoPremiumPl" + __type__ = "hook" + __version__ = "0.03" - __config__ = [("activated", "bool", "Activated", False), - ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported):", "all"), - ("hosterList", "str", "Hoster list (comma separated)", ""), - ("unloadFailing", "bool", "Try standard download if download fails", False), - ("interval", "int", "Reload supported hosts interval in hours (0 to disable)", 24)] + __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), + ("revertfailed" , "bool" , "Revert to standard download if fails", True ), + ("retry" , "int" , "Number of retries before revert" , 10 ), + ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), + ("reload" , "bool" , "Reload plugin list" , True ), + ("reloadinterval", "int" , "Reload interval in hours" , 12 )] + + __description__ = """NoPremium.pl hook plugin""" + __license__ = "GPLv3" + __authors__ = [("goddie", "dev@nopremium.pl")] - __description__ = "NoPremium.pl hook" - __license__ = "GPLv3" - __authors__ = [("goddie", "dev@nopremium.pl")] def getHosters(self): - hostings = loads(self.getURL("https://www.nopremium.pl/clipboard.php?json=3").strip()) + hostings = json_loads(self.getURL("https://www.nopremium.pl/clipboard.php?json=3").strip()) hostings_domains = [domain for row in hostings for domain in row["domains"] if row["sdownload"] == "0"] - self.logDebug(hostings_domains) - return hostings_domains + self.logDebug(hostings_domains) + return hostings_domains diff --git a/module/plugins/hooks/OverLoadMe.py b/module/plugins/hooks/OverLoadMe.py index eb3da319a..1872f8ccb 100644 --- a/module/plugins/hooks/OverLoadMe.py +++ b/module/plugins/hooks/OverLoadMe.py @@ -6,13 +6,16 @@ from module.plugins.internal.MultiHook import MultiHook class OverLoadMe(MultiHook): __name__ = "OverLoadMe" __type__ = "hook" - __version__ = "0.03" + __version__ = "0.04" - __config__ = [("https", "bool", "Enable HTTPS", True), - ("mode", "all;listed;unlisted", "Use for hosters (if supported):", "all"), - ("pluginlist", "str", "Hoster list (comma separated)", ""), - ("revertfailed", "bool", "Revert to standard download if download fails", False), - ("interval", "int", "Reload interval in hours (0 to disable)", 12)] + __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), + ("revertfailed" , "bool" , "Revert to standard download if fails", True ), + ("retry" , "int" , "Number of retries before revert" , 10 ), + ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), + ("reload" , "bool" , "Reload plugin list" , True ), + ("reloadinterval", "int" , "Reload interval in hours" , 12 ), + ("ssl" , "bool" , "Use HTTPS" , True )] __description__ = """Over-Load.me hook plugin""" __license__ = "GPLv3" @@ -20,7 +23,7 @@ class OverLoadMe(MultiHook): def getHosters(self): - https = "https" if self.getConfig("https") else "http" + https = "https" if self.getConfig("ssl") else "http" page = self.getURL(https + "://api.over-load.me/hoster.php", get={'auth': "0001-cb1f24dadb3aa487bda5afd3b76298935329be7700cd7-5329be77-00cf-1ca0135f"}).replace("\"", "").strip() self.logDebug("Hosterlist", page) diff --git a/module/plugins/hooks/PremiumTo.py b/module/plugins/hooks/PremiumTo.py index a4203c8bb..844ecc89d 100644 --- a/module/plugins/hooks/PremiumTo.py +++ b/module/plugins/hooks/PremiumTo.py @@ -6,10 +6,15 @@ from module.plugins.internal.MultiHook import MultiHook class PremiumTo(MultiHook): __name__ = "PremiumTo" __type__ = "hook" - __version__ = "0.07" + __version__ = "0.08" - __config__ = [("mode", "all;listed;unlisted", "Use for downloads from supported hosters:", "all"), - ("pluginlist", "str", "Hoster list (comma separated)", "")] + __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), + ("revertfailed" , "bool" , "Revert to standard download if fails", True ), + ("retry" , "int" , "Number of retries before revert" , 10 ), + ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), + ("reload" , "bool" , "Reload plugin list" , True ), + ("reloadinterval", "int" , "Reload interval in hours" , 12 )] __description__ = """Premium.to hook plugin""" __license__ = "GPLv3" diff --git a/module/plugins/hooks/PremiumizeMe.py b/module/plugins/hooks/PremiumizeMe.py index d334ddd25..293fcf339 100644 --- a/module/plugins/hooks/PremiumizeMe.py +++ b/module/plugins/hooks/PremiumizeMe.py @@ -7,12 +7,15 @@ from module.plugins.internal.MultiHook import MultiHook class PremiumizeMe(MultiHook): __name__ = "PremiumizeMe" __type__ = "hook" - __version__ = "0.16" - - __config__ = [("mode", "all;listed;unlisted", "Use for hosters (if supported):", "all"), - ("pluginlist", "str", "Hoster list (comma separated)", ""), - ("revertfailed", "bool", "Revert to standard download if download fails", False), - ("interval", "int", "Reload interval in hours (0 to disable)", 24)] + __version__ = "0.17" + + __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), + ("revertfailed" , "bool" , "Revert to standard download if fails", True ), + ("retry" , "int" , "Number of retries before revert" , 10 ), + ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), + ("reload" , "bool" , "Reload plugin list" , True ), + ("reloadinterval", "int" , "Reload interval in hours" , 12 )] __description__ = """Premiumize.me hook plugin""" __license__ = "GPLv3" diff --git a/module/plugins/hooks/PutdriveCom.py b/module/plugins/hooks/PutdriveCom.py new file mode 100644 index 000000000..f665dabee --- /dev/null +++ b/module/plugins/hooks/PutdriveCom.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- + +from module.plugins.hooks.ZeveraCom import ZeveraCom + + +class PutdriveCom(ZeveraCom): + __name__ = "PutdriveCom" + __type__ = "hook" + __version__ = "0.01" + + __config__ = [("mode" , "all;listed;unlisted", "Use for plugins (if supported)" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), + ("revertfailed", "bool" , "Revert to standard download if download fails", False), + ("interval" , "int" , "Reload interval in hours (0 to disable)" , 12 )] + + __description__ = """Putdrive.com hook plugin""" + __license__ = "GPLv3" + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] diff --git a/module/plugins/hooks/RPNetBiz.py b/module/plugins/hooks/RPNetBiz.py index 9c88e6c01..0768bd6cd 100644 --- a/module/plugins/hooks/RPNetBiz.py +++ b/module/plugins/hooks/RPNetBiz.py @@ -7,12 +7,15 @@ from module.plugins.internal.MultiHook import MultiHook class RPNetBiz(MultiHook): __name__ = "RPNetBiz" __type__ = "hook" - __version__ = "0.13" - - __config__ = [("mode", "all;listed;unlisted", "Use for hosters (if supported):", "all"), - ("pluginlist", "str", "Hoster list (comma separated)", ""), - ("revertfailed", "bool", "Revert to standard download if download fails", False), - ("interval", "int", "Reload interval in hours (0 to disable)", 24)] + __version__ = "0.14" + + __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), + ("revertfailed" , "bool" , "Revert to standard download if fails", True ), + ("retry" , "int" , "Number of retries before revert" , 10 ), + ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), + ("reload" , "bool" , "Reload plugin list" , True ), + ("reloadinterval", "int" , "Reload interval in hours" , 12 )] __description__ = """RPNet.biz hook plugin""" __license__ = "GPLv3" diff --git a/module/plugins/hooks/RapideoPl.py b/module/plugins/hooks/RapideoPl.py index 9eb454897..b605eca17 100644 --- a/module/plugins/hooks/RapideoPl.py +++ b/module/plugins/hooks/RapideoPl.py @@ -1,28 +1,31 @@ # -*- coding: utf-8 -*- +from module.common.json_layer import json_loads from module.plugins.internal.MultiHook import MultiHook -from module.common.json_layer import json_loads as loads class RapideoPl(MultiHook): - __name__ = "RapideoPl" - __version__ = "0.02" - __type__ = "hook" + __name__ = "RapideoPl" + __type__ = "hook" + __version__ = "0.03" - __config__ = [("activated", "bool", "Activated", False), - ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported):", "all"), - ("hosterList", "str", "Hoster list (comma separated)", ""), - ("unloadFailing", "bool", "Try standard download if download fails", False), - ("interval", "int", "Reload supported hosts interval in hours (0 to disable)", 24)] + __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), + ("revertfailed" , "bool" , "Revert to standard download if fails", True ), + ("retry" , "int" , "Number of retries before revert" , 10 ), + ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), + ("reload" , "bool" , "Reload plugin list" , True ), + ("reloadinterval", "int" , "Reload interval in hours" , 12 )] + + __description__ = """Rapideo.pl hook plugin""" + __license__ = "GPLv3" + __authors__ = [("goddie", "dev@rapideo.pl")] - __description__ = "Rapideo.pl hook" - __license__ = "GPLv3" - __authors__ = [("goddie", "dev@rapideo.pl")] def getHosters(self): - hostings = loads(self.getURL("https://www.rapideo.pl/clipboard.php?json=3").strip()) + hostings = json_loads(self.getURL("https://www.rapideo.pl/clipboard.php?json=3").strip()) hostings_domains = [domain for row in hostings for domain in row["domains"] if row["sdownload"] == "0"] - self.logDebug(hostings_domains) - return hostings_domains + self.logDebug(hostings_domains) + return hostings_domains diff --git a/module/plugins/hooks/RealdebridCom.py b/module/plugins/hooks/RealdebridCom.py index bac18e6c3..cff97c2f9 100644 --- a/module/plugins/hooks/RealdebridCom.py +++ b/module/plugins/hooks/RealdebridCom.py @@ -6,13 +6,16 @@ from module.plugins.internal.MultiHook import MultiHook class RealdebridCom(MultiHook): __name__ = "RealdebridCom" __type__ = "hook" - __version__ = "0.45" + __version__ = "0.46" - __config__ = [("https", "bool", "Enable HTTPS", False), - ("mode", "all;listed;unlisted", "Use for hosters (if supported):", "all"), - ("pluginlist", "str", "Hoster list (comma separated)", ""), - ("revertfailed", "bool", "Revert to standard download if download fails", False), - ("interval", "int", "Reload interval in hours (0 to disable)", 24)] + __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), + ("revertfailed" , "bool" , "Revert to standard download if fails", True ), + ("retry" , "int" , "Number of retries before revert" , 10 ), + ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), + ("reload" , "bool" , "Reload plugin list" , True ), + ("reloadinterval", "int" , "Reload interval in hours" , 12 ), + ("ssl" , "bool" , "Use HTTPS" , True )] __description__ = """Real-Debrid.com hook plugin""" __license__ = "GPLv3" @@ -20,7 +23,7 @@ class RealdebridCom(MultiHook): def getHosters(self): - https = "https" if self.getConfig("https") else "http" + https = "https" if self.getConfig("ssl") else "http" page = self.getURL(https + "://real-debrid.com/api/hosters.php").replace("\"", "").strip() return [x.strip() for x in page.split(",") if x.strip()] diff --git a/module/plugins/hooks/RehostTo.py b/module/plugins/hooks/RehostTo.py index 527770eb6..81cb26f2f 100644 --- a/module/plugins/hooks/RehostTo.py +++ b/module/plugins/hooks/RehostTo.py @@ -6,12 +6,15 @@ from module.plugins.internal.MultiHook import MultiHook class RehostTo(MultiHook): __name__ = "RehostTo" __type__ = "hook" - __version__ = "0.46" - - __config__ = [("mode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), - ("pluginlist", "str", "Hoster list (comma separated)", ""), - ("revertfailed", "bool", "Revert to standard download if download fails", False), - ("interval", "int", "Reload interval in hours (0 to disable)", 24)] + __version__ = "0.47" + + __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), + ("revertfailed" , "bool" , "Revert to standard download if fails", True ), + ("retry" , "int" , "Number of retries before revert" , 10 ), + ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), + ("reload" , "bool" , "Reload plugin list" , True ), + ("reloadinterval", "int" , "Reload interval in hours" , 12 )] __description__ = """Rehost.to hook plugin""" __license__ = "GPLv3" diff --git a/module/plugins/hooks/SimplyPremiumCom.py b/module/plugins/hooks/SimplyPremiumCom.py index 5f2d2a42c..843a3aa82 100644 --- a/module/plugins/hooks/SimplyPremiumCom.py +++ b/module/plugins/hooks/SimplyPremiumCom.py @@ -7,13 +7,15 @@ from module.plugins.internal.MultiHook import MultiHook class SimplyPremiumCom(MultiHook): __name__ = "SimplyPremiumCom" __type__ = "hook" - __version__ = "0.04" - - __config__ = [("activated", "bool", "Activated", "False"), - ("mode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), - ("pluginlist", "str", "Hoster list (comma separated)", ""), - ("revertfailed", "bool", "Revert to standard download if download fails", "False"), - ("interval", "int", "Reload interval in hours (0 to disable)", "24")] + __version__ = "0.05" + + __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), + ("revertfailed" , "bool" , "Revert to standard download if fails", True ), + ("retry" , "int" , "Number of retries before revert" , 10 ), + ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), + ("reload" , "bool" , "Reload plugin list" , True ), + ("reloadinterval", "int" , "Reload interval in hours" , 12 )] __description__ = """Simply-Premium.com hook plugin""" __license__ = "GPLv3" diff --git a/module/plugins/hooks/SimplydebridCom.py b/module/plugins/hooks/SimplydebridCom.py index 13c957294..10c613fb5 100644 --- a/module/plugins/hooks/SimplydebridCom.py +++ b/module/plugins/hooks/SimplydebridCom.py @@ -6,10 +6,15 @@ from module.plugins.internal.MultiHook import MultiHook class SimplydebridCom(MultiHook): __name__ = "SimplydebridCom" __type__ = "hook" - __version__ = "0.03" + __version__ = "0.04" - __config__ = [("mode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), - ("pluginlist", "str", "Hoster list (comma separated)", "")] + __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), + ("revertfailed" , "bool" , "Revert to standard download if fails", True ), + ("retry" , "int" , "Number of retries before revert" , 10 ), + ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), + ("reload" , "bool" , "Reload plugin list" , True ), + ("reloadinterval", "int" , "Reload interval in hours" , 12 )] __description__ = """Simply-Debrid.com hook plugin""" __license__ = "GPLv3" diff --git a/module/plugins/hooks/SmoozedCom.py b/module/plugins/hooks/SmoozedCom.py index 0aff36c0f..4e706c959 100644 --- a/module/plugins/hooks/SmoozedCom.py +++ b/module/plugins/hooks/SmoozedCom.py @@ -6,38 +6,21 @@ from module.plugins.internal.MultiHook import MultiHook class SmoozedCom(MultiHook): __name__ = "SmoozedCom" __type__ = "hook" - __version__ = "0.01" + __version__ = "0.02" - __config__ = [("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported):", "all"), - ("hosterList", "str", "Hoster list (comma separated)", ""), - ("unloadFailing", "bool", "Revert to stanard download if download fails", False), - ("interval", "int", "Reload interval in hours (0 to disable)", 24)] + __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), + ("revertfailed" , "bool" , "Revert to standard download if fails", True ), + ("retry" , "int" , "Number of retries before revert" , 10 ), + ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), + ("reload" , "bool" , "Reload plugin list" , True ), + ("reloadinterval", "int" , "Reload interval in hours" , 12 )] __description__ = """Smoozed.com hook plugin""" __license__ = "GPLv3" - __authors__ = [] + __authors__ = [("", "")] def getHosters(self): - # If no accounts are available there will be no hosters available - if not self.account or not self.account.canUse(): - return [] - - # Get account data - (user, data) = self.account.selectAccount() - account_info = self.account.getAccountInfo(user, True) - - # Return hoster list - return account_info["hoster"] - - - def coreReady(self): - # Get account plugin and check if there is a valid account available - self.account = self.core.accountManager.getAccountPlugin("SmoozedCom") - if not self.account.canUse(): - self.account = None - self.logError(_("Please add a valid premiumize.me account first and restart pyLoad")) - return - - # Run the overwriten core ready which actually enables the multihook hook - return MultiHook.coreReady(self) + user, data = self.account.selectAccount() + return self.account.getAccountData(user)["hosters"] diff --git a/module/plugins/hooks/UnrestrictLi.py b/module/plugins/hooks/UnrestrictLi.py index e481e8449..cb5abb26e 100644 --- a/module/plugins/hooks/UnrestrictLi.py +++ b/module/plugins/hooks/UnrestrictLi.py @@ -7,13 +7,16 @@ from module.plugins.internal.MultiHook import MultiHook class UnrestrictLi(MultiHook): __name__ = "UnrestrictLi" __type__ = "hook" - __version__ = "0.04" + __version__ = "0.05" - __config__ = [("mode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), - ("pluginlist", "str", "Hoster list (comma separated)", ""), - ("revertfailed", "bool", "Revert to standard download if download fails", False), - ("interval", "int", "Reload interval in hours (0 to disable)", 24), - ("history", "bool", "Delete History", False)] + __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), + ("revertfailed" , "bool" , "Revert to standard download if fails", True ), + ("retry" , "int" , "Number of retries before revert" , 10 ), + ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), + ("reload" , "bool" , "Reload plugin list" , True ), + ("reloadinterval", "int" , "Reload interval in hours" , 12 ), + ("history" , "bool" , "Delete History" , False)] __description__ = """Unrestrict.li hook plugin""" __license__ = "GPLv3" @@ -24,6 +27,4 @@ class UnrestrictLi(MultiHook): json_data = self.getURL("http://unrestrict.li/api/jdownloader/hosts.php", get={'format': "json"}) json_data = json_loads(json_data) - host_list = [element['host'] for element in json_data['result']] - - return host_list + return [element['host'] for element in json_data['result']] diff --git a/module/plugins/hooks/XFileSharingPro.py b/module/plugins/hooks/XFileSharingPro.py index 79e373ad3..73cb0b0eb 100644 --- a/module/plugins/hooks/XFileSharingPro.py +++ b/module/plugins/hooks/XFileSharingPro.py @@ -8,7 +8,7 @@ from module.plugins.Hook import Hook class XFileSharingPro(Hook): __name__ = "XFileSharingPro" __type__ = "hook" - __version__ = "0.28" + __version__ = "0.29" __config__ = [("activated" , "bool", "Activated" , True ), ("use_hoster_list" , "bool", "Load listed hosters only" , False), @@ -23,14 +23,15 @@ class XFileSharingPro(Hook): # event_list = ["pluginConfigChanged"] - regexp = {'hoster' : (r'https?://(?:www\.)?([\w.^_]+(?:\.[a-zA-Z]{2,})(?:\:\d+)?)/(?:embed-)?\w{12}(?:\W|$)', - r'https?://(?:[^/]+\.)?(%s)/(?:embed-)?\w+'), - 'crypter': (r'https?://(?:www\.)?([\w.^_]+(?:\.[a-zA-Z]{2,})(?:\:\d+)?)/(?:user|folder)s?/\w+', - r'https?://(?:[^/]+\.)?(%s)/(?:user|folder)s?/\w+')} + regexp = {'hoster' : (r'https?://(?:www\.)?(?P<DOMAIN>[\w.^_]+(?:\.[a-zA-Z]{2,})(?:\:\d+)?)/(?:embed-)?\w{12}(?:\W|$)', + r'https?://(?:[^/]+\.)?(?P<DOMAIN>%s)/(?:embed-)?\w+'), + 'crypter': (r'https?://(?:www\.)?(?P<DOMAIN>[\w.^_]+(?:\.[a-zA-Z]{2,})(?:\:\d+)?)/(?:user|folder)s?/\w+', + r'https?://(?:[^/]+\.)?(?P<DOMAIN>%s)/(?:user|folder)s?/\w+')} HOSTER_BUILTIN = [#WORKING HOSTERS: - "eyesfile.ca", "file4safe.com", "fileband.com", "filedwon.com", "filevice.com", "hostingbulk.com", - "ravishare.com", "salefiles.com", "sharesix.com", "thefile.me", "verzend.be", "xvidstage.com", + "180upload.com", "backin.net", "eyesfile.ca", "file4safe.com", "fileband.com", "filedwon.com", + "fileparadox.in", "filevice.com", "hostingbulk.com", "linestorage.com", "ravishare.com", "salefiles.com", + "sendmyway.com", "sharesix.com", "thefile.me", "verzend.be", "xvidstage.com", #NOT TESTED: "101shared.com", "4upfiles.com", "filemaze.ws", "filenuke.com", "linkzhost.com", "mightyupload.com", "rockdizfile.com", "sharebeast.com", "sharerepo.com", "shareswift.com", "uploadbaz.com", "uploadc.com", @@ -82,7 +83,7 @@ class XFileSharingPro(Hook): len_match_list = len(plugin_list) self.logInfo(_("Handling %d %s%s: %s") % (len_match_list, type, - "" if len_match_list is 1 else "s", + "" if len_match_list == 1 else "s", match_list.replace('|', ', '))) pattern = self.regexp[type][1] % match_list.replace('.', '\.') @@ -109,7 +110,7 @@ class XFileSharingPro(Hook): def unloadHoster(self, hoster): hdict = self.core.pluginManager.hosterPlugins[hoster] - if "new_name" in hdict and hdict['new_name'] is "XFileSharingPro": + if "new_name" in hdict and hdict['new_name'] == "XFileSharingPro": if "module" in hdict: del hdict['module'] @@ -123,7 +124,7 @@ class XFileSharingPro(Hook): # def downloadFailed(self, pyfile): - # if pyfile.pluginname is "BasePlugin" \ + # if pyfile.pluginname == "BasePlugin" \ # and pyfile.hasStatus("failed") \ # and not self.getConfig("use_hoster_list") \ # and self.unloadHoster("BasePlugin"): diff --git a/module/plugins/hooks/ZeveraCom.py b/module/plugins/hooks/ZeveraCom.py index 51f759b1c..215ec3673 100644 --- a/module/plugins/hooks/ZeveraCom.py +++ b/module/plugins/hooks/ZeveraCom.py @@ -6,16 +6,22 @@ from module.plugins.internal.MultiHook import MultiHook class ZeveraCom(MultiHook): __name__ = "ZeveraCom" __type__ = "hook" - __version__ = "0.04" + __version__ = "0.05" - __config__ = [("mode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), - ("pluginlist", "str", "Hoster list (comma separated)", "")] + __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), + ("revertfailed" , "bool" , "Revert to standard download if fails", True ), + ("retry" , "int" , "Number of retries before revert" , 10 ), + ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), + ("reload" , "bool" , "Reload plugin list" , True ), + ("reloadinterval", "int" , "Reload interval in hours" , 12 )] - __description__ = """Real-Debrid.com hook plugin""" + __description__ = """Zevera.com hook plugin""" __license__ = "GPLv3" - __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] + __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), + ("Walter Purcaro", "vuolter@gmail.com")] def getHosters(self): - page = self.getURL("http://www.zevera.com/jDownloader.ashx", get={'cmd': "gethosters"}) - return [x.strip() for x in page.replace("\"", "").split(",")] + html = self.account.api_response(pyreq.getHTTPRequest(timeout=120), cmd="gethosters") + return [x.strip() for x in html.split(",")] -- cgit v1.2.3 From 73b7584189b091006893f27ca91e79472ddb77ad Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Fri, 9 Jan 2015 17:32:26 +0100 Subject: [SkipRev] Improve file name grabbing --- module/plugins/hooks/SkipRev.py | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py index cc32c365e..ad6d7dacd 100644 --- a/module/plugins/hooks/SkipRev.py +++ b/module/plugins/hooks/SkipRev.py @@ -18,7 +18,7 @@ def _setup(self): class SkipRev(Hook): __name__ = "SkipRev" __type__ = "hook" - __version__ = "0.21" + __version__ = "0.22" __config__ = [("tokeep", "int", "Number of rev files to keep for package (-1 to auto)", -1)] @@ -33,23 +33,11 @@ class SkipRev(Hook): def _pyname(self, pyfile): - url = pyfile.url - plugin = pyfile.plugin - - if hasattr(plugin, "info") and 'name' in plugin.info and plugin.info['name']: - name = plugin.info['name'] - - elif hasattr(plugin, "parseInfos"): - name = next(plugin.parseInfos([url]))['name'] - - elif hasattr(plugin, "getInfo"): #@NOTE: if parseInfos was not found, getInfo should be missing too - name = plugin.getInfo(url)['name'] - + if hasattr(pyfile.pluginmodule, "getInfo"): + return getattr(pyfile.pluginmodule, "getInfo")([pyfile.url])[0][0] else: self.logWarning("Unable to grab file name") - name = urlparse(unquote(url)).path.split('/')[-1] - - return name + return urlparse(unquote(pyfile.url)).path.split('/')[-1] def _pyfile(self, link): -- cgit v1.2.3 From b4a26e4bdcfa697b833abac4b2a500000f24684f Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Fri, 9 Jan 2015 17:35:08 +0100 Subject: Fix some plugins name --- module/plugins/hooks/Captcha9kw.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/Captcha9kw.py b/module/plugins/hooks/Captcha9kw.py index 6eb4ef305..600694e78 100755 --- a/module/plugins/hooks/Captcha9kw.py +++ b/module/plugins/hooks/Captcha9kw.py @@ -13,8 +13,8 @@ from module.network.RequestFactory import getURL from module.plugins.Hook import Hook, threaded -class Captcha9kw(Hook): - __name__ = "Captcha9kw" +class Captcha9Kw(Hook): + __name__ = "Captcha9Kw" __type__ = "hook" __version__ = "0.27" -- cgit v1.2.3 From 21446b75ee240f2aee137aa1998ee0184fe47bf4 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sat, 10 Jan 2015 01:51:06 +0100 Subject: [RyushareCom] Update --- module/plugins/hooks/XFileSharingPro.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/XFileSharingPro.py b/module/plugins/hooks/XFileSharingPro.py index 73cb0b0eb..0745a6c7e 100644 --- a/module/plugins/hooks/XFileSharingPro.py +++ b/module/plugins/hooks/XFileSharingPro.py @@ -8,7 +8,7 @@ from module.plugins.Hook import Hook class XFileSharingPro(Hook): __name__ = "XFileSharingPro" __type__ = "hook" - __version__ = "0.29" + __version__ = "0.30" __config__ = [("activated" , "bool", "Activated" , True ), ("use_hoster_list" , "bool", "Load listed hosters only" , False), @@ -30,8 +30,8 @@ class XFileSharingPro(Hook): HOSTER_BUILTIN = [#WORKING HOSTERS: "180upload.com", "backin.net", "eyesfile.ca", "file4safe.com", "fileband.com", "filedwon.com", - "fileparadox.in", "filevice.com", "hostingbulk.com", "linestorage.com", "ravishare.com", "salefiles.com", - "sendmyway.com", "sharesix.com", "thefile.me", "verzend.be", "xvidstage.com", + "fileparadox.in", "filevice.com", "hostingbulk.com", "linestorage.com", "ravishare.com", "ryushare.com", + "salefiles.com", "sendmyway.com", "sharesix.com", "thefile.me", "verzend.be", "xvidstage.com", #NOT TESTED: "101shared.com", "4upfiles.com", "filemaze.ws", "filenuke.com", "linkzhost.com", "mightyupload.com", "rockdizfile.com", "sharebeast.com", "sharerepo.com", "shareswift.com", "uploadbaz.com", "uploadc.com", -- cgit v1.2.3 From b617325d793a55d25f4812b1c6a7b9e656b9c73f Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sat, 10 Jan 2015 15:55:06 +0100 Subject: [RehostTo] Fix https://github.com/pyload/pyload/issues/1009 --- module/plugins/hooks/RehostTo.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/RehostTo.py b/module/plugins/hooks/RehostTo.py index 81cb26f2f..d2383cf98 100644 --- a/module/plugins/hooks/RehostTo.py +++ b/module/plugins/hooks/RehostTo.py @@ -6,7 +6,7 @@ from module.plugins.internal.MultiHook import MultiHook class RehostTo(MultiHook): __name__ = "RehostTo" __type__ = "hook" - __version__ = "0.47" + __version__ = "0.48" __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), @@ -22,15 +22,8 @@ class RehostTo(MultiHook): def getHosters(self): + user, data = self.account.selectAccount() page = self.getURL("http://rehost.to/api.php", - get={'cmd': "get_supported_och_dl", 'long_ses': self.long_ses}) + get={'cmd' : "get_supported_och_dl", + 'long_ses': self.getAccountData(user)['session']}) return [x.strip() for x in page.replace("\"", "").split(",")] - - - def coreReady(self): - super(RehostTo, self).coreReady() - - user, data = self.account.selectAccount() - - self.ses = data['ses'] - self.long_ses = data['long_ses'] -- cgit v1.2.3 From 615e713cc874ffe4a1d15b2607c67b24ab2b4297 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sat, 10 Jan 2015 17:27:00 +0100 Subject: [RehostTo] Fix typo (2) --- module/plugins/hooks/RehostTo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/RehostTo.py b/module/plugins/hooks/RehostTo.py index d2383cf98..0cb736d9c 100644 --- a/module/plugins/hooks/RehostTo.py +++ b/module/plugins/hooks/RehostTo.py @@ -6,7 +6,7 @@ from module.plugins.internal.MultiHook import MultiHook class RehostTo(MultiHook): __name__ = "RehostTo" __type__ = "hook" - __version__ = "0.48" + __version__ = "0.49" __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), @@ -25,5 +25,5 @@ class RehostTo(MultiHook): user, data = self.account.selectAccount() page = self.getURL("http://rehost.to/api.php", get={'cmd' : "get_supported_och_dl", - 'long_ses': self.getAccountData(user)['session']}) + 'long_ses': self.account.getAccountData(user)['session']}) return [x.strip() for x in page.replace("\"", "").split(",")] -- cgit v1.2.3 From 4747e1d7958c9fb1180da6f3a21f3093220a6655 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sat, 10 Jan 2015 21:17:27 +0100 Subject: Code improvements --- module/plugins/hooks/EasybytezCom.py | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/EasybytezCom.py b/module/plugins/hooks/EasybytezCom.py index c460de7b7..e08127514 100644 --- a/module/plugins/hooks/EasybytezCom.py +++ b/module/plugins/hooks/EasybytezCom.py @@ -26,18 +26,7 @@ class EasybytezCom(MultiHook): def getHosters(self): user, data = self.account.selectAccount() - try: - req = self.account.getAccountRequest(user) - page = req.load("http://www.easybytez.com") + req = self.account.getAccountRequest(user) + page = req.load("http://www.easybytez.com") - hosters = re.search(r'</textarea>\s*Supported sites:(.*)', page).group(1).split(',') - - except Exception, e: - self.logWarning(_("Unable to load supported hoster list, using last known")) - self.logDebug(e) - - hosters = ["bitshare.com", "crocko.com", "ddlstorage.com", "depositfiles.com", "extabit.com", "hotfile.com", - "mediafire.com", "netload.in", "rapidgator.net", "rapidshare.com", "uploading.com", "uload.to", - "uploaded.to"] - finally: - return hosters + return re.search(r'</textarea>\s*Supported sites:(.*)', page).group(1).split(',') -- cgit v1.2.3 From 537e181c07876352581caf892f130cd0d7152290 Mon Sep 17 00:00:00 2001 From: Shuralon <manu.aslan@live.de> Date: Sun, 11 Jan 2015 14:25:14 +0100 Subject: [RehostTo] Fix --- module/plugins/hooks/RehostTo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/RehostTo.py b/module/plugins/hooks/RehostTo.py index 0cb736d9c..653a0444e 100644 --- a/module/plugins/hooks/RehostTo.py +++ b/module/plugins/hooks/RehostTo.py @@ -6,7 +6,7 @@ from module.plugins.internal.MultiHook import MultiHook class RehostTo(MultiHook): __name__ = "RehostTo" __type__ = "hook" - __version__ = "0.49" + __version__ = "0.5" __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), @@ -25,5 +25,5 @@ class RehostTo(MultiHook): user, data = self.account.selectAccount() page = self.getURL("http://rehost.to/api.php", get={'cmd' : "get_supported_och_dl", - 'long_ses': self.account.getAccountData(user)['session']}) + 'long_ses': self.account.getAccountInfo(user)['session']}) return [x.strip() for x in page.replace("\"", "").split(",")] -- cgit v1.2.3 From 2b9e1237bed5866d0349a420d7d806fad75400c6 Mon Sep 17 00:00:00 2001 From: Steven Kosyra <steven.kosyra@googlemail.com> Date: Sun, 11 Jan 2015 15:04:07 +0100 Subject: AndroidPhoneNotify added --- module/plugins/hooks/AndroidPhoneNotify.py | 37 ++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 module/plugins/hooks/AndroidPhoneNotify.py (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/AndroidPhoneNotify.py b/module/plugins/hooks/AndroidPhoneNotify.py new file mode 100644 index 000000000..d6bf64db4 --- /dev/null +++ b/module/plugins/hooks/AndroidPhoneNotify.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- + + +from module.plugins.Hook import Hook +from module.network.RequestFactory import getURL + +class AndroidPhoneNotify(Hook): + __name__ = "AndroidPhoneNotify" + __type__ = "hook" + __version__ = "0.01" + + __config__ = [("apikey", "str", "apikey", ""), + ("appname", "str", "ApplicationName", "pyLoad"), + ("notifycaptcha", "bool", "Send captcha notifications (maybe usefull if premium fails)", False)] + + __description__ = """Send push notifications to your Android Phone using notifymyandroid.com""" + __license__ = "GPLv3" + __authors__ = [("Steven Kosyra", "steven.kosyra@gmail.com")] + + + def packageFinished(self, pypack): + self.genUrl("Package finished:",pypack.name) + + + def newCaptchaTask(self, task): + if self.getConfig("notifycaptcha"): + self.genUrl("Captcha","new Captcha request") + + + + def genUrl(self,event, msg): + self.response(event, msg) + + + + def response(self, event, msg): + html = getURL("http://www.notifymyandroid.com/publicapi/notify?apikey=" + self.getConfig("apikey") + "&application=" + self.getConfig("appname") + "&event=" + str(event) + "&description= " + str(msg) + "") -- cgit v1.2.3 From 187586c77f750340c2d8c84781c82a3e612f17c3 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sun, 11 Jan 2015 20:20:43 +0100 Subject: Fix getAccount in some plugins --- module/plugins/hooks/RehostTo.py | 2 +- module/plugins/hooks/SmoozedCom.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/RehostTo.py b/module/plugins/hooks/RehostTo.py index 653a0444e..ddb8b3eb0 100644 --- a/module/plugins/hooks/RehostTo.py +++ b/module/plugins/hooks/RehostTo.py @@ -6,7 +6,7 @@ from module.plugins.internal.MultiHook import MultiHook class RehostTo(MultiHook): __name__ = "RehostTo" __type__ = "hook" - __version__ = "0.5" + __version__ = "0.50" __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), diff --git a/module/plugins/hooks/SmoozedCom.py b/module/plugins/hooks/SmoozedCom.py index 4e706c959..9ba2daac9 100644 --- a/module/plugins/hooks/SmoozedCom.py +++ b/module/plugins/hooks/SmoozedCom.py @@ -6,7 +6,7 @@ from module.plugins.internal.MultiHook import MultiHook class SmoozedCom(MultiHook): __name__ = "SmoozedCom" __type__ = "hook" - __version__ = "0.02" + __version__ = "0.03" __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), @@ -23,4 +23,4 @@ class SmoozedCom(MultiHook): def getHosters(self): user, data = self.account.selectAccount() - return self.account.getAccountData(user)["hosters"] + return self.account.getAccountInfo(user)["hosters"] -- cgit v1.2.3 From 1bf6adf3f1f9720333c1b1352de37898a153c409 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sun, 11 Jan 2015 21:51:52 +0100 Subject: Update notify addons --- module/plugins/hooks/AndroidPhoneNotify.py | 70 +++++++++++++++---- module/plugins/hooks/WindowsPhoneToastNotify.py | 91 ++++++++++++++++--------- 2 files changed, 116 insertions(+), 45 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/AndroidPhoneNotify.py b/module/plugins/hooks/AndroidPhoneNotify.py index d6bf64db4..18e1cce66 100644 --- a/module/plugins/hooks/AndroidPhoneNotify.py +++ b/module/plugins/hooks/AndroidPhoneNotify.py @@ -1,37 +1,79 @@ # -*- coding: utf-8 -*- +from time import time -from module.plugins.Hook import Hook from module.network.RequestFactory import getURL +from module.plugins.Hook import Hook + class AndroidPhoneNotify(Hook): __name__ = "AndroidPhoneNotify" __type__ = "hook" - __version__ = "0.01" + __version__ = "0.02" - __config__ = [("apikey", "str", "apikey", ""), - ("appname", "str", "ApplicationName", "pyLoad"), - ("notifycaptcha", "bool", "Send captcha notifications (maybe usefull if premium fails)", False)] + __config__ = [("apikey" , "str" , "API key" , "" ), + ("notifycaptcha" , "bool", "Notify captcha request" , True ), + ("notifypackage" , "bool", "Notify package finished" , True ), + ("notifyprocessed", "bool", "Notify processed packages status" , True ), + ("timeout" , "int" , "Timeout between captchas in seconds" , 5 ), + ("force" , "bool", "Send notifications if client is connected", False)] __description__ = """Send push notifications to your Android Phone using notifymyandroid.com""" __license__ = "GPLv3" - __authors__ = [("Steven Kosyra", "steven.kosyra@gmail.com")] + __authors__ = [("Steven Kosyra", "steven.kosyra@gmail.com"), + ("Walter Purcaro", "vuolter@gmail.com")] - def packageFinished(self, pypack): - self.genUrl("Package finished:",pypack.name) + event_list = ["allDownloadsProcessed"] + + + #@TODO: Remove in 0.4.10 + def initPeriodical(self): + pass + + + def setup(self): + self.info = {} #@TODO: Remove in 0.4.10 def newCaptchaTask(self, task): - if self.getConfig("notifycaptcha"): - self.genUrl("Captcha","new Captcha request") + if not self.getConfig("notifycaptcha"): + return False + + if time() - float(self.getStorage("AndroidPhoneNotify", 0)) < self.getConf("timeout"): + return False + + self.notify(_("Captcha"), _("New request waiting user input")) + + + def packageFinished(self, pypack): + if self.getConfig("notifypackage"): + self.notify(_("Package finished"), pypack.name) + + + def allDownloadsProcessed(self, thread): + if not self.getConfig("notifyprocessed"): + return False + + if any(True for pdata in self.core.api.getQueue() if pdata.linksdone < pdata.linkstotal): + self.notify(_("Package failed"), _("One or more packages was not completed successfully")) + else: + self.notify(_("All packages finished")) + def notify(self, event, msg=""): + apikey = self.getConfig("apikey") - def genUrl(self,event, msg): - self.response(event, msg) + if not apikey: + return False + if self.core.isClientConnected() and not self.getConfig("force"): + return False + getURL("http://www.notifymyandroid.com/publicapi/notify", + get={'apikey' : apikey, + 'application': "pyLoad", + 'event' : event, + 'description': msg}) - def response(self, event, msg): - html = getURL("http://www.notifymyandroid.com/publicapi/notify?apikey=" + self.getConfig("apikey") + "&application=" + self.getConfig("appname") + "&event=" + str(event) + "&description= " + str(msg) + "") + self.setStorage("AndroidPhoneNotify", time()) diff --git a/module/plugins/hooks/WindowsPhoneToastNotify.py b/module/plugins/hooks/WindowsPhoneToastNotify.py index ed305778c..886d4ca6a 100644 --- a/module/plugins/hooks/WindowsPhoneToastNotify.py +++ b/module/plugins/hooks/WindowsPhoneToastNotify.py @@ -1,7 +1,8 @@ # -*- coding: utf-8 -*- import httplib -import time + +from time import time from module.plugins.Hook import Hook @@ -9,16 +10,23 @@ from module.plugins.Hook import Hook class WindowsPhoneToastNotify(Hook): __name__ = "WindowsPhoneToastNotify" __type__ = "hook" - __version__ = "0.03" + __version__ = "0.04" - __config__ = [("force", "bool", "Force even if client is connected", False), - ("pushId", "str", "pushId", ""), - ("pushUrl", "str", "pushUrl", ""), - ("pushTimeout", "int", "Timeout between notifications in seconds", 0)] + __config__ = [("id" , "str" , "Push ID" , "" ), + ("url" , "str" , "Push url" , "" ), + ("notifycaptcha" , "bool", "Notify captcha request" , True ), + ("notifypackage" , "bool", "Notify package finished" , True ), + ("notifyprocessed", "bool", "Notify processed packages status" , True ), + ("timeout" , "int" , "Timeout between captchas in seconds" , 5 ), + ("force" , "bool", "Send notifications if client is connected", False)] __description__ = """Send push notifications to Windows Phone""" __license__ = "GPLv3" - __authors__ = [("Andy Voigt", "phone-support@hotmail.de")] + __authors__ = [("Andy Voigt", "phone-support@hotmail.de"), + ("Walter Purcaro", "vuolter@gmail.com")] + + + event_list = ["allDownloadsProcessed"] #@TODO: Remove in 0.4.10 @@ -30,37 +38,58 @@ class WindowsPhoneToastNotify(Hook): self.info = {} #@TODO: Remove in 0.4.10 - 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 newCaptchaTask(self, task): + if not self.getConfig("notifycaptcha"): + return False + if time() - float(self.getStorage("WindowsPhoneToastNotify", 0)) < self.getConf("timeout"): + return False - def doRequest(self): - URL = self.getConfig("pushUrl") - request = self.getXmlData() - webservice = httplib.HTTP(URL) - webservice.putrequest("POST", self.getConfig("pushId")) - webservice.putheader("Host", URL) - webservice.putheader("Content-type", "text/xml") - webservice.putheader("X-NotificationClass", "2") - webservice.putheader("X-WindowsPhone-Target", "toast") - webservice.putheader("Content-length", "%d" % len(request)) - webservice.endheaders() - webservice.send(request) - webservice.close() - self.setStorage("LAST_NOTIFY", time.time()) + self.notify(_("Captcha"), _("New request waiting user input")) - def newCaptchaTask(self, task): - if not self.getConfig("pushId") or not self.getConfig("pushUrl"): + def packageFinished(self, pypack): + if self.getConfig("notifypackage"): + self.notify(_("Package finished"), pypack.name) + + + def allDownloadsProcessed(self, thread): + if not self.getConfig("notifyprocessed"): return False - if self.core.isClientConnected() and not self.getConfig("force"): + if any(True for pdata in self.core.api.getQueue() if pdata.linksdone < pdata.linkstotal): + self.notify(_("Package failed"), _("One or more packages was not completed successfully")) + else: + self.notify(_("All packages finished")) + + + def getXmlData(self, msg): + return ("<?xml version='1.0' encoding='utf-8'?> <wp:Notification xmlns:wp='WPNotification'> " + "<wp:Toast> <wp:Text1>pyLoad</wp:Text1> <wp:Text2>%s</wp:Text2> " + "</wp:Toast> </wp:Notification>" % msg) + + + def notify(self, event, msg=""): + id = self.getConfig("id") + url = self.getConfig("url") + + if not id or not url: return False - if (time.time() - float(self.getStorage("LAST_NOTIFY", 0))) < self.getConf("pushTimeout"): + if self.core.isClientConnected() and not self.getConfig("force"): return False - self.doRequest() + request = self.getXmlData("%s: %s" % (event, msg) if msg else event) + webservice = httplib.HTTP(url) + + webservice.putrequest("POST", id) + webservice.putheader("Host", url) + webservice.putheader("Content-type", "text/xml") + webservice.putheader("X-NotificationClass", "2") + webservice.putheader("X-WindowsPhone-Target", "toast") + webservice.putheader("Content-length", "%d" % len(request)) + webservice.endheaders() + webservice.send(request) + webservice.close() + + self.setStorage("WindowsPhoneToastNotify", time()) -- cgit v1.2.3 From 184ea88c7322399a04ab80a6d509ce446b83d966 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sun, 11 Jan 2015 21:52:22 +0100 Subject: [ExternalScripts] Fixup --- module/plugins/hooks/ExternalScripts.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index a35e47c03..fc0cae44f 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -13,7 +13,7 @@ from module.utils import save_join class ExternalScripts(Hook): __name__ = "ExternalScripts" __type__ = "hook" - __version__ = "0.25" + __version__ = "0.26" __config__ = [("activated", "bool", "Activated", True)] @@ -136,11 +136,11 @@ class ExternalScripts(Hook): self.callScript(script) - def allDownloadsFinished(self): + def allDownloadsFinished(self, thread): for script in chain(self.scripts['all_downloads_finished'], self.scripts['all_dls_finished']): self.callScript(script) - def allDownloadsProcessed(self): + def allDownloadsProcessed(self, thread): for script in chain(self.scripts['all_downloads_processed'], self.scripts['all_dls_processed']): self.callScript(script) -- cgit v1.2.3 From e3bdcffc6020322d9f8985c6f6be9476e8c779c9 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sun, 11 Jan 2015 23:20:32 +0100 Subject: [SkipRev] Fix https://github.com/pyload/pyload/issues/1036 --- module/plugins/hooks/SkipRev.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py index ad6d7dacd..6b4e715da 100644 --- a/module/plugins/hooks/SkipRev.py +++ b/module/plugins/hooks/SkipRev.py @@ -18,7 +18,7 @@ def _setup(self): class SkipRev(Hook): __name__ = "SkipRev" __type__ = "hook" - __version__ = "0.22" + __version__ = "0.23" __config__ = [("tokeep", "int", "Number of rev files to keep for package (-1 to auto)", -1)] @@ -34,7 +34,7 @@ class SkipRev(Hook): def _pyname(self, pyfile): if hasattr(pyfile.pluginmodule, "getInfo"): - return getattr(pyfile.pluginmodule, "getInfo")([pyfile.url])[0][0] + return next(getattr(pyfile.pluginmodule, "getInfo")([pyfile.url]))[0] else: self.logWarning("Unable to grab file name") return urlparse(unquote(pyfile.url)).path.split('/')[-1] -- cgit v1.2.3 From 7e5e88778c2dd4fac088cffbd2fba4384dde8582 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Tue, 13 Jan 2015 01:45:31 +0100 Subject: [ClickAndLoad] Fix error "Port already in use" --- module/plugins/hooks/ClickAndLoad.py | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 8ef31ec1e..222310c25 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -3,6 +3,7 @@ import socket from threading import Thread, Lock +from time import sleep from module.plugins.Hook import Hook, threaded @@ -20,7 +21,7 @@ def forward(source, destination): class ClickAndLoad(Hook): __name__ = "ClickAndLoad" __type__ = "hook" - __version__ = "0.25" + __version__ = "0.26" __config__ = [("activated", "bool", "Activated" , True ), ("port" , "int" , "Port" , 9666 ), @@ -54,6 +55,8 @@ class ClickAndLoad(Hook): def server(self, ip, webport, cnlport): try: dock_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + + dock_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) dock_socket.bind((ip, cnlport)) dock_socket.listen(5) @@ -65,17 +68,8 @@ class ClickAndLoad(Hook): hookManager.startThread(forward, client_socket, server_socket) except socket.error, e: - if hasattr(e, "errno"): - errno = e.errno - else: - errno = e.args[0] - - if errno == 98: - self.logWarning(_("Port %s already in use") % cnlport) - else: - self.logError(e) - self.server(ip, webport, cnlport) - - except Exception, e: self.logError(e) self.server(ip, webport, cnlport) + + finally: + dock_socket.close() -- cgit v1.2.3 From e1baccf1ec914563d3b2b845906cce024e7cd3b1 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Tue, 13 Jan 2015 23:14:50 +0100 Subject: Replace 'except' with 'except Exception' --- module/plugins/hooks/ExternalScripts.py | 2 +- module/plugins/hooks/IRCInterface.py | 8 ++++---- module/plugins/hooks/ImageTyperz.py | 2 +- module/plugins/hooks/UpdateManager.py | 4 ++-- module/plugins/hooks/XMPPInterface.py | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index fc0cae44f..f4d2cb69c 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -59,7 +59,7 @@ class ExternalScripts(Hook): if not exists(path): try: makedirs(path) - except: + except Exception: self.logDebug("Script folder %s not created" % folder) return diff --git a/module/plugins/hooks/IRCInterface.py b/module/plugins/hooks/IRCInterface.py index efd4e411d..98fa1d030 100644 --- a/module/plugins/hooks/IRCInterface.py +++ b/module/plugins/hooks/IRCInterface.py @@ -61,7 +61,7 @@ class IRCInterface(Thread, Hook): try: if self.getConfig("info_pack"): self.response(_("Package finished: %s") % pypack.name) - except: + except Exception: pass @@ -70,7 +70,7 @@ class IRCInterface(Thread, Hook): if self.getConfig("info_file"): self.response( _("Download finished: %(name)s @ %(plugin)s ") % {"name": pyfile.name, "plugin": pyfile.pluginname}) - except: + except Exception: pass @@ -183,7 +183,7 @@ class IRCInterface(Thread, Hook): trigger = temp[0] if len(temp) > 1: args = temp[1:] - except: + except Exception: pass handler = getattr(self, "event_%s" % trigger, self.event_pass) @@ -347,7 +347,7 @@ class IRCInterface(Thread, Hook): return ["INFO: Added %d links to Package %s [#%d]" % (len(links), pack['name'], id)] - except: + except Exception: # create new package id = self.core.api.addPackage(pack, links, 1) return ["INFO: Created new Package %s [#%d] with %d links." % (pack, id, len(links))] diff --git a/module/plugins/hooks/ImageTyperz.py b/module/plugins/hooks/ImageTyperz.py index d448d1be9..768129e4a 100644 --- a/module/plugins/hooks/ImageTyperz.py +++ b/module/plugins/hooks/ImageTyperz.py @@ -69,7 +69,7 @@ class ImageTyperz(Hook): try: balance = float(res) - except: + except Exception: raise ImageTyperzException("Invalid response") self.logInfo(_("Account balance: $%s left") % res) diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index c72699228..03b9ba6a4 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -117,7 +117,7 @@ class UpdateManager(Hook): def server_request(self): try: return getURL(self.SERVER_URL, get={'v': self.core.api.getServerVersion()}).splitlines() - except: + except Exception: self.logWarning(_("Unable to contact server to get updates")) @@ -192,7 +192,7 @@ class UpdateManager(Hook): # Protect UpdateManager from self-removing try: blacklisted.remove(("hook", "UpdateManager")) - except: + except Exception: pass for t, n in blacklisted: diff --git a/module/plugins/hooks/XMPPInterface.py b/module/plugins/hooks/XMPPInterface.py index bbeab4341..b8e9fc1ad 100644 --- a/module/plugins/hooks/XMPPInterface.py +++ b/module/plugins/hooks/XMPPInterface.py @@ -69,7 +69,7 @@ class XMPPInterface(IRCInterface, JabberClient): try: if self.getConfig("info_pack"): self.announce(_("Package finished: %s") % pypack.name) - except: + except Exception: pass @@ -78,7 +78,7 @@ class XMPPInterface(IRCInterface, JabberClient): if self.getConfig("info_file"): self.announce( _("Download finished: %(name)s @ %(plugin)s") % {"name": pyfile.name, "plugin": pyfile.pluginname}) - except: + except Exception: pass @@ -152,7 +152,7 @@ class XMPPInterface(IRCInterface, JabberClient): trigger = temp[0] if len(temp) > 1: args = temp[1:] - except: + except Exception: pass handler = getattr(self, "event_%s" % trigger, self.event_pass) -- cgit v1.2.3 From 660ddd365b0ee18609e05e6babe55f272bd3becd Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Tue, 13 Jan 2015 23:15:42 +0100 Subject: [XFileSharingPro] Update BUILTIN lists --- module/plugins/hooks/XFileSharingPro.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/XFileSharingPro.py b/module/plugins/hooks/XFileSharingPro.py index 0745a6c7e..e6e30ca8f 100644 --- a/module/plugins/hooks/XFileSharingPro.py +++ b/module/plugins/hooks/XFileSharingPro.py @@ -8,7 +8,7 @@ from module.plugins.Hook import Hook class XFileSharingPro(Hook): __name__ = "XFileSharingPro" __type__ = "hook" - __version__ = "0.30" + __version__ = "0.31" __config__ = [("activated" , "bool", "Activated" , True ), ("use_hoster_list" , "bool", "Load listed hosters only" , False), @@ -30,15 +30,15 @@ class XFileSharingPro(Hook): HOSTER_BUILTIN = [#WORKING HOSTERS: "180upload.com", "backin.net", "eyesfile.ca", "file4safe.com", "fileband.com", "filedwon.com", - "fileparadox.in", "filevice.com", "hostingbulk.com", "linestorage.com", "ravishare.com", "ryushare.com", - "salefiles.com", "sendmyway.com", "sharesix.com", "thefile.me", "verzend.be", "xvidstage.com", + "fileparadox.in", "filevice.com", "hostingbulk.com", "junkyvideo.com", "linestorage.com", "ravishare.com", + "ryushare.com", "salefiles.com", "sendmyway.com", "sharesix.com", "thefile.me", "verzend.be", "xvidstage.com", #NOT TESTED: "101shared.com", "4upfiles.com", "filemaze.ws", "filenuke.com", "linkzhost.com", "mightyupload.com", "rockdizfile.com", "sharebeast.com", "sharerepo.com", "shareswift.com", "uploadbaz.com", "uploadc.com", "vidbull.com", "zalaa.com", "zomgupload.com", #NOT WORKING: "amonshare.com", "banicrazy.info", "boosterking.com", "host4desi.com", "laoupload.com", "rd-fs.com"] - CRYPTER_BUILTIN = [] + CRYPTER_BUILTIN = ["junocloud.me", "rapidfileshare.net"] # def pluginConfigChanged(self.__name__, plugin, name, value): -- cgit v1.2.3 From 0b73c1b042a2b1e17f30c951626586f8774c68ed Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Fri, 16 Jan 2015 01:14:47 +0100 Subject: [SkipRev] Fix https://github.com/pyload/pyload/issues/1048 --- module/plugins/hooks/SkipRev.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py index 6b4e715da..51d385bb4 100644 --- a/module/plugins/hooks/SkipRev.py +++ b/module/plugins/hooks/SkipRev.py @@ -18,7 +18,7 @@ def _setup(self): class SkipRev(Hook): __name__ = "SkipRev" __type__ = "hook" - __version__ = "0.23" + __version__ = "0.24" __config__ = [("tokeep", "int", "Number of rev files to keep for package (-1 to auto)", -1)] @@ -34,7 +34,7 @@ class SkipRev(Hook): def _pyname(self, pyfile): if hasattr(pyfile.pluginmodule, "getInfo"): - return next(getattr(pyfile.pluginmodule, "getInfo")([pyfile.url]))[0] + return getattr(pyfile.pluginmodule, "getInfo")([pyfile.url]).next()[0] else: self.logWarning("Unable to grab file name") return urlparse(unquote(pyfile.url)).path.split('/')[-1] -- cgit v1.2.3 From e2d8d605aeb4fd3477a8d681e16cd0b17500a648 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Fri, 16 Jan 2015 01:36:04 +0100 Subject: Fix allDownloadsFinished and allDownloadsProcessed defs --- module/plugins/hooks/AndroidPhoneNotify.py | 4 +-- module/plugins/hooks/ExternalScripts.py | 6 ++-- module/plugins/hooks/ExtractArchive.py | 42 ++++++++++++------------- module/plugins/hooks/WindowsPhoneToastNotify.py | 4 +-- 4 files changed, 28 insertions(+), 28 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/AndroidPhoneNotify.py b/module/plugins/hooks/AndroidPhoneNotify.py index 18e1cce66..fbc2acd5c 100644 --- a/module/plugins/hooks/AndroidPhoneNotify.py +++ b/module/plugins/hooks/AndroidPhoneNotify.py @@ -9,7 +9,7 @@ from module.plugins.Hook import Hook class AndroidPhoneNotify(Hook): __name__ = "AndroidPhoneNotify" __type__ = "hook" - __version__ = "0.02" + __version__ = "0.03" __config__ = [("apikey" , "str" , "API key" , "" ), ("notifycaptcha" , "bool", "Notify captcha request" , True ), @@ -51,7 +51,7 @@ class AndroidPhoneNotify(Hook): self.notify(_("Package finished"), pypack.name) - def allDownloadsProcessed(self, thread): + def allDownloadsProcessed(self): if not self.getConfig("notifyprocessed"): return False diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index f4d2cb69c..b2b4548a2 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -13,7 +13,7 @@ from module.utils import save_join class ExternalScripts(Hook): __name__ = "ExternalScripts" __type__ = "hook" - __version__ = "0.26" + __version__ = "0.27" __config__ = [("activated", "bool", "Activated", True)] @@ -136,11 +136,11 @@ class ExternalScripts(Hook): self.callScript(script) - def allDownloadsFinished(self, thread): + def allDownloadsFinished(self): for script in chain(self.scripts['all_downloads_finished'], self.scripts['all_dls_finished']): self.callScript(script) - def allDownloadsProcessed(self, thread): + def allDownloadsProcessed(self): for script in chain(self.scripts['all_downloads_processed'], self.scripts['all_dls_processed']): self.callScript(script) diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 2e9efa2b0..bdbaf64af 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -58,7 +58,7 @@ from module.utils import save_join, uniqify class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.03" + __version__ = "1.04" __config__ = [("activated" , "bool" , "Activated" , True ), ("fullpath" , "bool" , "Extract full path" , True ), @@ -158,7 +158,7 @@ class ExtractArchive(Hook): @threaded - def allDownloadsProcessed(self, thread): + def allDownloadsProcessed(self): local = copy(self.queue) self.queue[:] = [] @@ -302,36 +302,36 @@ class ExtractArchive(Hook): try: progress = lambda x: pyfile.setProgress(x) - encrypted = False + encrypted = True #@TODO: set to `False` passwords = self.getPasswords() - try: - self.logInfo(basename(plugin.file), "Verifying...") + # try: + # self.logInfo(basename(plugin.file), "Verifying...") - tmp_password = plugin.password - plugin.password = "" #: Force verifying without password + # tmp_password = plugin.password + # plugin.password = "" #: Force verifying without password - plugin.verify() + # plugin.verify() - except PasswordError: - encrypted = True + # except PasswordError: + # encrypted = True - except CRCError: - self.logWarning(basename(plugin.file), _("Archive damaged")) + # except CRCError: + # self.logWarning(basename(plugin.file), _("Archive damaged")) - if not self.getConfig("repair"): - raise CRCError + # if not self.getConfig("repair"): + # raise CRCError - elif plugin.repair(): - self.logInfo(basename(plugin.file), _("Successfully repaired")) + # elif plugin.repair(): + # self.logInfo(basename(plugin.file), _("Successfully repaired")) - elif not self.getConfig("keepbroken"): - raise ArchiveError(_("Broken archive")) + # elif not self.getConfig("keepbroken"): + # raise ArchiveError(_("Broken archive")) - else: - self.logInfo(basename(plugin.file), _("All OK")) + # else: + # self.logInfo(basename(plugin.file), _("All OK")) - plugin.password = tmp_password + # plugin.password = tmp_password if not encrypted: plugin.extract(progress) diff --git a/module/plugins/hooks/WindowsPhoneToastNotify.py b/module/plugins/hooks/WindowsPhoneToastNotify.py index 886d4ca6a..20686ee36 100644 --- a/module/plugins/hooks/WindowsPhoneToastNotify.py +++ b/module/plugins/hooks/WindowsPhoneToastNotify.py @@ -10,7 +10,7 @@ from module.plugins.Hook import Hook class WindowsPhoneToastNotify(Hook): __name__ = "WindowsPhoneToastNotify" __type__ = "hook" - __version__ = "0.04" + __version__ = "0.05" __config__ = [("id" , "str" , "Push ID" , "" ), ("url" , "str" , "Push url" , "" ), @@ -53,7 +53,7 @@ class WindowsPhoneToastNotify(Hook): self.notify(_("Package finished"), pypack.name) - def allDownloadsProcessed(self, thread): + def allDownloadsProcessed(self): if not self.getConfig("notifyprocessed"): return False -- cgit v1.2.3 From b205352a18db19f9fccb2f8dd73a12e6e87ef58d Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Fri, 16 Jan 2015 01:37:19 +0100 Subject: [LinkdecrypterCom] Improve getCrypters routine --- module/plugins/hooks/LinkdecrypterCom.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/LinkdecrypterCom.py b/module/plugins/hooks/LinkdecrypterCom.py index d4924a687..f85a598bc 100644 --- a/module/plugins/hooks/LinkdecrypterCom.py +++ b/module/plugins/hooks/LinkdecrypterCom.py @@ -8,7 +8,7 @@ from module.plugins.internal.MultiHook import MultiHook class LinkdecrypterCom(MultiHook): __name__ = "LinkdecrypterCom" __type__ = "hook" - __version__ = "1.01" + __version__ = "1.02" __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), @@ -21,8 +21,5 @@ class LinkdecrypterCom(MultiHook): def getCrypters(self): - try: - html = self.getURL("http://linkdecrypter.com/") - return re.search(r'>Supported\(\d+\)</b>: <i>(.+?) \+ RSDF', html).group(1).split(', ') - except Exception: - return list() + return re.search(r'>Supported\(\d+\)</b>: <i>(.[\w.\-, ]+)', + self.getURL("http://linkdecrypter.com/").replace("(g)", "")).group(1).split(', ') -- cgit v1.2.3 From b72f8fb3d564feb3881d43c2956b1adc238e8b54 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Fri, 16 Jan 2015 15:46:59 +0100 Subject: [UpdateManager] Default to check for updates in debug mode --- module/plugins/hooks/UpdateManager.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index 03b9ba6a4..b6a8bac7c 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -16,14 +16,14 @@ from module.utils import save_join class UpdateManager(Hook): __name__ = "UpdateManager" __type__ = "hook" - __version__ = "0.42" + __version__ = "0.43" __config__ = [("activated" , "bool" , "Activated" , True ), ("mode" , "pyLoad + plugins;plugins only", "Check updates for" , "pyLoad + plugins"), ("interval" , "int" , "Check interval in hours" , 8 ), ("autorestart" , "bool" , "Automatically restart pyLoad when required" , True ), ("reloadplugins", "bool" , "Monitor plugins for code changes in debug mode", True ), - ("nodebugupdate", "bool" , "Don't check for updates in debug mode" , True )] + ("nodebugupdate", "bool" , "Don't check for updates in debug mode" , False )] __description__ = """ Check for updates """ __license__ = "GPLv3" -- cgit v1.2.3 From c4f167e267ba949ee20ec8a6d3c611d6dd93b325 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Tue, 20 Jan 2015 01:22:00 +0100 Subject: Fix plugin filename case --- module/plugins/hooks/Captcha9Kw.py | 261 +++++++++++++++++++++++++++++++++++++ module/plugins/hooks/Captcha9kw.py | 261 ------------------------------------- 2 files changed, 261 insertions(+), 261 deletions(-) create mode 100644 module/plugins/hooks/Captcha9Kw.py delete mode 100755 module/plugins/hooks/Captcha9kw.py (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/Captcha9Kw.py b/module/plugins/hooks/Captcha9Kw.py new file mode 100644 index 000000000..600694e78 --- /dev/null +++ b/module/plugins/hooks/Captcha9Kw.py @@ -0,0 +1,261 @@ +# -*- coding: utf-8 -*- + +from __future__ import with_statement + +import re + +from base64 import b64encode +from time import sleep + +from module.network.HTTPRequest import BadHeader +from module.network.RequestFactory import getURL + +from module.plugins.Hook import Hook, threaded + + +class Captcha9Kw(Hook): + __name__ = "Captcha9Kw" + __type__ = "hook" + __version__ = "0.27" + + __config__ = [("activated" , "bool" , "Activated" , True ), + ("ssl" , "bool" , "Use HTTPS" , True ), + ("force" , "bool" , "Force captcha resolving even if client is connected" , True ), + ("confirm" , "bool" , "Confirm Captcha (cost +6 credits)" , False ), + ("captchaperhour", "int" , "Captcha per hour" , "9999" ), + ("captchapermin" , "int" , "Captcha per minute" , "9999" ), + ("prio" , "int" , "Priority (max 10)(cost +0 -> +10 credits)" , "0" ), + ("queue" , "int" , "Max. Queue (max 999)" , "50" ), + ("hoster_options", "string" , "Hoster options (format: pluginname:prio=1:selfsolfe=1:confirm=1:timeout=900|...)", "ShareonlineBiz:prio=0:timeout=999 | UploadedTo:prio=0:timeout=999"), + ("selfsolve" , "bool" , "Selfsolve (manually solve your captcha in your 9kw client if active)" , "0" ), + ("passkey" , "password", "API key" , "" ), + ("timeout" , "int" , "Timeout in seconds (min 60, max 3999)" , "900" )] + + __description__ = """Send captchas to 9kw.eu""" + __license__ = "GPLv3" + __authors__ = [("RaNaN", "RaNaN@pyload.org"), + ("Walter Purcaro", "vuolter@gmail.com")] + + + API_URL = "http://www.9kw.eu/index.cgi" + + + #@TODO: Remove in 0.4.10 + def initPeriodical(self): + pass + + + def setup(self): + self.info = {} #@TODO: Remove in 0.4.10 + if self.getConfig("ssl"): + self.API_URL = self.API_URL.replace("http://", "https://") + + + def getCredits(self): + res = getURL(self.API_URL, + get={'apikey': self.getConfig("passkey"), + 'pyload': "1", + 'source': "pyload", + 'action': "usercaptchaguthaben"}) + + if res.isdigit(): + self.logInfo(_("%s credits left") % res) + credits = self.info['credits'] = int(res) + return credits + else: + self.logError(res) + return 0 + + + @threaded + def _processCaptcha(self, task): + try: + with open(task.captchaFile, 'rb') as f: + data = f.read() + + except IOError, e: + self.logError(e) + return + + data = b64encode(data) + mouse = 1 if task.isPositional() else 0 + pluginname = re.search(r'_([^_]*)_\d+.\w+', task.captchaFile).group(1) + + option = {'min' : 2, + 'max' : 50, + 'phrase' : 0, + 'numeric' : 0, + 'case_sensitive': 0, + 'math' : 0, + 'prio' : min(max(self.getConfig("prio"), 0), 10), + 'confirm' : self.getConfig("confirm"), + 'timeout' : min(max(self.getConfig("timeout"), 300), 3999), + 'selfsolve' : self.getConfig("selfsolve"), + 'cph' : self.getConfig("captchaperhour"), + 'cpm' : self.getConfig("captchapermin")} + + for opt in str(self.getConfig("hoster_options").split('|')): + + details = map(str.strip, opt.split(':')) + + if not details or details[0].lower() != pluginname.lower(): + continue + + for d in details: + hosteroption = d.split("=") + + if len(hosteroption) < 2 or not hosteroption[1].isdigit(): + continue + + o = hosteroption[0].lower() + if o in option: + option[o] = hosteroption[1] + + break + + post_data = {'apikey' : self.getConfig("passkey"), + 'prio' : option['prio'], + 'confirm' : option['confirm'], + 'maxtimeout' : option['timeout'], + 'selfsolve' : option['selfsolve'], + 'captchaperhour': option['cph'], + 'captchapermin' : option['cpm'], + 'case-sensitive': option['case_sensitive'], + 'min_len' : option['min'], + 'max_len' : option['max'], + 'phrase' : option['phrase'], + 'numeric' : option['numeric'], + 'math' : option['math'], + 'oldsource' : pluginname, + 'pyload' : "1", + 'source' : "pyload", + 'base64' : "1", + 'mouse' : mouse, + 'file-upload-01': data, + 'action' : "usercaptchaupload"} + + for _i in xrange(5): + try: + res = getURL(self.API_URL, post=post_data) + except BadHeader, e: + sleep(3) + else: + if res and res.isdigit(): + break + else: + self.logError(_("Bad upload: %s") % res) + return + + self.logDebug(_("NewCaptchaID ticket: %s") % res, task.captchaFile) + + task.data["ticket"] = res + + for _i in xrange(int(self.getConfig("timeout") / 5)): + result = getURL(self.API_URL, + get={'apikey': self.getConfig("passkey"), + 'id' : res, + 'pyload': "1", + 'info' : "1", + 'source': "pyload", + 'action': "usercaptchacorrectdata"}) + + if not result or result == "NO DATA": + sleep(5) + else: + break + else: + self.logDebug("Could not send request: %s" % res) + result = None + + self.logInfo(_("Captcha result for ticket %s: %s") % (res, result)) + + task.setResult(result) + + + def newCaptchaTask(self, task): + if not task.isTextual() and not task.isPositional(): + return + + if not self.getConfig("passkey"): + return + + if self.core.isClientConnected() and not self.getConfig("force"): + return + + credits = self.getCredits() + + if not credits: + self.logError(_("Your captcha 9kw.eu account has not enough credits")) + return + + queue = min(self.getConfig("queue"), 999) + timeout = min(max(self.getConfig("timeout"), 300), 3999) + pluginname = re.search(r'_([^_]*)_\d+.\w+', task.captchaFile).group(1) + + for _i in xrange(5): + servercheck = getURL("http://www.9kw.eu/grafik/servercheck.txt") + if queue < re.search(r'queue=(\d+)', servercheck).group(1): + break + + sleep(10) + else: + self.fail(_("Too many captchas in queue")) + + for opt in str(self.getConfig("hoster_options").split('|')): + details = map(str.strip, opt.split(':')) + + if not details or details[0].lower() != pluginname.lower(): + continue + + for d in details: + hosteroption = d.split("=") + + if (len(hosteroption) > 1 + and hosteroption[0].lower() == 'timeout' + and hosteroption[1].isdigit()): + timeout = int(hosteroption[1]) + + break + + task.handler.append(self) + + task.setWaiting(timeout) + + self._processCaptcha(task) + + + def _captchaResponse(self, task, correct): + type = "correct" if correct else "refund" + + if 'ticket' not in task.data: + self.logDebug("No CaptchaID for %s request (task: %s)" % (type, task)) + return + + passkey = self.getConfig("passkey") + + for _i in xrange(3): + res = getURL(self.API_URL, + get={'action' : "usercaptchacorrectback", + 'apikey' : passkey, + 'api_key': passkey, + 'correct': "1" if correct else "2", + 'pyload' : "1", + 'source' : "pyload", + 'id' : task.data["ticket"]}) + + self.logDebug("Request %s: %s" % (type, res)) + + if res == "OK": + break + + sleep(5) + else: + self.logDebug("Could not send %s request: %s" % (type, res)) + + + def captchaCorrect(self, task): + self._captchaResponse(task, True) + + + def captchaInvalid(self, task): + self._captchaResponse(task, False) diff --git a/module/plugins/hooks/Captcha9kw.py b/module/plugins/hooks/Captcha9kw.py deleted file mode 100755 index 600694e78..000000000 --- a/module/plugins/hooks/Captcha9kw.py +++ /dev/null @@ -1,261 +0,0 @@ -# -*- coding: utf-8 -*- - -from __future__ import with_statement - -import re - -from base64 import b64encode -from time import sleep - -from module.network.HTTPRequest import BadHeader -from module.network.RequestFactory import getURL - -from module.plugins.Hook import Hook, threaded - - -class Captcha9Kw(Hook): - __name__ = "Captcha9Kw" - __type__ = "hook" - __version__ = "0.27" - - __config__ = [("activated" , "bool" , "Activated" , True ), - ("ssl" , "bool" , "Use HTTPS" , True ), - ("force" , "bool" , "Force captcha resolving even if client is connected" , True ), - ("confirm" , "bool" , "Confirm Captcha (cost +6 credits)" , False ), - ("captchaperhour", "int" , "Captcha per hour" , "9999" ), - ("captchapermin" , "int" , "Captcha per minute" , "9999" ), - ("prio" , "int" , "Priority (max 10)(cost +0 -> +10 credits)" , "0" ), - ("queue" , "int" , "Max. Queue (max 999)" , "50" ), - ("hoster_options", "string" , "Hoster options (format: pluginname:prio=1:selfsolfe=1:confirm=1:timeout=900|...)", "ShareonlineBiz:prio=0:timeout=999 | UploadedTo:prio=0:timeout=999"), - ("selfsolve" , "bool" , "Selfsolve (manually solve your captcha in your 9kw client if active)" , "0" ), - ("passkey" , "password", "API key" , "" ), - ("timeout" , "int" , "Timeout in seconds (min 60, max 3999)" , "900" )] - - __description__ = """Send captchas to 9kw.eu""" - __license__ = "GPLv3" - __authors__ = [("RaNaN", "RaNaN@pyload.org"), - ("Walter Purcaro", "vuolter@gmail.com")] - - - API_URL = "http://www.9kw.eu/index.cgi" - - - #@TODO: Remove in 0.4.10 - def initPeriodical(self): - pass - - - def setup(self): - self.info = {} #@TODO: Remove in 0.4.10 - if self.getConfig("ssl"): - self.API_URL = self.API_URL.replace("http://", "https://") - - - def getCredits(self): - res = getURL(self.API_URL, - get={'apikey': self.getConfig("passkey"), - 'pyload': "1", - 'source': "pyload", - 'action': "usercaptchaguthaben"}) - - if res.isdigit(): - self.logInfo(_("%s credits left") % res) - credits = self.info['credits'] = int(res) - return credits - else: - self.logError(res) - return 0 - - - @threaded - def _processCaptcha(self, task): - try: - with open(task.captchaFile, 'rb') as f: - data = f.read() - - except IOError, e: - self.logError(e) - return - - data = b64encode(data) - mouse = 1 if task.isPositional() else 0 - pluginname = re.search(r'_([^_]*)_\d+.\w+', task.captchaFile).group(1) - - option = {'min' : 2, - 'max' : 50, - 'phrase' : 0, - 'numeric' : 0, - 'case_sensitive': 0, - 'math' : 0, - 'prio' : min(max(self.getConfig("prio"), 0), 10), - 'confirm' : self.getConfig("confirm"), - 'timeout' : min(max(self.getConfig("timeout"), 300), 3999), - 'selfsolve' : self.getConfig("selfsolve"), - 'cph' : self.getConfig("captchaperhour"), - 'cpm' : self.getConfig("captchapermin")} - - for opt in str(self.getConfig("hoster_options").split('|')): - - details = map(str.strip, opt.split(':')) - - if not details or details[0].lower() != pluginname.lower(): - continue - - for d in details: - hosteroption = d.split("=") - - if len(hosteroption) < 2 or not hosteroption[1].isdigit(): - continue - - o = hosteroption[0].lower() - if o in option: - option[o] = hosteroption[1] - - break - - post_data = {'apikey' : self.getConfig("passkey"), - 'prio' : option['prio'], - 'confirm' : option['confirm'], - 'maxtimeout' : option['timeout'], - 'selfsolve' : option['selfsolve'], - 'captchaperhour': option['cph'], - 'captchapermin' : option['cpm'], - 'case-sensitive': option['case_sensitive'], - 'min_len' : option['min'], - 'max_len' : option['max'], - 'phrase' : option['phrase'], - 'numeric' : option['numeric'], - 'math' : option['math'], - 'oldsource' : pluginname, - 'pyload' : "1", - 'source' : "pyload", - 'base64' : "1", - 'mouse' : mouse, - 'file-upload-01': data, - 'action' : "usercaptchaupload"} - - for _i in xrange(5): - try: - res = getURL(self.API_URL, post=post_data) - except BadHeader, e: - sleep(3) - else: - if res and res.isdigit(): - break - else: - self.logError(_("Bad upload: %s") % res) - return - - self.logDebug(_("NewCaptchaID ticket: %s") % res, task.captchaFile) - - task.data["ticket"] = res - - for _i in xrange(int(self.getConfig("timeout") / 5)): - result = getURL(self.API_URL, - get={'apikey': self.getConfig("passkey"), - 'id' : res, - 'pyload': "1", - 'info' : "1", - 'source': "pyload", - 'action': "usercaptchacorrectdata"}) - - if not result or result == "NO DATA": - sleep(5) - else: - break - else: - self.logDebug("Could not send request: %s" % res) - result = None - - self.logInfo(_("Captcha result for ticket %s: %s") % (res, result)) - - task.setResult(result) - - - def newCaptchaTask(self, task): - if not task.isTextual() and not task.isPositional(): - return - - if not self.getConfig("passkey"): - return - - if self.core.isClientConnected() and not self.getConfig("force"): - return - - credits = self.getCredits() - - if not credits: - self.logError(_("Your captcha 9kw.eu account has not enough credits")) - return - - queue = min(self.getConfig("queue"), 999) - timeout = min(max(self.getConfig("timeout"), 300), 3999) - pluginname = re.search(r'_([^_]*)_\d+.\w+', task.captchaFile).group(1) - - for _i in xrange(5): - servercheck = getURL("http://www.9kw.eu/grafik/servercheck.txt") - if queue < re.search(r'queue=(\d+)', servercheck).group(1): - break - - sleep(10) - else: - self.fail(_("Too many captchas in queue")) - - for opt in str(self.getConfig("hoster_options").split('|')): - details = map(str.strip, opt.split(':')) - - if not details or details[0].lower() != pluginname.lower(): - continue - - for d in details: - hosteroption = d.split("=") - - if (len(hosteroption) > 1 - and hosteroption[0].lower() == 'timeout' - and hosteroption[1].isdigit()): - timeout = int(hosteroption[1]) - - break - - task.handler.append(self) - - task.setWaiting(timeout) - - self._processCaptcha(task) - - - def _captchaResponse(self, task, correct): - type = "correct" if correct else "refund" - - if 'ticket' not in task.data: - self.logDebug("No CaptchaID for %s request (task: %s)" % (type, task)) - return - - passkey = self.getConfig("passkey") - - for _i in xrange(3): - res = getURL(self.API_URL, - get={'action' : "usercaptchacorrectback", - 'apikey' : passkey, - 'api_key': passkey, - 'correct': "1" if correct else "2", - 'pyload' : "1", - 'source' : "pyload", - 'id' : task.data["ticket"]}) - - self.logDebug("Request %s: %s" % (type, res)) - - if res == "OK": - break - - sleep(5) - else: - self.logDebug("Could not send %s request: %s" % (type, res)) - - - def captchaCorrect(self, task): - self._captchaResponse(task, True) - - - def captchaInvalid(self, task): - self._captchaResponse(task, False) -- cgit v1.2.3 From feef23fadfdfbf64b38ea0be817e36321160be1f Mon Sep 17 00:00:00 2001 From: Nippey <matthias@dornuweb.de> Date: Thu, 22 Jan 2015 16:47:29 +0100 Subject: socket.create_connection is unavailable in Python25 socket.create_connection doesn't exist in Python 2.5. But it can be modeled with above function taken from: https://hg.python.org/cpython/file/2.6/Lib/socket.py#l534 So, it is how 2.6 does it :) --- module/plugins/hooks/ClickAndLoad.py | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 222310c25..370c40053 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -17,11 +17,40 @@ def forward(source, destination): else: destination.shutdown(socket.SHUT_WR) - +_GLOBAL_DEFAULT_TIMEOUT = object() +def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT): + """Connect to *address* and return the socket object. + + Convenience function. Connect to *address* (a 2-tuple ``(host, + port)``) and return the socket object. Passing the optional + *timeout* parameter will set the timeout on the socket instance + before attempting to connect. If no *timeout* is supplied, the + global default timeout setting returned by :func:`getdefaulttimeout` + is used. + """ + + msg = "getaddrinfo returns an empty list" + host, port = address + for res in getaddrinfo(host, port, 0, socket.SOCK_STREAM): + af, socktype, proto, canonname, sa = res + sock = None + try: + sock = socket(af, socktype, proto) + if timeout is not _GLOBAL_DEFAULT_TIMEOUT: + sock.settimeout(timeout) + sock.connect(sa) + return sock + + except error, msg: + if sock is not None: + sock.close() + + raise error, msg + class ClickAndLoad(Hook): __name__ = "ClickAndLoad" __type__ = "hook" - __version__ = "0.26" + __version__ = "0.27" __config__ = [("activated", "bool", "Activated" , True ), ("port" , "int" , "Port" , 9666 ), @@ -62,7 +91,7 @@ class ClickAndLoad(Hook): while True: server_socket = dock_socket.accept()[0] - client_socket = socket.create_connection(("127.0.0.1", webport)) + client_socket = create_connection(("127.0.0.1", webport)) hookManager.startThread(forward, server_socket, client_socket) hookManager.startThread(forward, client_socket, server_socket) -- cgit v1.2.3 From cf4ded052964047de88d676045329b8fa4fca2dc Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Thu, 22 Jan 2015 21:31:19 +0100 Subject: Update plugins after CaptchaService changes --- module/plugins/hooks/DeathByCaptcha.py | 2 +- module/plugins/hooks/ExtractArchive.py | 38 +++++++++++++++++----------------- module/plugins/hooks/ImageTyperz.py | 2 +- 3 files changed, 21 insertions(+), 21 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/DeathByCaptcha.py b/module/plugins/hooks/DeathByCaptcha.py index 050b6fe15..d513c446d 100644 --- a/module/plugins/hooks/DeathByCaptcha.py +++ b/module/plugins/hooks/DeathByCaptcha.py @@ -135,7 +135,7 @@ class DeathByCaptcha(Hook): def submit(self, captcha, captchaType="file", match=None): - #workaround multipart-post bug in HTTPRequest.py + #@NOTE: Workaround multipart-post bug in HTTPRequest.py if re.match("^\w*$", self.getConfig("passkey")): multipart = True data = (FORM_FILE, captcha) diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index bdbaf64af..f2f4b5207 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -58,7 +58,7 @@ from module.utils import save_join, uniqify class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.04" + __version__ = "1.05" __config__ = [("activated" , "bool" , "Activated" , True ), ("fullpath" , "bool" , "Extract full path" , True ), @@ -305,33 +305,33 @@ class ExtractArchive(Hook): encrypted = True #@TODO: set to `False` passwords = self.getPasswords() - # try: - # self.logInfo(basename(plugin.file), "Verifying...") + try: + self.logInfo(basename(plugin.file), "Verifying...") - # tmp_password = plugin.password - # plugin.password = "" #: Force verifying without password + tmp_password = plugin.password + plugin.password = "" #: Force verifying without password - # plugin.verify() + plugin.verify() - # except PasswordError: - # encrypted = True + except PasswordError: + encrypted = True - # except CRCError: - # self.logWarning(basename(plugin.file), _("Archive damaged")) + except CRCError: + self.logWarning(basename(plugin.file), _("Archive damaged")) - # if not self.getConfig("repair"): - # raise CRCError + if not self.getConfig("repair"): + raise CRCError - # elif plugin.repair(): - # self.logInfo(basename(plugin.file), _("Successfully repaired")) + elif plugin.repair(): + self.logInfo(basename(plugin.file), _("Successfully repaired")) - # elif not self.getConfig("keepbroken"): - # raise ArchiveError(_("Broken archive")) + elif not self.getConfig("keepbroken"): + raise ArchiveError(_("Broken archive")) - # else: - # self.logInfo(basename(plugin.file), _("All OK")) + else: + self.logInfo(basename(plugin.file), _("All OK")) - # plugin.password = tmp_password + plugin.password = tmp_password if not encrypted: plugin.extract(progress) diff --git a/module/plugins/hooks/ImageTyperz.py b/module/plugins/hooks/ImageTyperz.py index 768129e4a..d62fed385 100644 --- a/module/plugins/hooks/ImageTyperz.py +++ b/module/plugins/hooks/ImageTyperz.py @@ -82,7 +82,7 @@ class ImageTyperz(Hook): req.c.setopt(LOW_SPEED_TIME, 80) try: - #workaround multipart-post bug in HTTPRequest.py + #@NOTE: Workaround multipart-post bug in HTTPRequest.py if re.match("^\w*$", self.getConfig("passkey")): multipart = True data = (FORM_FILE, captcha) -- cgit v1.2.3 From ce27cfd75023d3408cbdd74cf797a5aea7428de7 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Fri, 23 Jan 2015 00:52:58 +0100 Subject: [ClickAndLoad] Improve create_connection --- module/plugins/hooks/ClickAndLoad.py | 78 +++++++++++++++++++++--------------- 1 file changed, 46 insertions(+), 32 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 370c40053..682639750 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -17,40 +17,55 @@ def forward(source, destination): else: destination.shutdown(socket.SHUT_WR) -_GLOBAL_DEFAULT_TIMEOUT = object() -def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT): - """Connect to *address* and return the socket object. - - Convenience function. Connect to *address* (a 2-tuple ``(host, - port)``) and return the socket object. Passing the optional - *timeout* parameter will set the timeout on the socket instance - before attempting to connect. If no *timeout* is supplied, the - global default timeout setting returned by :func:`getdefaulttimeout` - is used. - """ - - msg = "getaddrinfo returns an empty list" - host, port = address - for res in getaddrinfo(host, port, 0, socket.SOCK_STREAM): - af, socktype, proto, canonname, sa = res - sock = None - try: - sock = socket(af, socktype, proto) - if timeout is not _GLOBAL_DEFAULT_TIMEOUT: - sock.settimeout(timeout) - sock.connect(sa) - return sock - - except error, msg: - if sock is not None: - sock.close() - - raise error, msg - + +#: socket.create_connection wrapper for python 2.5 +def create_connection(address, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, + source_address=None): + try: + return socket.create_connection(address, timeout, source_address) + + except SyntaxError: + """Connect to *address* and return the socket object. + + Convenience function. Connect to *address* (a 2-tuple ``(host, + port)``) and return the socket object. Passing the optional + *timeout* parameter will set the timeout on the socket instance + before attempting to connect. If no *timeout* is supplied, the + global default timeout setting returned by :func:`getdefaulttimeout` + is used. If *source_address* is set it must be a tuple of (host, port) + for the socket to bind as a source address before making the connection. + An host of \'\' or port 0 tells the OS to use the default. + """ + + host, port = address + err = None + for res in getaddrinfo(host, port, 0, SOCK_STREAM): + af, socktype, proto, canonname, sa = res + sock = None + try: + sock = socket(af, socktype, proto) + if timeout is not socket._GLOBAL_DEFAULT_TIMEOUT: + sock.settimeout(timeout) + if source_address: + sock.bind(source_address) + sock.connect(sa) + return sock + + except error as _: + err = _ + if sock is not None: + sock.close() + + if err is not None: + raise err + else: + raise error("getaddrinfo returns an empty list") + + class ClickAndLoad(Hook): __name__ = "ClickAndLoad" __type__ = "hook" - __version__ = "0.27" + __version__ = "0.28" __config__ = [("activated", "bool", "Activated" , True ), ("port" , "int" , "Port" , 9666 ), @@ -98,7 +113,6 @@ class ClickAndLoad(Hook): except socket.error, e: self.logError(e) - self.server(ip, webport, cnlport) finally: dock_socket.close() -- cgit v1.2.3 From d6fc06740679154f67a0f95aba5463dda1ecf3fb Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sat, 24 Jan 2015 01:52:04 +0100 Subject: [ExtractArchive] Fix encrypted flag init --- module/plugins/hooks/ExtractArchive.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index f2f4b5207..38459e5f1 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -58,7 +58,7 @@ from module.utils import save_join, uniqify class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.05" + __version__ = "1.06" __config__ = [("activated" , "bool" , "Activated" , True ), ("fullpath" , "bool" , "Extract full path" , True ), @@ -302,7 +302,7 @@ class ExtractArchive(Hook): try: progress = lambda x: pyfile.setProgress(x) - encrypted = True #@TODO: set to `False` + encrypted = False passwords = self.getPasswords() try: -- cgit v1.2.3 From 7fc3362307737cd7c565b710ec83c5bdc4d3e8a9 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sun, 25 Jan 2015 03:05:00 +0100 Subject: Revert Extractor to the old one (temp) --- module/plugins/hooks/ExtractArchive.py | 219 ++++++++++----------------------- 1 file changed, 65 insertions(+), 154 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 38459e5f1..9e530ce8f 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -51,33 +51,32 @@ if os.name != "nt": from pwd import getpwnam from module.plugins.Hook import Hook, threaded, Expose -from module.plugins.internal.Extractor import ArchiveError, CRCError, PasswordError -from module.utils import save_join, uniqify +from module.plugins.internal.Extractor import ArchiveError, CRCError, WrongPassword +from module.utils import save_join, fs_encode class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.06" - - __config__ = [("activated" , "bool" , "Activated" , True ), - ("fullpath" , "bool" , "Extract full path" , True ), - ("overwrite" , "bool" , "Overwrite files" , False ), - ("keepbroken" , "bool" , "Extract broken archives" , False ), - ("repair" , "bool" , "Repair broken archives" , True ), - ("passwordfile" , "file" , "Store passwords in file" , "archive_password.txt" ), - ("delete" , "bool" , "Delete archive when successfully extracted", False ), - ("subfolder" , "bool" , "Create subfolder for each package" , False ), - ("destination" , "folder", "Extract files to" , "" ), - ("extensions" , "str" , "Extract the following extensions" , "7z,bz2,bzip2,gz,gzip,lha,lzh,lzma,rar,tar,taz,tbz,tbz2,tgz,xar,xz,z,zip"), - ("excludefiles" , "str" , "Don't extract the following files" , "*.nfo,*.DS_Store,index.dat,thumb.db" ), - ("recursive" , "bool" , "Extract archives in archives" , True ), - ("queue" , "bool" , "Wait for all downloads to be finished" , False ), - ("renice" , "int" , "CPU Priority" , 0 )] + __version__ = "1.07" + + __config__ = [("activated", "bool", "Activated", True), + ("fullpath", "bool", "Extract full path", True), + ("overwrite", "bool", "Overwrite files", True), + ("passwordfile", "file", "password file", "archive_password.txt"), + ("deletearchive", "bool", "Delete archives when done", False), + ("subfolder", "bool", "Create subfolder for each package", False), + ("destination", "folder", "Extract files to", ""), + ("excludefiles", "str", "Exclude files from unpacking (seperated by ;)", ""), + ("recursive", "bool", "Extract archives in archvies", True), + ("queue", "bool", "Wait for all downloads to be finished", True), + ("renice", "int", "CPU Priority", 0)] __description__ = """Extract different kind of archives""" __license__ = "GPLv3" - __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] + __authors__ = [("RaNaN", "ranan@pyload.org"), + ("AndroKev", None), + ("Walter Purcaro", "vuolter@gmail.com")] event_list = ["allDownloadsProcessed"] @@ -88,16 +87,12 @@ class ExtractArchive(Hook): pass - def coreReady(self): - self.extracting = False - - def setup(self): self.plugins = [] self.passwords = [] names = [] - for p in ("UnRar", "SevenZip", "UnZip"): + for p in ("UnRar", "UnZip"): try: module = self.core.pluginManager.loadModule("internal", p) klass = getattr(module, p) @@ -127,69 +122,45 @@ class ExtractArchive(Hook): self.queue = [] - def periodical(self): - if not self.queue or self.extracting: - return - - local = copy(self.queue) - self.queue[:] = [] - - self.extractPackages(*local) - - @Expose def extractPackage(self, id): - """ Extract package wrapper""" - self.extractPackages(id) - - - @Expose - def extractPackages(self, *ids): - """ Extract packages with given id""" - self.manager.startThread(self.extract, ids) + """ Extract package with given id""" + self.manager.startThread(self.extract, [id]) def packageFinished(self, pypack): - if self.getConfig("queue") or self.extracting: + pid = pypack.id + if self.getConfig("queue"): self.logInfo(_("Package %s queued for later extracting") % pypack.name) - self.queue.append(pypack.id) + self.queue.append(pid) else: - self.extractPackage(pypack.id) + self.manager.startThread(self.extract, [pid]) @threaded - def allDownloadsProcessed(self): + def allDownloadsProcessed(self, thread): local = copy(self.queue) - self.queue[:] = [] - if self.extract(local): #: check only if all gone fine, no failed reporting for now + del self.queue[:] + + if self.extract(local, thread): #: check only if all gone fine, no failed reporting for now self.manager.dispatchEvent("all_archives_extracted") self.manager.dispatchEvent("all_archives_processed") - def extract(self, ids): - self.extracting = True - + def extract(self, ids, thread=None): processed = [] extracted = [] failed = [] - clearlist = lambda string: [x.lstrip('.') for x in string.replace(' ', '').replace(',', '|').replace(';', '|').split('|')] - destination = self.getConfig("destination") subfolder = self.getConfig("subfolder") fullpath = self.getConfig("fullpath") overwrite = self.getConfig("overwrite") - extensions = clearlist(self.getConfig("extensions")) - excludefiles = clearlist(self.getConfig("excludefiles")) + excludefiles = self.getConfig("excludefiles") renice = self.getConfig("renice") recursive = self.getConfig("recursive") - delete = self.getConfig("delete") - keepbroken = self.getConfig("keepbroken") - - if extensions: - self.logDebug("Extensions: %s" % "|.".join(extensions)) # reload from txt file self.reloadPasswords() @@ -200,7 +171,7 @@ class ExtractArchive(Hook): #iterate packages -> plugins -> targets for pid in ids: p = self.core.files.getPackage(pid) - self.logInfo(_("Check package: %s") % p.name) + self.logInfo(_("Check package %s") % p.name) if not p: continue @@ -208,25 +179,21 @@ class ExtractArchive(Hook): out = save_join(dl, p.folder, destination, "") #: force trailing slash if subfolder: - out = save_join(out, p.folder) + out = save_join(out, fs_encode(p.folder)) if not exists(out): makedirs(out) files_ids = [(save_join(dl, p.folder, x['name']), x['id']) for x in p.getChildren().itervalues()] - matched = False - success = True + matched = False + success = True # check as long there are unseen files while files_ids: new_files_ids = [] - if extensions: - files_ids = [(file, id) for file, id in files_ids if filter(lambda ext: file.endswith(ext), extensions)] - for plugin in self.plugins: targets = plugin.getTargets(files_ids) - if targets: self.logDebug("Targets for %s: %s" % (plugin.__name__, targets)) matched = True @@ -238,32 +205,19 @@ class ExtractArchive(Hook): processed.append(target) # prevent extracting same file twice - self.logInfo(basename(target), _("Extract to: %s") % out) + self.logInfo(basename(target), _("Extract to %s") % out) try: - klass = plugin(self, - target, - out, - p.password, - fullpath, - overwrite, - excludefiles, - renice, - delete, - keepbroken) + klass = plugin(self, target, out, fullpath, overwrite, excludefiles, renice) klass.init() - new_files = self._extract(klass, fid) + new_files = self._extract(klass, fid, [p.password.strip()], thread) except Exception, e: self.logError(basename(target), e) - new_files = None - - if new_files is None: - self.logWarning(basename(target), _("No files extracted")) success = False continue - self.logDebug("Extracted files: %s" % new_files) + self.logDebug("Extracted", new_files) self.setPermissions(new_files) for file in new_files: @@ -285,87 +239,46 @@ class ExtractArchive(Hook): else: self.logInfo(_("No files found to extract")) - if not matched or not success and subfolder: - try: - os.rmdir(out) - except OSError: - pass - - self.extracting = False return True if not failed else False - def _extract(self, plugin, fid): + def _extract(self, plugin, fid, passwords, thread): pyfile = self.core.files.getFile(fid) + deletearchive = self.getConfig("deletearchive") pyfile.setCustomStatus(_("extracting")) + thread.addActive(pyfile) # keep this file until everything is done try: - progress = lambda x: pyfile.setProgress(x) - encrypted = False - passwords = self.getPasswords() - - try: - self.logInfo(basename(plugin.file), "Verifying...") - - tmp_password = plugin.password - plugin.password = "" #: Force verifying without password - - plugin.verify() - - except PasswordError: - encrypted = True - - except CRCError: - self.logWarning(basename(plugin.file), _("Archive damaged")) - - if not self.getConfig("repair"): - raise CRCError - - elif plugin.repair(): - self.logInfo(basename(plugin.file), _("Successfully repaired")) - - elif not self.getConfig("keepbroken"): - raise ArchiveError(_("Broken archive")) - - else: - self.logInfo(basename(plugin.file), _("All OK")) - - plugin.password = tmp_password - - if not encrypted: - plugin.extract(progress) + progress = lambda x: pyfile.setProgress(x) + success = False + if not plugin.checkArchive(): + plugin.extract(progress, pw) + success = True else: self.logInfo(basename(plugin.file), _("Password protected")) + self.logDebug("Passwords: %s" % passwords if passwords else "No password provided") - if plugin.password: - passwords.insert(0, plugin.password) - passwords = uniqify(self.passwords) - self.logDebug("Password: %s" % plugin.password) - else: - self.logDebug("No package password provided") - - for pw in passwords: + for pw in set(passwords) | set(self.getPasswords()): try: self.logDebug("Try password: %s" % pw) - - if plugin.setPassword(pw): - plugin.extract(progress) + if plugin.checkPassword(pw): + plugin.extract(progress, pw) self.addPassword(pw) + success = True break - else: - raise PasswordError - except PasswordError: + except WrongPassword: self.logDebug("Password was wrong") - else: - raise PasswordError + + if not success: + raise Exception(_("Wrong password")) if self.core.debug: - self.logDebug("Would delete: %s" % ", ".join(plugin.getDeleteFiles())) + self.logDebug("Would delete", ", ".join(plugin.getDeleteFiles())) - if self.getConfig("delete"): + if deletearchive: files = plugin.getDeleteFiles() self.logInfo(_("Deleting %s files") % len(files)) for f in files: @@ -381,16 +294,12 @@ class ExtractArchive(Hook): return extracted_files - except PasswordError: - self.logError(basename(plugin.file), _("Wrong password" if passwords else "No password found")) - plugin.password = "" + except ArchiveError, e: + self.logError(basename(plugin.file), _("Archive Error"), e) except CRCError: self.logError(basename(plugin.file), _("CRC Mismatch")) - except ArchiveError, e: - self.logError(basename(plugin.file), _("Archive Error"), e) - except Exception, e: if self.core.debug: print_exc() @@ -398,7 +307,7 @@ class ExtractArchive(Hook): self.manager.dispatchEvent("archive_extract_failed", pyfile) - self.logError(basename(plugin.file), _("Extract failed")) + raise Exception(_("Extract failed")) @Expose @@ -428,13 +337,15 @@ class ExtractArchive(Hook): """ Adds a password to saved list""" passwordfile = self.getConfig("passwordfile") + if pw in self.passwords: + self.passwords.remove(pw) + self.passwords.insert(0, pw) - self.passwords = uniqify(self.passwords) try: with open(passwordfile, "wb") as f: for pw in self.passwords: - f.write(pw + '\n') + f.write(pw + "\n") except IOError, e: self.logError(e) -- cgit v1.2.3 From d95f42fd8aef58a1aa892a8540a7ec360540d90a Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sun, 25 Jan 2015 16:54:40 +0100 Subject: [ClickAndLoad] Fix bad except --- module/plugins/hooks/ClickAndLoad.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 682639750..c8e5e0e98 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -51,7 +51,7 @@ def create_connection(address, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, sock.connect(sa) return sock - except error as _: + except socket.error, _: err = _ if sock is not None: sock.close() @@ -59,13 +59,13 @@ def create_connection(address, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, if err is not None: raise err else: - raise error("getaddrinfo returns an empty list") + raise socket.error("getaddrinfo returns an empty list") class ClickAndLoad(Hook): __name__ = "ClickAndLoad" __type__ = "hook" - __version__ = "0.28" + __version__ = "0.29" __config__ = [("activated", "bool", "Activated" , True ), ("port" , "int" , "Port" , 9666 ), -- cgit v1.2.3 From 99ed44b0d919a33e3a559472893163b347cd1c37 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sun, 25 Jan 2015 19:09:21 +0100 Subject: Fix reverted Extractor --- module/plugins/hooks/ExtractArchive.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 9e530ce8f..20e585046 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -58,7 +58,7 @@ from module.utils import save_join, fs_encode class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.07" + __version__ = "1.08" __config__ = [("activated", "bool", "Activated", True), ("fullpath", "bool", "Extract full path", True), @@ -254,7 +254,7 @@ class ExtractArchive(Hook): success = False if not plugin.checkArchive(): - plugin.extract(progress, pw) + plugin.extract(progress, self.getPasswords()) success = True else: self.logInfo(basename(plugin.file), _("Password protected")) -- cgit v1.2.3 From b9ca6e20d44b6bbe95c7becc566b351b3f39c1e6 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Mon, 26 Jan 2015 00:20:26 +0100 Subject: [ClickAndLoad] Fix create_connection in python 2.5 --- module/plugins/hooks/ClickAndLoad.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index c8e5e0e98..80201fe23 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -19,10 +19,11 @@ def forward(source, destination): #: socket.create_connection wrapper for python 2.5 -def create_connection(address, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, - source_address=None): +def create_connection(address, timeout=object(), source_address=None): try: - return socket.create_connection(address, timeout, source_address) + return socket.create_connection(address, + socket._GLOBAL_DEFAULT_TIMEOUT if type(timeout) == object else timeout, + source_address) except SyntaxError: """Connect to *address* and return the socket object. @@ -44,7 +45,7 @@ def create_connection(address, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, sock = None try: sock = socket(af, socktype, proto) - if timeout is not socket._GLOBAL_DEFAULT_TIMEOUT: + if type(timeout) != object: sock.settimeout(timeout) if source_address: sock.bind(source_address) @@ -65,7 +66,7 @@ def create_connection(address, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, class ClickAndLoad(Hook): __name__ = "ClickAndLoad" __type__ = "hook" - __version__ = "0.29" + __version__ = "0.30" __config__ = [("activated", "bool", "Activated" , True ), ("port" , "int" , "Port" , 9666 ), -- cgit v1.2.3 From 49397d8e52e7c68a4ce3c1eb74792e23d79f3ebb Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Tue, 27 Jan 2015 17:46:19 +0100 Subject: [ClickAndLoad] Use self.manager instead hookManager --- module/plugins/hooks/ClickAndLoad.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 80201fe23..94a240d4c 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -66,7 +66,7 @@ def create_connection(address, timeout=object(), source_address=None): class ClickAndLoad(Hook): __name__ = "ClickAndLoad" __type__ = "hook" - __version__ = "0.30" + __version__ = "0.31" __config__ = [("activated", "bool", "Activated" , True ), ("port" , "int" , "Port" , 9666 ), @@ -91,7 +91,7 @@ class ClickAndLoad(Hook): @threaded def proxy(self, ip, webport, cnlport): - hookManager.startThread(self.server, ip, webport, cnlport) + self.manager.startThread(self.server, ip, webport, cnlport) lock = Lock() lock.acquire() lock.acquire() @@ -109,8 +109,8 @@ class ClickAndLoad(Hook): server_socket = dock_socket.accept()[0] client_socket = create_connection(("127.0.0.1", webport)) - hookManager.startThread(forward, server_socket, client_socket) - hookManager.startThread(forward, client_socket, server_socket) + self.manager.startThread(forward, server_socket, client_socket) + self.manager.startThread(forward, client_socket, server_socket) except socket.error, e: self.logError(e) -- cgit v1.2.3 From 8848a359a43316fb346b728d1d79d7b72d27e5a0 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Tue, 27 Jan 2015 17:48:25 +0100 Subject: Update Extractor (again) --- module/plugins/hooks/ExtractArchive.py | 273 +++++++++++++++++++-------------- 1 file changed, 161 insertions(+), 112 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 20e585046..11764759f 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -6,8 +6,6 @@ import os import sys from copy import copy -from os import remove, chmod, makedirs -from os.path import exists, basename, isfile, isdir from traceback import print_exc # monkey patch bug in python 2.6 and lower @@ -47,35 +45,37 @@ if sys.version_info < (2, 7) and os.name != "nt": if os.name != "nt": from grp import getgrnam - from os import chown from pwd import getpwnam from module.plugins.Hook import Hook, threaded, Expose -from module.plugins.internal.Extractor import ArchiveError, CRCError, WrongPassword -from module.utils import save_join, fs_encode +from module.plugins.internal.Extractor import ArchiveError, CRCError, PasswordError +from module.utils import fs_decode, save_join, uniqify class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.08" - - __config__ = [("activated", "bool", "Activated", True), - ("fullpath", "bool", "Extract full path", True), - ("overwrite", "bool", "Overwrite files", True), - ("passwordfile", "file", "password file", "archive_password.txt"), - ("deletearchive", "bool", "Delete archives when done", False), - ("subfolder", "bool", "Create subfolder for each package", False), - ("destination", "folder", "Extract files to", ""), - ("excludefiles", "str", "Exclude files from unpacking (seperated by ;)", ""), - ("recursive", "bool", "Extract archives in archvies", True), - ("queue", "bool", "Wait for all downloads to be finished", True), - ("renice", "int", "CPU Priority", 0)] + __version__ = "1.09" + + __config__ = [("activated" , "bool" , "Activated" , True ), + ("fullpath" , "bool" , "Extract full path" , True ), + ("overwrite" , "bool" , "Overwrite files" , False ), + ("keepbroken" , "bool" , "Extract broken archives" , False ), + # ("repair" , "bool" , "Repair broken archives" , True ), + ("passwordfile" , "file" , "Store passwords in file" , "archive_password.txt" ), + ("delete" , "bool" , "Delete archive when successfully extracted", False ), + ("subfolder" , "bool" , "Create subfolder for each package" , False ), + ("destination" , "folder", "Extract files to" , "" ), + ("extensions" , "str" , "Extract the following extensions" , "7z,bz2,bzip2,gz,gzip,lha,lzh,lzma,rar,tar,taz,tbz,tbz2,tgz,xar,xz,z,zip"), + ("excludefiles" , "str" , "Don't extract the following files" , "*.nfo,*.DS_Store,index.dat,thumb.db" ), + ("recursive" , "bool" , "Extract archives in archives" , True ), + ("queue" , "bool" , "Wait for all downloads to be finished" , False ), + ("renice" , "int" , "CPU Priority" , 0 )] __description__ = """Extract different kind of archives""" __license__ = "GPLv3" __authors__ = [("RaNaN", "ranan@pyload.org"), - ("AndroKev", None), + ("AndroKev", ""), ("Walter Purcaro", "vuolter@gmail.com")] @@ -87,18 +87,23 @@ class ExtractArchive(Hook): pass + def coreReady(self): + self.extracting = False + + def setup(self): - self.plugins = [] - self.passwords = [] - names = [] + self.interval = 300 + self.extractors = [] + self.passwords = [] - for p in ("UnRar", "UnZip"): + names = [] + for p in ("UnRar", "SevenZip", "UnZip"): try: module = self.core.pluginManager.loadModule("internal", p) klass = getattr(module, p) if klass.checkDeps(): names.append(p) - self.plugins.append(klass) + self.extractors.append(klass) except OSError, e: if e.errno == 2: @@ -118,49 +123,55 @@ class ExtractArchive(Hook): else: self.logInfo(_("No Extract plugins activated")) - # queue with package ids - self.queue = [] + + def periodical(self): + if not self.extracting: + self.extractPackage(*self.getQueue()) @Expose - def extractPackage(self, id): - """ Extract package with given id""" - self.manager.startThread(self.extract, [id]) + def extractPackage(self, *ids): + """ Extract packages with given id""" + self.manager.startThread(self.extract, ids) def packageFinished(self, pypack): - pid = pypack.id - if self.getConfig("queue"): + if self.extracting or self.getConfig("queue"): self.logInfo(_("Package %s queued for later extracting") % pypack.name) - self.queue.append(pid) + self.addToQueue(pypack.id) else: - self.manager.startThread(self.extract, [pid]) + self.extractPackage(pypack.id) @threaded - def allDownloadsProcessed(self, thread): - local = copy(self.queue) - - del self.queue[:] - - if self.extract(local, thread): #: check only if all gone fine, no failed reporting for now + def allDownloadsProcessed(self): + if self.extract(self.getQueue()): #@NOTE: check only if all gone fine, no failed reporting for now self.manager.dispatchEvent("all_archives_extracted") self.manager.dispatchEvent("all_archives_processed") - def extract(self, ids, thread=None): + def extract(self, ids): processed = [] extracted = [] failed = [] + clearList = lambda string: [x.lstrip('.') for x in string.replace(' ', '').replace(',', '|').replace(';', '|').split('|')] + destination = self.getConfig("destination") subfolder = self.getConfig("subfolder") fullpath = self.getConfig("fullpath") overwrite = self.getConfig("overwrite") + extensions = clearList(self.getConfig("extensions")) + excludefiles = clearList(self.getConfig("excludefiles")) excludefiles = self.getConfig("excludefiles") renice = self.getConfig("renice") recursive = self.getConfig("recursive") + delete = self.getConfig("delete") + keepbroken = self.getConfig("keepbroken") + + if extensions: + self.logDebug("Extensions: %s" % "|.".join(extensions)) # reload from txt file self.reloadPasswords() @@ -168,63 +179,81 @@ class ExtractArchive(Hook): # dl folder dl = self.config['general']['download_folder'] - #iterate packages -> plugins -> targets + #iterate packages -> extractors -> targets for pid in ids: - p = self.core.files.getPackage(pid) - self.logInfo(_("Check package %s") % p.name) - if not p: + pypack = self.core.files.getPackage(pid) + + self.logInfo(_("Check package: %s") % pypack.name) + + if not pypack: continue # determine output folder - out = save_join(dl, p.folder, destination, "") #: force trailing slash + out = save_join(dl, pypack.folder, destination, "") #: force trailing slash if subfolder: - out = save_join(out, fs_encode(p.folder)) + out = save_join(out, pypack.folder) - if not exists(out): - makedirs(out) + if not os.path.exists(out): + os.makedirs(out) - files_ids = [(save_join(dl, p.folder, x['name']), x['id']) for x in p.getChildren().itervalues()] - matched = False - success = True + matched = False + success = True + files_ids = [(save_join(dl, pypack.folder, x['name']), x['id']) for x in pypack.getChildren().itervalues()] # check as long there are unseen files while files_ids: new_files_ids = [] - for plugin in self.plugins: - targets = plugin.getTargets(files_ids) + if extensions: + files_ids = [(file, id) for file, id in files_ids if filter(lambda ext: file.endswith(ext), extensions)] + + for Extractor in self.extractors: + targets = Extractor.getTargets(files_ids) if targets: - self.logDebug("Targets for %s: %s" % (plugin.__name__, targets)) + self.logDebug("Targets for %s: %s" % (Extractor.__name__, targets)) matched = True - for target, fid in targets: - if target in processed: - self.logDebug(basename(target), "skipped") + for filename, fid in targets: + fname = os.path.basename(filename) + + if filename in processed: + self.logDebug(fname, "Skipped") continue - processed.append(target) # prevent extracting same file twice + processed.append(filename) # prevent extracting same file twice - self.logInfo(basename(target), _("Extract to %s") % out) + self.logInfo(fname, _("Extract to: %s") % out) try: - klass = plugin(self, target, out, fullpath, overwrite, excludefiles, renice) + self.extracting = True + + klass = Extractor(self, + filename, + out, + fullpath, + overwrite, + excludefiles, + renice, + delete, + keepbroken, + fid) klass.init() - new_files = self._extract(klass, fid, [p.password.strip()], thread) + new_files = self._extract(klass, fid, pypack.password) except Exception, e: - self.logError(basename(target), e) + self.logError(fname, e) success = False continue - self.logDebug("Extracted", new_files) + self.logDebug("Extracted files: %s" % new_files) self.setPermissions(new_files) for file in new_files: - if not exists(file): + if not os.path.exists(file): self.logDebug("New file %s does not exists" % file) continue - if recursive and isfile(file): + if recursive and os.path.isfile(file): new_files_ids.append((file, fid)) # append as new target files_ids = new_files_ids # also check extracted files @@ -232,96 +261,120 @@ class ExtractArchive(Hook): if matched: if success: extracted.append(pid) - self.manager.dispatchEvent("package_extracted", p) + self.manager.dispatchEvent("package_extracted", pypack) else: failed.append(pid) - self.manager.dispatchEvent("package_extract_failed", p) + self.manager.dispatchEvent("package_extract_failed", pypack) else: self.logInfo(_("No files found to extract")) + if not matched or not success and subfolder: + try: + os.rmdir(out) + except OSError: + pass + + self.extracting = False return True if not failed else False - def _extract(self, plugin, fid, passwords, thread): + def _extract(self, archive, fid, password): pyfile = self.core.files.getFile(fid) - deletearchive = self.getConfig("deletearchive") + fname = os.path.basename(fs_decode(archive.target)) pyfile.setCustomStatus(_("extracting")) - thread.addActive(pyfile) # keep this file until everything is done + pyfile.setProgress(0) try: - progress = lambda x: pyfile.setProgress(x) success = False - if not plugin.checkArchive(): - plugin.extract(progress, self.getPasswords()) + if not archive.checkArchive(): + archive.extract(password) success = True else: - self.logInfo(basename(plugin.file), _("Password protected")) - self.logDebug("Passwords: %s" % passwords if passwords else "No password provided") + self.logInfo(fname, _("Password protected")) + self.logDebug("Password: %s" % (password or "No provided")) - for pw in set(passwords) | set(self.getPasswords()): + for pw in set(self.getPasswords(False) + [password]): try: self.logDebug("Try password: %s" % pw) - if plugin.checkPassword(pw): - plugin.extract(progress, pw) + if archive.checkPassword(pw): + archive.extract(pw) self.addPassword(pw) success = True break - except WrongPassword: + except PasswordError: self.logDebug("Password was wrong") + else: + raise PasswordError - if not success: - raise Exception(_("Wrong password")) + pyfile.setProgress(100) + pyfile.setStatus("processing") if self.core.debug: - self.logDebug("Would delete", ", ".join(plugin.getDeleteFiles())) + self.logDebug("Would delete: %s" % ", ".join(plugin.getDeleteFiles())) - if deletearchive: - files = plugin.getDeleteFiles() + if self.getConfig("delete"): + files = archive.getDeleteFiles() self.logInfo(_("Deleting %s files") % len(files)) for f in files: - if exists(f): - remove(f) + if os.path.exists(f): + os.remove(f) else: self.logDebug("%s does not exists" % f) - self.logInfo(basename(plugin.file), _("Extracting finished")) + self.logInfo(fname, _("Extracting finished")) - extracted_files = plugin.getExtractedFiles() - self.manager.dispatchEvent("archive_extracted", pyfile, plugin.out, plugin.file, extracted_files) + extracted_files = archive.getExtractedFiles() + self.manager.dispatchEvent("archive_extracted", pyfile, archive.out, archive.file, extracted_files) return extracted_files - except ArchiveError, e: - self.logError(basename(plugin.file), _("Archive Error"), e) + except PasswordError: + self.logError(fname, _("Wrong password" if password else "No password found")) except CRCError: - self.logError(basename(plugin.file), _("CRC Mismatch")) + self.logError(fname, _("CRC Mismatch")) + + except ArchiveError, e: + self.logError(fname, _("Archive Error"), e) except Exception, e: if self.core.debug: print_exc() - self.logError(basename(plugin.file), _("Unknown Error"), e) + self.logError(fname, _("Unknown Error"), e) + + finally: + pyfile.finishIfDone() self.manager.dispatchEvent("archive_extract_failed", pyfile) raise Exception(_("Extract failed")) + def getQueue(self): + return self.getStorage("ExtractArchive", []) + + + def addToQueue(self, item): + queue = self.getQueue() + return self.setStorage("ExtractArchive", queue + [item] if item not in queue else queue) + + @Expose - def getPasswords(self): + def getPasswords(self, reload=True): """ List of saved passwords """ + if reload: + self.reloadPasswords() + return self.passwords def reloadPasswords(self): - passwordfile = self.getConfig("passwordfile") - try: passwords = [] - with open(passwordfile, "a+") as f: + with open(self.getConfig("passwordfile")) as f: for pw in f.read().splitlines(): passwords.append(pw) @@ -335,17 +388,12 @@ class ExtractArchive(Hook): @Expose def addPassword(self, pw): """ Adds a password to saved list""" - passwordfile = self.getConfig("passwordfile") - - if pw in self.passwords: - self.passwords.remove(pw) - - self.passwords.insert(0, pw) - try: - with open(passwordfile, "wb") as f: + self.passwords = uniqify([pw] + self.passwords) + + with open(self.getConfig("passwordfile"), "wb") as f: for pw in self.passwords: - f.write(pw + "\n") + f.write(pw + '\n') except IOError, e: self.logError(e) @@ -353,20 +401,21 @@ class ExtractArchive(Hook): def setPermissions(self, files): for f in files: - if not exists(f): + if not os.path.exists(f): continue try: if self.config['permission']['change_file']: - if isfile(f): - chmod(f, int(self.config['permission']['file'], 8)) - elif isdir(f): - chmod(f, int(self.config['permission']['folder'], 8)) + if os.path.isfile(f): + os.chmod(f, int(self.config['permission']['file'], 8)) + + elif os.path.isdir(f): + os.chmod(f, int(self.config['permission']['folder'], 8)) if self.config['permission']['change_dl'] and os.name != "nt": uid = getpwnam(self.config['permission']['user'])[2] gid = getgrnam(self.config['permission']['group'])[2] - chown(f, uid, gid) + os.chown(f, uid, gid) except Exception, e: self.logWarning(_("Setting User and Group failed"), e) -- cgit v1.2.3 From 6cdce819e11b9bd1f3048513e7a1e0e5cf70a441 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Wed, 28 Jan 2015 01:16:37 +0100 Subject: [ExtractArchive] Fix typo --- module/plugins/hooks/ExtractArchive.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 11764759f..5c4e9bc82 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -55,13 +55,13 @@ from module.utils import fs_decode, save_join, uniqify class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.09" + __version__ = "1.10" __config__ = [("activated" , "bool" , "Activated" , True ), ("fullpath" , "bool" , "Extract full path" , True ), ("overwrite" , "bool" , "Overwrite files" , False ), ("keepbroken" , "bool" , "Extract broken archives" , False ), - # ("repair" , "bool" , "Repair broken archives" , True ), + ("repair" , "bool" , "Repair broken archives" , True ), ("passwordfile" , "file" , "Store passwords in file" , "archive_password.txt" ), ("delete" , "bool" , "Delete archive when successfully extracted", False ), ("subfolder" , "bool" , "Create subfolder for each package" , False ), -- cgit v1.2.3 From f23019b934446275b97f0c5fecf7709c19e557f9 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Thu, 29 Jan 2015 02:19:37 +0100 Subject: [JustPremium] Cleanup --- module/plugins/hooks/JustPremium.py | 110 ++++++++++++++---------------------- 1 file changed, 43 insertions(+), 67 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/JustPremium.py b/module/plugins/hooks/JustPremium.py index 2c5788b75..529628406 100644 --- a/module/plugins/hooks/JustPremium.py +++ b/module/plugins/hooks/JustPremium.py @@ -1,79 +1,55 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. +from module.linkdict.Hook import Hook - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. - @author: mazleu -""" -from module.plugins.Hook import Hook -from module.plugins.Account import Account -from module.plugins.Hoster import Hoster +class JustPremium(Hook): + __name__ = "JustPremium" + __type__ = "hook" + __version__ = "0.17" + __config__ = [("freehosters", "bool", "Allow all freehosters and other unknown sites", False), + ("nicehoster" , "str" , "unblock this hosters (comma seperated)" , "Zippyshare.com")] -class JustPremium(Hook): - __name__ = "JustPremium" - __version__ = "0.16" - __description__ = "If you add multiple links with at least one premium hoster link, all non premium links get removed" - __config__ = [("activated", "bool", "Activated", "False"), - ("freehosters","bool", "Allow all freehosters and other unknown sites", "false"), - ("nicehoster", "str", "unblock this hosters (comma seperated)", "Zippyshare.com")] + __description__ = """Remove all not premium links from urls added""" + __license__ = "GPLv3" + __authors__ = [("mazleu", "mazleica@gmail.com")] - __author_name__ = ("mazleu") - __author_mail__ = ("mazleica@gmail.com") event_list = ["linksAdded"] + def coreReady(self) : - accs=str(self.core.accountManager.getAccountInfos()) - global badhosts - global hosts - hosts = "" - while "[{" in accs: - startid=accs.rfind("[], ", 0, accs.find("[{"))+2 - endid=accs.find("}]",startid)+2 - hosts=hosts+","+accs[startid+3:accs.find("'",startid+3)] - accs=accs[0:startid]+accs[endid:] - badhosts=accs.replace("': [], '",",")[2:-6] - hosts=hosts[1:] - hosts=hosts+","+self.getConfig("nicehoster") - self.logDebug("good hosts:",hosts) - self.logDebug("bad hosts:",badhosts) - - - def filterLinks(self, t): - links = self.core.api.checkURLs(t) - hosterlist ="" - bhosters = [x.strip() for x in badhosts.split(",")] - ghosters = [x.strip() for x in hosts.split(",")] - premhoster = False - for hoster in links: - self.logDebug(hoster) - if hoster in ghosters: - premhoster = True - self.logDebug ("Found at least one hoster with account") - if premhoster : - for hoster in links: - if self.getConfig("freehosters"): - if hoster in bhosters: - self.logInfo("remove links from hoster '%s' " % (hoster)) - for link in links[hoster]: - t.remove(link) - self.logDebug("remove link '%s'because hoster was: '%s' " % (link,hoster)) - else: - if not hoster in ghosters: - self.logInfo("remove links from hoster '%s' " % (hoster)) - for link in links[hoster]: - t.remove(link) - self.logDebug("remove link '%s' because hoster was: '%s' " % (link,hoster)) + hosts = "" + accounts = str(self.core.accountManager.getAccountInfos()) + + while "[{" in accounts: + startid = accounts.rfind("[], ", 0, accounts.find("[{")) + 2 + endid = accounts.find("}]", startid) + 2 + hosts = hosts + "," + accounts[startid+3:accounts.find("'",startid+3)] + accounts = accounts[0:startid] + accounts[endid:] + + self.hosts = map(str.strip, (hosts[1:] + "," + self.getConfig("nicehoster")).split(',')) + self.badhosts = map(str.strip, accounts.replace("': [], '",",")[2:-6].split(',')) + + self.logDebug("Hosts: %s" % ", ".join(self.hosts)) + self.logDebug("Bad hosts: %s" % ", ".join(self.badhosts)) + + def linksAdded(self, links, pid): - self.filterLinks(links) + linkdict = self.core.api.checkURLs(links) + + #: Found at least one hoster with account + if not any(True for hoster in linkdict if hoster in self.hosts): + return + + if self.getConfig("freehosters"): + bad_hosters = [hoster for hoster in linkdict.iterkeys() if hoster in self.badhosts] + else: + bad_hosters = [hoster for hoster in linkdict.iterkeys() if hoster not in self.hosts] + + for hoster in bad_hosters: + self.logInfo(_("Remove links of hoster: %s") % hoster) + for link in linkdict[hoster]: + self.logDebug("Remove link: %s" % link) + links.remove(link) -- cgit v1.2.3 From 1ec3fd53f88aefb757491d590c302f6f71742a5c Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Thu, 29 Jan 2015 02:21:30 +0100 Subject: [JustPremium] Cleanup (2) --- module/plugins/hooks/JustPremium.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/JustPremium.py b/module/plugins/hooks/JustPremium.py index 529628406..7e1e738e4 100644 --- a/module/plugins/hooks/JustPremium.py +++ b/module/plugins/hooks/JustPremium.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- -from module.linkdict.Hook import Hook +from module.plugins.Hook import Hook class JustPremium(Hook): __name__ = "JustPremium" __type__ = "hook" - __version__ = "0.17" + __version__ = "0.18" __config__ = [("freehosters", "bool", "Allow all freehosters and other unknown sites", False), ("nicehoster" , "str" , "unblock this hosters (comma seperated)" , "Zippyshare.com")] -- cgit v1.2.3 From 52acc62381d165b615ebbb4414d846c7aee462d5 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Thu, 29 Jan 2015 13:34:33 +0100 Subject: [ExtractArchive] Fix typo (thx SelmaUrban) --- module/plugins/hooks/ExtractArchive.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 5c4e9bc82..c24173964 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -55,7 +55,7 @@ from module.utils import fs_decode, save_join, uniqify class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.10" + __version__ = "1.11" __config__ = [("activated" , "bool" , "Activated" , True ), ("fullpath" , "bool" , "Extract full path" , True ), @@ -74,9 +74,7 @@ class ExtractArchive(Hook): __description__ = """Extract different kind of archives""" __license__ = "GPLv3" - __authors__ = [("RaNaN", "ranan@pyload.org"), - ("AndroKev", ""), - ("Walter Purcaro", "vuolter@gmail.com")] + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] event_list = ["allDownloadsProcessed"] @@ -100,7 +98,7 @@ class ExtractArchive(Hook): for p in ("UnRar", "SevenZip", "UnZip"): try: module = self.core.pluginManager.loadModule("internal", p) - klass = getattr(module, p) + klass = getattr(module, p) if klass.checkDeps(): names.append(p) self.extractors.append(klass) @@ -164,7 +162,6 @@ class ExtractArchive(Hook): overwrite = self.getConfig("overwrite") extensions = clearList(self.getConfig("extensions")) excludefiles = clearList(self.getConfig("excludefiles")) - excludefiles = self.getConfig("excludefiles") renice = self.getConfig("renice") recursive = self.getConfig("recursive") delete = self.getConfig("delete") @@ -386,10 +383,10 @@ class ExtractArchive(Hook): @Expose - def addPassword(self, pw): + def addPassword(self, password): """ Adds a password to saved list""" try: - self.passwords = uniqify([pw] + self.passwords) + self.passwords = uniqify([password] + self.passwords) with open(self.getConfig("passwordfile"), "wb") as f: for pw in self.passwords: -- cgit v1.2.3 From cb9e67a5437ddfafd6a93f5a208b9faf3f2d5575 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Thu, 29 Jan 2015 15:56:57 +0100 Subject: Some file encoding fixup + optimizations --- module/plugins/hooks/ExternalScripts.py | 23 +++++++++++------------ module/plugins/hooks/ExtractArchive.py | 9 ++++++--- module/plugins/hooks/HotFolder.py | 3 ++- module/plugins/hooks/MergeFiles.py | 6 +++--- 4 files changed, 22 insertions(+), 19 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index b2b4548a2..3d9a1e811 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -1,10 +1,9 @@ # -*- coding: utf-8 -*- +import os import subprocess from itertools import chain -from os import listdir, access, X_OK, makedirs -from os.path import join, exists, basename, abspath from module.plugins.Hook import Hook from module.utils import save_join @@ -47,40 +46,40 @@ class ExternalScripts(Hook): for folder in folders: self.scripts[folder] = [] - self.initPluginType(folder, join(pypath, 'scripts', folder)) - self.initPluginType(folder, join('scripts', folder)) + self.initPluginType(folder, os.path.join(pypath, 'scripts', folder)) + self.initPluginType(folder, os.path.join('scripts', folder)) for script_type, names in self.scripts.iteritems(): if names: - self.logInfo(_("Installed scripts for"), script_type, ", ".join([basename(x) for x in names])) + self.logInfo(_("Installed scripts for"), script_type, ", ".join([os.path.basename(x) for x in names])) def initPluginType(self, folder, path): - if not exists(path): + if not os.path.exists(path): try: - makedirs(path) + os.makedirs(path) except Exception: self.logDebug("Script folder %s not created" % folder) return - for f in listdir(path): + for f in os.listdir(path): if f.startswith("#") or f.startswith(".") or f.startswith("_") or f.endswith("~") or f.endswith(".swp"): continue - if not access(join(path, f), X_OK): + if not os.access(os.path.join(path, f), os.X_OK): self.logWarning(_("Script not executable:") + " %s/%s" % (folder, f)) - self.scripts[folder].append(join(path, f)) + self.scripts[folder].append(os.path.join(path, f)) def callScript(self, script, *args): try: cmd = [script] + [str(x) if not isinstance(x, basestring) else x for x in args] - self.logDebug("Executing", abspath(script), " ".join(cmd)) + self.logDebug("Executing", os.path.abspath(script), " ".join(cmd)) #output goes to pyload subprocess.Popen(cmd, bufsize=-1) except Exception, e: - self.logError(_("Error in %(script)s: %(error)s") % {"script": basename(script), "error": e}) + self.logError(_("Error in %(script)s: %(error)s") % {"script": os.path.basename(script), "error": e}) def downloadPreparing(self, pyfile): diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index c24173964..11427109b 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -49,7 +49,7 @@ if os.name != "nt": from module.plugins.Hook import Hook, threaded, Expose from module.plugins.internal.Extractor import ArchiveError, CRCError, PasswordError -from module.utils import fs_decode, save_join, uniqify +from module.utils import fs_decode, fs_encode, save_join, uniqify class ExtractArchive(Hook): @@ -371,7 +371,9 @@ class ExtractArchive(Hook): def reloadPasswords(self): try: passwords = [] - with open(self.getConfig("passwordfile")) as f: + + file = fs_encode(self.getConfig("passwordfile")) + with open(file) as f: for pw in f.read().splitlines(): passwords.append(pw) @@ -388,7 +390,8 @@ class ExtractArchive(Hook): try: self.passwords = uniqify([password] + self.passwords) - with open(self.getConfig("passwordfile"), "wb") as f: + file = fs_encode(self.getConfig("passwordfile")) + with open(file, "wb") as f: for pw in self.passwords: f.write(pw + '\n') diff --git a/module/plugins/hooks/HotFolder.py b/module/plugins/hooks/HotFolder.py index b0b59e2ba..1ff02c319 100644 --- a/module/plugins/hooks/HotFolder.py +++ b/module/plugins/hooks/HotFolder.py @@ -39,7 +39,8 @@ class HotFolder(Hook): makedirs(join(folder, "finished")) if self.getConfig("watch_file"): - with open(fs_encode(self.getConfig("file")), "a+") as f: + file = fs_encode(self.getConfig("file")) + with open(file, "a+") as f: content = f.read().strip() if content: diff --git a/module/plugins/hooks/MergeFiles.py b/module/plugins/hooks/MergeFiles.py index 4de45f958..9f1348485 100644 --- a/module/plugins/hooks/MergeFiles.py +++ b/module/plugins/hooks/MergeFiles.py @@ -8,13 +8,13 @@ import re from traceback import print_exc from module.plugins.Hook import Hook, threaded -from module.utils import save_join, fs_encode +from module.utils import save_join class MergeFiles(Hook): __name__ = "MergeFiles" __type__ = "hook" - __version__ = "0.13" + __version__ = "0.14" __config__ = [("activated", "bool", "Activated", True)] @@ -65,7 +65,7 @@ class MergeFiles(Hook): pyfile.setStatus("processing") try: - with open(os.path.join(download_folder, splitted_file), "rb") as s_file: + with open(save_join(download_folder, splitted_file), "rb") as s_file: size_written = 0 s_file_size = int(os.path.getsize(os.path.join(download_folder, splitted_file))) while True: -- cgit v1.2.3 From 788a06132882300a22f6db3aa7ac3a6009d4d762 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Thu, 29 Jan 2015 23:13:54 +0100 Subject: Update Extractor (2) --- module/plugins/hooks/ExtractArchive.py | 159 ++++++++++++++++++++++----------- 1 file changed, 105 insertions(+), 54 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 11427109b..f2bc11ec2 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -12,12 +12,14 @@ from traceback import print_exc # http://bugs.python.org/issue6122 , http://bugs.python.org/issue1236 , http://bugs.python.org/issue1731717 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: return func(*args) + except OSError, e: if e.errno == errno.EINTR: continue @@ -49,28 +51,64 @@ if os.name != "nt": from module.plugins.Hook import Hook, threaded, Expose from module.plugins.internal.Extractor import ArchiveError, CRCError, PasswordError -from module.utils import fs_decode, fs_encode, save_join, uniqify +from module.utils import fs_encode, save_join, uniqify + + +class ArchiveQueue(object): + + def __init__(self, plugin, storage): + self.plugin = plugin + self.storage = storage + + + def get(self): + return self.plugin.getStorage("ExtractArchive:%s" % storage, []) + + + def set(self, value): + return self.plugin.setStorage("ExtractArchive:%s" % storage, value) + + + def clean(self): + return self.set([]) + + + def add(self, item): + queue = self.get() + if item not in queue: + return self.set(queue + [item]) + else: + return True + + + def remove(self, item): + queue = self.get() + queue.pop(item, None) + return self.set(queue) + class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.11" - - __config__ = [("activated" , "bool" , "Activated" , True ), - ("fullpath" , "bool" , "Extract full path" , True ), - ("overwrite" , "bool" , "Overwrite files" , False ), - ("keepbroken" , "bool" , "Extract broken archives" , False ), - ("repair" , "bool" , "Repair broken archives" , True ), - ("passwordfile" , "file" , "Store passwords in file" , "archive_password.txt" ), - ("delete" , "bool" , "Delete archive when successfully extracted", False ), - ("subfolder" , "bool" , "Create subfolder for each package" , False ), - ("destination" , "folder", "Extract files to" , "" ), - ("extensions" , "str" , "Extract the following extensions" , "7z,bz2,bzip2,gz,gzip,lha,lzh,lzma,rar,tar,taz,tbz,tbz2,tgz,xar,xz,z,zip"), - ("excludefiles" , "str" , "Don't extract the following files" , "*.nfo,*.DS_Store,index.dat,thumb.db" ), - ("recursive" , "bool" , "Extract archives in archives" , True ), - ("queue" , "bool" , "Wait for all downloads to be finished" , False ), - ("renice" , "int" , "CPU Priority" , 0 )] + __version__ = "1.12" + + __config__ = [("activated" , "bool" , "Activated" , True ), + ("fullpath" , "bool" , "Extract full path" , True ), + ("overwrite" , "bool" , "Overwrite files" , False ), + ("keepbroken" , "bool" , "Try to extract broken archives" , False ), + ("repair" , "bool" , "Repair broken archives" , False ), + ("extractempty" , "bool" , "Extract empty archives" , True ), + ("usepasswordfile" , "bool" , "Use password file" , True ), + ("passwordfile" , "file" , "Password file" , "archive_password.txt" ), + ("delete" , "bool" , "Delete archive when successfully extracted", False ), + ("subfolder" , "bool" , "Create subfolder for each package" , False ), + ("destination" , "folder", "Extract files to folder" , "" ), + ("extensions" , "str" , "Extract the following extensions" , "7z,bz2,bzip2,gz,gzip,lha,lzh,lzma,rar,tar,taz,tbz,tbz2,tgz,xar,xz,z,zip"), + ("excludefiles" , "str" , "Don't extract the following files" , "*.nfo,*.DS_Store,index.dat,thumb.db" ), + ("recursive" , "bool" , "Extract archives in archives" , True ), + ("queue" , "bool" , "Wait for all downloads to be finished" , False ), + ("renice" , "int" , "CPU priority" , 0 )] __description__ = """Extract different kind of archives""" __license__ = "GPLv3" @@ -90,6 +128,9 @@ class ExtractArchive(Hook): def setup(self): + self.queue = ArchiveQueue(self, "Queue") + self.failed = ArchiveQueue(self, "Failed") + self.interval = 300 self.extractors = [] self.passwords = [] @@ -124,7 +165,7 @@ class ExtractArchive(Hook): def periodical(self): if not self.extracting: - self.extractPackage(*self.getQueue()) + self.extractPackage(*self.queue.get()) @Expose @@ -136,14 +177,14 @@ class ExtractArchive(Hook): def packageFinished(self, pypack): if self.extracting or self.getConfig("queue"): self.logInfo(_("Package %s queued for later extracting") % pypack.name) - self.addToQueue(pypack.id) + self.queue.add(pypack.id) else: self.extractPackage(pypack.id) @threaded def allDownloadsProcessed(self): - if self.extract(self.getQueue()): #@NOTE: check only if all gone fine, no failed reporting for now + if self.extract(self.queue.get()): #@NOTE: check only if all gone fine, no failed reporting for now self.manager.dispatchEvent("all_archives_extracted") self.manager.dispatchEvent("all_archives_processed") @@ -180,11 +221,11 @@ class ExtractArchive(Hook): for pid in ids: pypack = self.core.files.getPackage(pid) - self.logInfo(_("Check package: %s") % pypack.name) - if not pypack: continue + self.logInfo(_("Check package: %s") % pypack.name) + # determine output folder out = save_join(dl, pypack.folder, destination, "") #: force trailing slash @@ -224,19 +265,19 @@ class ExtractArchive(Hook): try: self.extracting = True - klass = Extractor(self, - filename, - out, - fullpath, - overwrite, - excludefiles, - renice, - delete, - keepbroken, - fid) - klass.init() + archive = Extractor(self, + filename, + out, + fullpath, + overwrite, + excludefiles, + renice, + delete, + keepbroken, + fid) + archive.init() - new_files = self._extract(klass, fid, pypack.password) + new_files = self._extract(archive, fid, pypack.password) except Exception, e: self.logError(fname, e) @@ -250,6 +291,7 @@ class ExtractArchive(Hook): if not os.path.exists(file): self.logDebug("New file %s does not exists" % file) continue + if recursive and os.path.isfile(file): new_files_ids.append((file, fid)) # append as new target @@ -262,43 +304,60 @@ class ExtractArchive(Hook): else: failed.append(pid) self.manager.dispatchEvent("package_extract_failed", pypack) + + self.failed.add(pid) else: self.logInfo(_("No files found to extract")) if not matched or not success and subfolder: try: os.rmdir(out) + except OSError: pass + self.queue.remove(pid) + self.extracting = False return True if not failed else False def _extract(self, archive, fid, password): pyfile = self.core.files.getFile(fid) - fname = os.path.basename(fs_decode(archive.target)) + fname = os.path.basename(archive.filename) pyfile.setCustomStatus(_("extracting")) pyfile.setProgress(0) try: - success = False + try: + archive.check() - if not archive.checkArchive(): - archive.extract(password) - success = True - else: + except CRCError: + self.logInfo(fname, _("Header protected")) + + if self.getConfig("repair"): + self.logWarning(fname, "Repairing...") + archive.repair() + + except PasswordError): self.logInfo(fname, _("Password protected")) - self.logDebug("Password: %s" % (password or "No provided")) + except ArchiveError, e: + if e != "Empty Archive" or not self.getConfig("extractempty"): + raise ArchiveError(e) + + self.logDebug("Password: %s" % (password or "No provided")) + + if not self.getConfig("usepasswordfile"): + archive.extract(password) + else: for pw in set(self.getPasswords(False) + [password]): try: self.logDebug("Try password: %s" % pw) - if archive.checkPassword(pw): + if archive.isPassword(pw): archive.extract(pw) self.addPassword(pw) - success = True break except PasswordError: @@ -316,8 +375,9 @@ class ExtractArchive(Hook): files = archive.getDeleteFiles() self.logInfo(_("Deleting %s files") % len(files)) for f in files: - if os.path.exists(f): - os.remove(f) + file = fs_encode(f) + if os.path.exists(file): + os.remove(file) else: self.logDebug("%s does not exists" % f) @@ -350,15 +410,6 @@ class ExtractArchive(Hook): raise Exception(_("Extract failed")) - def getQueue(self): - return self.getStorage("ExtractArchive", []) - - - def addToQueue(self, item): - queue = self.getQueue() - return self.setStorage("ExtractArchive", queue + [item] if item not in queue else queue) - - @Expose def getPasswords(self, reload=True): """ List of saved passwords """ -- cgit v1.2.3 From 096e457a5a44e1ade87504147468fda045e07a88 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Thu, 29 Jan 2015 23:19:39 +0100 Subject: [ExtractArchive] Fix password recognition --- module/plugins/hooks/ExtractArchive.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index f2bc11ec2..8c5af1bb5 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -329,6 +329,8 @@ class ExtractArchive(Hook): pyfile.setCustomStatus(_("extracting")) pyfile.setProgress(0) + encrypted = False + try: try: archive.check() @@ -337,11 +339,12 @@ class ExtractArchive(Hook): self.logInfo(fname, _("Header protected")) if self.getConfig("repair"): - self.logWarning(fname, "Repairing...") + self.logWarning(fname, _("Repairing...")) archive.repair() except PasswordError): self.logInfo(fname, _("Password protected")) + encrypted = True except ArchiveError, e: if e != "Empty Archive" or not self.getConfig("extractempty"): @@ -349,7 +352,7 @@ class ExtractArchive(Hook): self.logDebug("Password: %s" % (password or "No provided")) - if not self.getConfig("usepasswordfile"): + if not encrypted or not self.getConfig("usepasswordfile"): archive.extract(password) else: for pw in set(self.getPasswords(False) + [password]): -- cgit v1.2.3 From 9f5aa7aec672ee184a640910fcda2d818e8f19fe Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Thu, 29 Jan 2015 23:55:40 +0100 Subject: [ExtractArchive] Fix https://github.com/pyload/pyload/issues/1100 --- module/plugins/hooks/ExtractArchive.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 8c5af1bb5..c91228850 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -91,7 +91,7 @@ class ArchiveQueue(object): class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.12" + __version__ = "1.13" __config__ = [("activated" , "bool" , "Activated" , True ), ("fullpath" , "bool" , "Extract full path" , True ), @@ -342,7 +342,7 @@ class ExtractArchive(Hook): self.logWarning(fname, _("Repairing...")) archive.repair() - except PasswordError): + except PasswordError: self.logInfo(fname, _("Password protected")) encrypted = True -- cgit v1.2.3 From ddccf7b36d7a941e4ab5539ff0c35b1367fe5337 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sat, 31 Jan 2015 03:45:19 +0100 Subject: [ExtractArchive] Fix typo Fix https://github.com/pyload/pyload/issues/1011#issuecomment-72268195, https://github.com/pyload/pyload/issues/1113, https://github.com/pyload/pyload/issues/1115 --- module/plugins/hooks/ExtractArchive.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index c91228850..f1b73bf5f 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -62,11 +62,11 @@ class ArchiveQueue(object): def get(self): - return self.plugin.getStorage("ExtractArchive:%s" % storage, []) + return self.plugin.getStorage("ExtractArchive:%s" % self.storage, []) def set(self, value): - return self.plugin.setStorage("ExtractArchive:%s" % storage, value) + return self.plugin.setStorage("ExtractArchive:%s" % self.storage, value) def clean(self): @@ -91,7 +91,7 @@ class ArchiveQueue(object): class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.13" + __version__ = "1.14" __config__ = [("activated" , "bool" , "Activated" , True ), ("fullpath" , "bool" , "Extract full path" , True ), -- cgit v1.2.3 From 4eb3ecd44244734463d9fdec1a68cf25dcb0b625 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sat, 31 Jan 2015 11:19:45 +0100 Subject: [ExtractArchive] Fix https://github.com/pyload/pyload/issues/1109 and https://github.com/pyload/pyload/issues/1116 --- module/plugins/hooks/ExtractArchive.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index f1b73bf5f..a09e96d1f 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -62,17 +62,25 @@ class ArchiveQueue(object): def get(self): - return self.plugin.getStorage("ExtractArchive:%s" % self.storage, []) + return self.plugin.getStorage("ExtractArchive:%s" % self.storage, "").decode('base64').split() def set(self, value): - return self.plugin.setStorage("ExtractArchive:%s" % self.storage, value) + if isinstance(value, list): + item = str(value)[1:-1].replace(' ', '').replace(',', ' ') + else: + item = str(value).strip() + return self.plugin.setStorage("ExtractArchive:%s" % self.storage, item.encode('base64')[:-1]) def clean(self): return self.set([]) + def delete(self): + return self.plugin.delStorage("ExtractArchive:%s" % self.storage) + + def add(self, item): queue = self.get() if item not in queue: @@ -91,7 +99,7 @@ class ArchiveQueue(object): class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.14" + __version__ = "1.15" __config__ = [("activated" , "bool" , "Activated" , True ), ("fullpath" , "bool" , "Extract full path" , True ), @@ -387,7 +395,7 @@ class ExtractArchive(Hook): self.logInfo(fname, _("Extracting finished")) extracted_files = archive.getExtractedFiles() - self.manager.dispatchEvent("archive_extracted", pyfile, archive.out, archive.file, extracted_files) + self.manager.dispatchEvent("archive_extracted", pyfile, archive.out, archive.filename, extracted_files) return extracted_files -- cgit v1.2.3 From 9bcc44f285360334980d375601f4e69ac5e0d2af Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sat, 31 Jan 2015 12:02:03 +0100 Subject: [ExtractArchive] Fix typo (thx VinceGitHub) --- module/plugins/hooks/ExtractArchive.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index a09e96d1f..494381124 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -99,7 +99,7 @@ class ArchiveQueue(object): class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.15" + __version__ = "1.16" __config__ = [("activated" , "bool" , "Activated" , True ), ("fullpath" , "bool" , "Extract full path" , True ), @@ -380,7 +380,7 @@ class ExtractArchive(Hook): pyfile.setStatus("processing") if self.core.debug: - self.logDebug("Would delete: %s" % ", ".join(plugin.getDeleteFiles())) + self.logDebug("Would delete: %s" % ", ".join(archive.getDeleteFiles())) if self.getConfig("delete"): files = archive.getDeleteFiles() -- cgit v1.2.3 From a206e9103c6d791caf780be3de6ce6ceda13b793 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sat, 31 Jan 2015 21:18:17 +0100 Subject: [JustPremium] Rewritten --- module/plugins/hooks/JustPremium.py | 44 ++++++++++++------------------------- 1 file changed, 14 insertions(+), 30 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/JustPremium.py b/module/plugins/hooks/JustPremium.py index 7e1e738e4..1b0ed4196 100644 --- a/module/plugins/hooks/JustPremium.py +++ b/module/plugins/hooks/JustPremium.py @@ -1,55 +1,39 @@ # -*- coding: utf-8 -*- +import re + from module.plugins.Hook import Hook class JustPremium(Hook): __name__ = "JustPremium" __type__ = "hook" - __version__ = "0.18" + __version__ = "0.19" - __config__ = [("freehosters", "bool", "Allow all freehosters and other unknown sites", False), - ("nicehoster" , "str" , "unblock this hosters (comma seperated)" , "Zippyshare.com")] + __config__ = [("excluded", "str", "Exclude hosters (comma separated)", "")] __description__ = """Remove all not premium links from urls added""" __license__ = "GPLv3" - __authors__ = [("mazleu", "mazleica@gmail.com")] + __authors__ = [("mazleu", "mazleica@gmail.com"), + ("Walter Purcaro", "vuolter@gmail.com")] event_list = ["linksAdded"] - def coreReady(self) : - hosts = "" - accounts = str(self.core.accountManager.getAccountInfos()) - - while "[{" in accounts: - startid = accounts.rfind("[], ", 0, accounts.find("[{")) + 2 - endid = accounts.find("}]", startid) + 2 - hosts = hosts + "," + accounts[startid+3:accounts.find("'",startid+3)] - accounts = accounts[0:startid] + accounts[endid:] - - self.hosts = map(str.strip, (hosts[1:] + "," + self.getConfig("nicehoster")).split(',')) - self.badhosts = map(str.strip, accounts.replace("': [], '",",")[2:-6].split(',')) - - self.logDebug("Hosts: %s" % ", ".join(self.hosts)) - self.logDebug("Bad hosts: %s" % ", ".join(self.badhosts)) - - def linksAdded(self, links, pid): - linkdict = self.core.api.checkURLs(links) + linkdict = self.core.api.checkURLs(links) + premiumplugins = set(account.type for account in self.core.api.getAccounts(False) if account.valid and account.premium) #: Found at least one hoster with account - if not any(True for hoster in linkdict if hoster in self.hosts): + if not any(True for pluginname in linkdict if pluginname in premiumplugins): return - if self.getConfig("freehosters"): - bad_hosters = [hoster for hoster in linkdict.iterkeys() if hoster in self.badhosts] - else: - bad_hosters = [hoster for hoster in linkdict.iterkeys() if hoster not in self.hosts] + excluded = map(lambda domain: "".join(part.capitalize() for part in re.split(r'(\.|\d+)', domain) if part != '.'), + self.getConfig('excluded').replace(' ', '').replace(',', '|').replace(';', '|').split('|')) - for hoster in bad_hosters: - self.logInfo(_("Remove links of hoster: %s") % hoster) - for link in linkdict[hoster]: + for pluginname in set(linkdict.keys()) - premiumplugins.union(excluded): + self.logInfo(_("Remove links of plugin: %s") % pluginname) + for link in linkdict[pluginname]: self.logDebug("Remove link: %s" % link) links.remove(link) -- cgit v1.2.3 From 79725268402043906f619f7c09e848e02ab8a17b Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sat, 31 Jan 2015 22:00:59 +0100 Subject: Spare code cosmetics --- module/plugins/hooks/BypassCaptcha.py | 4 ++-- module/plugins/hooks/Captcha9Kw.py | 31 ++++++++++++++----------------- module/plugins/hooks/ExpertDecoders.py | 8 +++++--- module/plugins/hooks/ExternalScripts.py | 2 +- module/plugins/hooks/MultiHome.py | 2 +- module/plugins/hooks/XFileSharingPro.py | 14 +++++++------- 6 files changed, 30 insertions(+), 31 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/BypassCaptcha.py b/module/plugins/hooks/BypassCaptcha.py index 8e0d9d36e..cf8754dae 100644 --- a/module/plugins/hooks/BypassCaptcha.py +++ b/module/plugins/hooks/BypassCaptcha.py @@ -59,7 +59,7 @@ class BypassCaptcha(Hook): def getCredits(self): res = getURL(self.GETCREDITS_URL, post={"key": self.getConfig("passkey")}) - data = dict([x.split(' ', 1) for x in res.splitlines()]) + data = dict(x.split(' ', 1) for x in res.splitlines()) return int(data['Left']) @@ -79,7 +79,7 @@ class BypassCaptcha(Hook): finally: req.close() - data = dict([x.split(' ', 1) for x in res.splitlines()]) + data = dict(x.split(' ', 1) for x in res.splitlines()) if not data or "Value" not in data: raise BypassCaptchaException(res) diff --git a/module/plugins/hooks/Captcha9Kw.py b/module/plugins/hooks/Captcha9Kw.py index 600694e78..342f3fee8 100644 --- a/module/plugins/hooks/Captcha9Kw.py +++ b/module/plugins/hooks/Captcha9Kw.py @@ -77,22 +77,19 @@ class Captcha9Kw(Hook): self.logError(e) return - data = b64encode(data) - mouse = 1 if task.isPositional() else 0 pluginname = re.search(r'_([^_]*)_\d+.\w+', task.captchaFile).group(1) - - option = {'min' : 2, - 'max' : 50, - 'phrase' : 0, - 'numeric' : 0, - 'case_sensitive': 0, - 'math' : 0, - 'prio' : min(max(self.getConfig("prio"), 0), 10), - 'confirm' : self.getConfig("confirm"), - 'timeout' : min(max(self.getConfig("timeout"), 300), 3999), - 'selfsolve' : self.getConfig("selfsolve"), - 'cph' : self.getConfig("captchaperhour"), - 'cpm' : self.getConfig("captchapermin")} + option = {'min' : 2, + 'max' : 50, + 'phrase' : 0, + 'numeric' : 0, + 'case_sensitive': 0, + 'math' : 0, + 'prio' : min(max(self.getConfig("prio"), 0), 10), + 'confirm' : self.getConfig("confirm"), + 'timeout' : min(max(self.getConfig("timeout"), 300), 3999), + 'selfsolve' : self.getConfig("selfsolve"), + 'cph' : self.getConfig("captchaperhour"), + 'cpm' : self.getConfig("captchapermin")} for opt in str(self.getConfig("hoster_options").split('|')): @@ -130,8 +127,8 @@ class Captcha9Kw(Hook): 'pyload' : "1", 'source' : "pyload", 'base64' : "1", - 'mouse' : mouse, - 'file-upload-01': data, + 'mouse' : 1 if task.isPositional() else 0, + 'file-upload-01': b64encode(data), 'action' : "usercaptchaupload"} for _i in xrange(5): diff --git a/module/plugins/hooks/ExpertDecoders.py b/module/plugins/hooks/ExpertDecoders.py index c80401003..c9f8204c4 100644 --- a/module/plugins/hooks/ExpertDecoders.py +++ b/module/plugins/hooks/ExpertDecoders.py @@ -56,15 +56,17 @@ class ExpertDecoders(Hook): with open(task.captchaFile, 'rb') as f: data = f.read() - data = b64encode(data) req = getRequest() #raise timeout threshold req.c.setopt(LOW_SPEED_TIME, 80) try: - result = req.load(self.API_URL, post={"action": "upload", "key": self.getConfig("passkey"), - "file": data, "gen_task_id": ticket}) + result = req.load(self.API_URL, + post={'action' : "upload", + 'key' : self.getConfig("passkey"), + 'file' : b64encode(data), + 'gen_task_id': ticket}) finally: req.close() diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index 3d9a1e811..bbd442963 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -51,7 +51,7 @@ class ExternalScripts(Hook): for script_type, names in self.scripts.iteritems(): if names: - self.logInfo(_("Installed scripts for"), script_type, ", ".join([os.path.basename(x) for x in names])) + self.logInfo(_("Installed scripts for"), script_type, ", ".join(map(os.path.basename, names))) def initPluginType(self, folder, path): diff --git a/module/plugins/hooks/MultiHome.py b/module/plugins/hooks/MultiHome.py index 105a42abd..c9f6fc30c 100644 --- a/module/plugins/hooks/MultiHome.py +++ b/module/plugins/hooks/MultiHome.py @@ -32,7 +32,7 @@ class MultiHome(Hook): def toConfig(self): - return ";".join([i.adress for i in self.interfaces]) + return ";".join(i.adress for i in self.interfaces) def parseInterfaces(self, interfaces): diff --git a/module/plugins/hooks/XFileSharingPro.py b/module/plugins/hooks/XFileSharingPro.py index e6e30ca8f..9435d35d9 100644 --- a/module/plugins/hooks/XFileSharingPro.py +++ b/module/plugins/hooks/XFileSharingPro.py @@ -65,22 +65,22 @@ class XFileSharingPro(Hook): self.logInfo(_("Handling any %s I can!") % type) pattern = self.regexp[type][0] else: - s = self.getConfig('%s_list' % type).replace('\\', '').replace('|', ',').replace(';', ',').lower() - plugin_list = set([x.strip() for x in s.split(',')]) + plugins = self.getConfig('%s_list' % type) + plugin_set = set(plugins.replace(' ', '').replace('\\', '').replace('|', ',').replace(';', ',').lower().split(',')) if use_builtin_list: - plugin_list |= set([x.lower() for x in getattr(self, "%s_BUILTIN" % type.upper())]) + plugin_set |= set(x.lower() for x in getattr(self, "%s_BUILTIN" % type.upper())) - plugin_list -= set(('', u'')) + plugin_set -= set(('', u'')) - if not plugin_list: + if not plugin_set: self.logInfo(_("No %s to handle") % type) self._unload(type, plugin) return - match_list = '|'.join(sorted(plugin_list)) + match_list = '|'.join(sorted(plugin_set)) - len_match_list = len(plugin_list) + len_match_list = len(plugin_set) self.logInfo(_("Handling %d %s%s: %s") % (len_match_list, type, "" if len_match_list == 1 else "s", -- cgit v1.2.3 From cfdc545c0e0f85450d142fcc64af5bd37ff6da13 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sat, 31 Jan 2015 23:21:17 +0100 Subject: [ExtractArchive] Pre-final fixup --- module/plugins/hooks/ExtractArchive.py | 79 ++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 37 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 494381124..f1641d639 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -99,14 +99,13 @@ class ArchiveQueue(object): class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.16" + __version__ = "1.20" __config__ = [("activated" , "bool" , "Activated" , True ), - ("fullpath" , "bool" , "Extract full path" , True ), + ("fullpath" , "bool" , "Extract with full paths" , True ), ("overwrite" , "bool" , "Overwrite files" , False ), ("keepbroken" , "bool" , "Try to extract broken archives" , False ), - ("repair" , "bool" , "Repair broken archives" , False ), - ("extractempty" , "bool" , "Extract empty archives" , True ), + ("repair" , "bool" , "Repair broken archives" , True ), ("usepasswordfile" , "bool" , "Use password file" , True ), ("passwordfile" , "file" , "Password file" , "archive_password.txt" ), ("delete" , "bool" , "Delete archive when successfully extracted", False ), @@ -115,7 +114,7 @@ class ExtractArchive(Hook): ("extensions" , "str" , "Extract the following extensions" , "7z,bz2,bzip2,gz,gzip,lha,lzh,lzma,rar,tar,taz,tbz,tbz2,tgz,xar,xz,z,zip"), ("excludefiles" , "str" , "Don't extract the following files" , "*.nfo,*.DS_Store,index.dat,thumb.db" ), ("recursive" , "bool" , "Extract archives in archives" , True ), - ("queue" , "bool" , "Wait for all downloads to be finished" , False ), + ("waitall" , "bool" , "Wait for all downloads to be finished" , False ), ("renice" , "int" , "CPU priority" , 0 )] __description__ = """Extract different kind of archives""" @@ -148,7 +147,7 @@ class ExtractArchive(Hook): try: module = self.core.pluginManager.loadModule("internal", p) klass = getattr(module, p) - if klass.checkDeps(): + if klass.isUsable(): names.append(p) self.extractors.append(klass) @@ -183,7 +182,7 @@ class ExtractArchive(Hook): def packageFinished(self, pypack): - if self.extracting or self.getConfig("queue"): + if self.extracting or self.getConfig("waitall"): self.logInfo(_("Package %s queued for later extracting") % pypack.name) self.queue.add(pypack.id) else: @@ -203,19 +202,20 @@ class ExtractArchive(Hook): extracted = [] failed = [] - clearList = lambda string: [x.lstrip('.') for x in string.replace(' ', '').replace(',', '|').replace(';', '|').split('|')] + toList = lambda string: string.replace(' ', '').replace(',', '|').replace(';', '|').split('|') destination = self.getConfig("destination") subfolder = self.getConfig("subfolder") fullpath = self.getConfig("fullpath") overwrite = self.getConfig("overwrite") - extensions = clearList(self.getConfig("extensions")) - excludefiles = clearList(self.getConfig("excludefiles")) renice = self.getConfig("renice") recursive = self.getConfig("recursive") delete = self.getConfig("delete") keepbroken = self.getConfig("keepbroken") + extensions = [x.lstrip('.').lower() for x in toList(self.getConfig("extensions"))] + excludefiles = toList(self.getConfig("excludefiles")) + if extensions: self.logDebug("Extensions: %s" % "|.".join(extensions)) @@ -245,14 +245,15 @@ class ExtractArchive(Hook): matched = False success = True - files_ids = [(save_join(dl, pypack.folder, x['name']), x['id']) for x in pypack.getChildren().itervalues()] + files_ids = [(save_join(dl, pypack.folder, pylink['name']), pylink['id']) for pylink in pypack.getChildren().itervalues()] # check as long there are unseen files while files_ids: new_files_ids = [] if extensions: - files_ids = [(file, id) for file, id in files_ids if filter(lambda ext: file.endswith(ext), extensions)] + files_ids = [(fname, fid) for fname, id in files_ids \ + if filter(lambda ext: fname.lower().endswith(ext), extensions)] for Extractor in self.extractors: targets = Extractor.getTargets(files_ids) @@ -260,21 +261,21 @@ class ExtractArchive(Hook): self.logDebug("Targets for %s: %s" % (Extractor.__name__, targets)) matched = True - for filename, fid in targets: - fname = os.path.basename(filename) + for fname, fid in targets: + name = os.path.basename(fname) - if filename in processed: - self.logDebug(fname, "Skipped") + if fname in processed: + self.logDebug(name, "Skipped") continue - processed.append(filename) # prevent extracting same file twice + processed.append(fname) # prevent extracting same file twice - self.logInfo(fname, _("Extract to: %s") % out) + self.logInfo(name, _("Extract to: %s") % out) try: self.extracting = True archive = Extractor(self, - filename, + fname, out, fullpath, overwrite, @@ -288,20 +289,21 @@ class ExtractArchive(Hook): new_files = self._extract(archive, fid, pypack.password) except Exception, e: - self.logError(fname, e) + self.logError(name, e) success = False continue self.logDebug("Extracted files: %s" % new_files) self.setPermissions(new_files) - for file in new_files: + for filename in new_files: + file = fs_encode(filename) if not os.path.exists(file): - self.logDebug("New file %s does not exists" % file) + self.logDebug("New file %s does not exists" % filename) continue if recursive and os.path.isfile(file): - new_files_ids.append((file, fid)) # append as new target + new_files_ids.append((filename, fid)) # append as new target files_ids = new_files_ids # also check extracted files @@ -332,7 +334,7 @@ class ExtractArchive(Hook): def _extract(self, archive, fid, password): pyfile = self.core.files.getFile(fid) - fname = os.path.basename(archive.filename) + name = os.path.basename(archive.filename) pyfile.setCustomStatus(_("extracting")) pyfile.setProgress(0) @@ -343,20 +345,23 @@ class ExtractArchive(Hook): try: archive.check() - except CRCError: - self.logInfo(fname, _("Header protected")) + except CRCError, e: + self.logDebug(name, e) + self.logInfo(name, _("Header protected")) if self.getConfig("repair"): - self.logWarning(fname, _("Repairing...")) - archive.repair() + self.logWarning(name, _("Repairing...")) + repaired = archive.repair() + + if not repaired and not self.getConfig("keepbroken"): + raise CRCError("Archive damaged") except PasswordError: - self.logInfo(fname, _("Password protected")) + self.logInfo(name, _("Password protected")) encrypted = True except ArchiveError, e: - if e != "Empty Archive" or not self.getConfig("extractempty"): - raise ArchiveError(e) + raise ArchiveError(e) self.logDebug("Password: %s" % (password or "No provided")) @@ -392,7 +397,7 @@ class ExtractArchive(Hook): else: self.logDebug("%s does not exists" % f) - self.logInfo(fname, _("Extracting finished")) + self.logInfo(name, _("Extracting finished")) extracted_files = archive.getExtractedFiles() self.manager.dispatchEvent("archive_extracted", pyfile, archive.out, archive.filename, extracted_files) @@ -400,18 +405,18 @@ class ExtractArchive(Hook): return extracted_files except PasswordError: - self.logError(fname, _("Wrong password" if password else "No password found")) + self.logError(name, _("Wrong password" if password else "No password found")) - except CRCError: - self.logError(fname, _("CRC Mismatch")) + except CRCError, e: + self.logError(name, _("CRC mismatch"), e) except ArchiveError, e: - self.logError(fname, _("Archive Error"), e) + self.logError(name, _("Archive error"), e) except Exception, e: + self.logError(name, _("Unknown error"), e) if self.core.debug: print_exc() - self.logError(fname, _("Unknown Error"), e) finally: pyfile.finishIfDone() -- cgit v1.2.3 From b4515ea17dd64df7647f7d7d91ebc0c8a46d5433 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sat, 31 Jan 2015 23:52:43 +0100 Subject: Fix https://github.com/pyload/pyload/issues/1120 (2) --- module/plugins/hooks/ExtractArchive.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index f1641d639..dde1a5ddc 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -99,7 +99,7 @@ class ArchiveQueue(object): class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.20" + __version__ = "1.21" __config__ = [("activated" , "bool" , "Activated" , True ), ("fullpath" , "bool" , "Extract with full paths" , True ), @@ -252,7 +252,7 @@ class ExtractArchive(Hook): new_files_ids = [] if extensions: - files_ids = [(fname, fid) for fname, id in files_ids \ + files_ids = [(fname, fid) for fname, fid in files_ids \ if filter(lambda ext: fname.lower().endswith(ext), extensions)] for Extractor in self.extractors: -- cgit v1.2.3 From 8bda0302c7a9452a1828ec9c9e2f60901d25e3c5 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sun, 1 Feb 2015 00:08:07 +0100 Subject: [ExtractArchive] Fix http://forum.pyload.org/viewtopic.php?f=10&t=3990 --- module/plugins/hooks/ExtractArchive.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index dde1a5ddc..dd1a82a82 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -91,7 +91,10 @@ class ArchiveQueue(object): def remove(self, item): queue = self.get() - queue.pop(item, None) + try: + queue.remove(item) + except ValueError: + pass return self.set(queue) @@ -99,7 +102,7 @@ class ArchiveQueue(object): class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.21" + __version__ = "1.22" __config__ = [("activated" , "bool" , "Activated" , True ), ("fullpath" , "bool" , "Extract with full paths" , True ), -- cgit v1.2.3 From 63651d0c9b32c85c1a55dbf6b5299881170dccff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20H=C3=B6rnlein?= <jens.hoernlein@googlemail.com> Date: Sun, 1 Feb 2015 01:42:00 +0100 Subject: [JustPremium] Added Multi-Hosters recognition --- module/plugins/hooks/JustPremium.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/JustPremium.py b/module/plugins/hooks/JustPremium.py index 1b0ed4196..99af95e38 100644 --- a/module/plugins/hooks/JustPremium.py +++ b/module/plugins/hooks/JustPremium.py @@ -8,14 +8,15 @@ from module.plugins.Hook import Hook class JustPremium(Hook): __name__ = "JustPremium" __type__ = "hook" - __version__ = "0.19" + __version__ = "0.20" __config__ = [("excluded", "str", "Exclude hosters (comma separated)", "")] __description__ = """Remove all not premium links from urls added""" __license__ = "GPLv3" __authors__ = [("mazleu", "mazleica@gmail.com"), - ("Walter Purcaro", "vuolter@gmail.com")] + ("Walter Purcaro", "vuolter@gmail.com"), + ("immenz", "immenz@gmx.net")] event_list = ["linksAdded"] @@ -24,15 +25,16 @@ class JustPremium(Hook): def linksAdded(self, links, pid): linkdict = self.core.api.checkURLs(links) premiumplugins = set(account.type for account in self.core.api.getAccounts(False) if account.valid and account.premium) - - #: Found at least one hoster with account - if not any(True for pluginname in linkdict if pluginname in premiumplugins): + multihoster = set(hoster for hoster in self.core.pluginManager.hosterPlugins if 'new_name' in self.core.pluginManager.hosterPlugins[hoster]) + + #: Found at least one hoster with account or multihoster + if not any(True for pluginname in linkdict if pluginname in premiumplugins | multihoster): return excluded = map(lambda domain: "".join(part.capitalize() for part in re.split(r'(\.|\d+)', domain) if part != '.'), self.getConfig('excluded').replace(' ', '').replace(',', '|').replace(';', '|').split('|')) - for pluginname in set(linkdict.keys()) - premiumplugins.union(excluded): + for pluginname in set(linkdict.keys()) - (premiumplugins | set(excluded) | multihoster): self.logInfo(_("Remove links of plugin: %s") % pluginname) for link in linkdict[pluginname]: self.logDebug("Remove link: %s" % link) -- cgit v1.2.3 From 2fa8ca10879e163e5f20c9d7b8645e376e9941f3 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sun, 1 Feb 2015 23:32:34 +0100 Subject: [ClickAndLoad] Improve --- module/plugins/hooks/ClickAndLoad.py | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 94a240d4c..7ece12781 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -20,24 +20,13 @@ def forward(source, destination): #: socket.create_connection wrapper for python 2.5 def create_connection(address, timeout=object(), source_address=None): - try: - return socket.create_connection(address, - socket._GLOBAL_DEFAULT_TIMEOUT if type(timeout) == object else timeout, - source_address) - - except SyntaxError: - """Connect to *address* and return the socket object. - - Convenience function. Connect to *address* (a 2-tuple ``(host, - port)``) and return the socket object. Passing the optional - *timeout* parameter will set the timeout on the socket instance - before attempting to connect. If no *timeout* is supplied, the - global default timeout setting returned by :func:`getdefaulttimeout` - is used. If *source_address* is set it must be a tuple of (host, port) - for the socket to bind as a source address before making the connection. - An host of \'\' or port 0 tells the OS to use the default. - """ + if hasattr(socket, 'create_connection'): + if type(timeout) == object: + timeout = socket._GLOBAL_DEFAULT_TIMEOUT + return socket.create_connection(address, timeout, source_address) + + else: host, port = address err = None for res in getaddrinfo(host, port, 0, SOCK_STREAM): @@ -66,7 +55,7 @@ def create_connection(address, timeout=object(), source_address=None): class ClickAndLoad(Hook): __name__ = "ClickAndLoad" __type__ = "hook" - __version__ = "0.31" + __version__ = "0.32" __config__ = [("activated", "bool", "Activated" , True ), ("port" , "int" , "Port" , 9666 ), @@ -114,6 +103,7 @@ class ClickAndLoad(Hook): except socket.error, e: self.logError(e) + self.server(ip, webport, cnlport) finally: dock_socket.close() -- cgit v1.2.3 From e265a18ec18c4260531f977c98ebb13d2074380b Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Mon, 2 Feb 2015 00:33:17 +0100 Subject: [JustPremium] Cleanup --- module/plugins/hooks/JustPremium.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/JustPremium.py b/module/plugins/hooks/JustPremium.py index 99af95e38..b70d8dd2c 100644 --- a/module/plugins/hooks/JustPremium.py +++ b/module/plugins/hooks/JustPremium.py @@ -8,7 +8,7 @@ from module.plugins.Hook import Hook class JustPremium(Hook): __name__ = "JustPremium" __type__ = "hook" - __version__ = "0.20" + __version__ = "0.21" __config__ = [("excluded", "str", "Exclude hosters (comma separated)", "")] @@ -23,18 +23,23 @@ class JustPremium(Hook): def linksAdded(self, links, pid): - linkdict = self.core.api.checkURLs(links) - premiumplugins = set(account.type for account in self.core.api.getAccounts(False) if account.valid and account.premium) - multihoster = set(hoster for hoster in self.core.pluginManager.hosterPlugins if 'new_name' in self.core.pluginManager.hosterPlugins[hoster]) - + hosterdict = self.core.pluginManager.hosterPlugins + linkdict = self.core.api.checkURLs(links) + + premiumplugins = set(account.type for account in self.core.api.getAccounts(False) \ + if account.valid and account.premium) + multihosters = set(hoster for hoster in self.core.pluginManager.hosterPlugins \ + if 'new_name' in hosterdict[hoster] \ + and hosterdict[hoster]['new_name'] in premiumplugins) + #: Found at least one hoster with account or multihoster - if not any(True for pluginname in linkdict if pluginname in premiumplugins | multihoster): + if not any(True for pluginname in linkdict if pluginname in premiumplugins | multihosters): return excluded = map(lambda domain: "".join(part.capitalize() for part in re.split(r'(\.|\d+)', domain) if part != '.'), self.getConfig('excluded').replace(' ', '').replace(',', '|').replace(';', '|').split('|')) - for pluginname in set(linkdict.keys()) - (premiumplugins | set(excluded) | multihoster): + for pluginname in set(linkdict.keys()) - (premiumplugins | multihosters).union(excluded): self.logInfo(_("Remove links of plugin: %s") % pluginname) for link in linkdict[pluginname]: self.logDebug("Remove link: %s" % link) -- cgit v1.2.3 From 60394c74c92775303094a1069917d53169ab2fcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20H=C3=B6rnlein?= <jens.hoernlein@googlemail.com> Date: Mon, 2 Feb 2015 00:36:37 +0100 Subject: Captcha9Kw should be initialized activated false --- module/plugins/hooks/Captcha9Kw.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/Captcha9Kw.py b/module/plugins/hooks/Captcha9Kw.py index 342f3fee8..1031ef224 100644 --- a/module/plugins/hooks/Captcha9Kw.py +++ b/module/plugins/hooks/Captcha9Kw.py @@ -16,10 +16,9 @@ from module.plugins.Hook import Hook, threaded class Captcha9Kw(Hook): __name__ = "Captcha9Kw" __type__ = "hook" - __version__ = "0.27" + __version__ = "0.28" - __config__ = [("activated" , "bool" , "Activated" , True ), - ("ssl" , "bool" , "Use HTTPS" , True ), + __config__ = [("ssl" , "bool" , "Use HTTPS" , True ), ("force" , "bool" , "Force captcha resolving even if client is connected" , True ), ("confirm" , "bool" , "Confirm Captcha (cost +6 credits)" , False ), ("captchaperhour", "int" , "Captcha per hour" , "9999" ), -- cgit v1.2.3 From 8dfb7adc0fc3c858c0ddf9371c2f4580bb8be3c7 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Tue, 3 Feb 2015 00:10:11 +0100 Subject: Update Extractor (3) --- module/plugins/hooks/ExtractArchive.py | 74 +++++++++++++++++++++------------- 1 file changed, 46 insertions(+), 28 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index dd1a82a82..74dded9b7 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -51,6 +51,7 @@ if os.name != "nt": from module.plugins.Hook import Hook, threaded, Expose from module.plugins.internal.Extractor import ArchiveError, CRCError, PasswordError +from module.plugins.internal.SimpleHoster import replace_patterns from module.utils import fs_encode, save_join, uniqify @@ -94,7 +95,7 @@ class ArchiveQueue(object): try: queue.remove(item) except ValueError: - pass + pass return self.set(queue) @@ -102,7 +103,7 @@ class ArchiveQueue(object): class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.22" + __version__ = "1.23" __config__ = [("activated" , "bool" , "Activated" , True ), ("fullpath" , "bool" , "Extract with full paths" , True ), @@ -127,48 +128,55 @@ class ExtractArchive(Hook): event_list = ["allDownloadsProcessed"] + NAME_REPLACEMENTS = [(r'\.part\d+\.rar$', ".part.rar")] + #@TODO: Remove in 0.4.10 def initPeriodical(self): pass - def coreReady(self): - self.extracting = False - - def setup(self): self.queue = ArchiveQueue(self, "Queue") self.failed = ArchiveQueue(self, "Failed") self.interval = 300 + self.extracting = False self.extractors = [] self.passwords = [] - names = [] + + def coreReady(self): + # self.extracting = False + for p in ("UnRar", "SevenZip", "UnZip"): try: module = self.core.pluginManager.loadModule("internal", p) klass = getattr(module, p) if klass.isUsable(): - names.append(p) self.extractors.append(klass) except OSError, e: if e.errno == 2: self.logInfo(_("No %s installed") % p) else: - self.logWarning(_("Could not activate %s") % p, e) + self.logWarning(_("Could not activate: %s") % p, e) if self.core.debug: print_exc() except Exception, e: - self.logWarning(_("Could not activate %s") % p, e) + self.logWarning(_("Could not activate: %s") % p, e) if self.core.debug: print_exc() - if names: - self.logInfo(_("Activated") + " " + " ".join(names)) + if self.extractors: + self.logInfo(_("Activated") + " " + " ".join(Extractor.__name__ for Extractor in self.extractors)) + + if self.getConfig("waitall"): + self.extractPackage(*self.queue.get()) #: Resume unfinished extractions + else: + super(ExtractArchive, self).initPeriodical() + else: self.logInfo(_("No Extract plugins activated")) @@ -185,11 +193,7 @@ class ExtractArchive(Hook): def packageFinished(self, pypack): - if self.extracting or self.getConfig("waitall"): - self.logInfo(_("Package %s queued for later extracting") % pypack.name) - self.queue.add(pypack.id) - else: - self.extractPackage(pypack.id) + self.queue.add(pypack.id) @threaded @@ -201,6 +205,8 @@ class ExtractArchive(Hook): def extract(self, ids): + self.extracting = True + processed = [] extracted = [] failed = [] @@ -267,16 +273,19 @@ class ExtractArchive(Hook): for fname, fid in targets: name = os.path.basename(fname) - if fname in processed: - self.logDebug(name, "Skipped") + if not os.path.exists(fname): + self.logDebug(name, "File not found") continue - processed.append(fname) # prevent extracting same file twice + pname = replace_patterns(fname, self.NAME_REPLACEMENTS) + if pname not in processed: + processed.append(pname) #: prevent extracting same file twice + else: + self.logDebug(name, "Skipped") + continue self.logInfo(name, _("Extract to: %s") % out) try: - self.extracting = True - archive = Extractor(self, fname, out, @@ -339,11 +348,9 @@ class ExtractArchive(Hook): pyfile = self.core.files.getFile(fid) name = os.path.basename(archive.filename) - pyfile.setCustomStatus(_("extracting")) - pyfile.setProgress(0) + pyfile.setStatus("processing") encrypted = False - try: try: archive.check() @@ -354,8 +361,14 @@ class ExtractArchive(Hook): if self.getConfig("repair"): self.logWarning(name, _("Repairing...")) + + pyfile.setCustomStatus(_("repairing")) + pyfile.setProgress(0) + repaired = archive.repair() + pyfile.setProgress(100) + if not repaired and not self.getConfig("keepbroken"): raise CRCError("Archive damaged") @@ -368,13 +381,18 @@ class ExtractArchive(Hook): self.logDebug("Password: %s" % (password or "No provided")) + pyfile.setCustomStatus(_("extracting")) + pyfile.setProgress(0) + if not encrypted or not self.getConfig("usepasswordfile"): archive.extract(password) else: for pw in set(self.getPasswords(False) + [password]): try: self.logDebug("Try password: %s" % pw) - if archive.isPassword(pw): + + ispw = archive.isPassword(pw) + if ispw or ispw is None: archive.extract(pw) self.addPassword(pw) break @@ -385,7 +403,7 @@ class ExtractArchive(Hook): raise PasswordError pyfile.setProgress(100) - pyfile.setStatus("processing") + pyfile.setCustomStatus(_("finalizing")) if self.core.debug: self.logDebug("Would delete: %s" % ", ".join(archive.getDeleteFiles())) @@ -402,7 +420,7 @@ class ExtractArchive(Hook): self.logInfo(name, _("Extracting finished")) - extracted_files = archive.getExtractedFiles() + extracted_files = archive.files or archive.list() self.manager.dispatchEvent("archive_extracted", pyfile, archive.out, archive.filename, extracted_files) return extracted_files -- cgit v1.2.3 From 65c83f937b3a8f819d89cae9204ac12cb6ba1deb Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Tue, 3 Feb 2015 00:20:00 +0100 Subject: [Checksum] Retrieve hashsum from self.info --- module/plugins/hooks/Checksum.py | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/Checksum.py b/module/plugins/hooks/Checksum.py index 8d9f8f981..064375a41 100644 --- a/module/plugins/hooks/Checksum.py +++ b/module/plugins/hooks/Checksum.py @@ -40,7 +40,7 @@ def computeChecksum(local_file, algorithm): class Checksum(Hook): __name__ = "Checksum" __type__ = "hook" - __version__ = "0.15" + __version__ = "0.16" __config__ = [("check_checksum", "bool", "Check checksum? (If False only size will be verified)", True), ("check_action", "fail;retry;nothing", "What to do if check fails?", "retry"), @@ -55,10 +55,12 @@ class Checksum(Hook): ("stickell", "l.stickell@yahoo.it")] - methods = {'sfv': 'crc32', 'crc': 'crc32', 'hash': 'md5'} - regexps = {'sfv': r'^(?P<NAME>[^;].+)\s+(?P<HASH>[0-9A-Fa-f]{8})$', - 'md5': r'^(?P<NAME>[0-9A-Fa-f]{32}) (?P<FILE>.+)$', - 'crc': r'filename=(?P<NAME>.+)\nsize=(?P<SIZE>\d+)\ncrc32=(?P<HASH>[0-9A-Fa-f]{8})$', + methods = {'sfv' : 'crc32', + 'crc' : 'crc32', + 'hash': 'md5'} + regexps = {'sfv' : r'^(?P<NAME>[^;].+)\s+(?P<HASH>[0-9A-Fa-f]{8})$', + 'md5' : r'^(?P<NAME>[0-9A-Fa-f]{32}) (?P<FILE>.+)$', + 'crc' : r'filename=(?P<NAME>.+)\nsize=(?P<SIZE>\d+)\ncrc32=(?P<HASH>[0-9A-Fa-f]{8})$', 'default': r'^(?P<HASH>[0-9A-Fa-f]+)\s+\*?(?P<NAME>.+)$'} @@ -92,8 +94,9 @@ class Checksum(Hook): elif hasattr(pyfile.plugin, "api_data") and isinstance(pyfile.plugin.api_data, dict): data = pyfile.plugin.api_data.copy() - # elif hasattr(pyfile.plugin, "info") and isinstance(pyfile.plugin.info, dict): - # data = pyfile.plugin.info.copy() + elif hasattr(pyfile.plugin, "info") and isinstance(pyfile.plugin.info, dict): + data = pyfile.plugin.info.copy() + data.pop('size', None) #@NOTE: Don't check file size until a similary matcher will be implemented else: return @@ -110,19 +113,25 @@ class Checksum(Hook): if not isfile(local_file): self.checkFailed(pyfile, None, "File does not exist") - # validate file size + # validate file size if "size" in data: - api_size = int(data['size']) + api_size = int(data['size']) file_size = getsize(local_file) + if api_size != file_size: self.logWarning(_("File %s has incorrect size: %d B (%d expected)") % (pyfile.name, file_size, api_size)) self.checkFailed(pyfile, local_file, "Incorrect file size") - del data['size'] + + data.pop('size', None) # validate checksum if data and self.getConfig("check_checksum"): - if "checksum" in data: - data['md5'] = data['checksum'] + + if not 'md5' in data: + for type in ("checksum", "hashsum", "hash"): + if type in data: + data['md5'] = data[type] #@NOTE: What happens if it's not an md5 hash? + break for key in self.algorithms: if key in data: -- cgit v1.2.3 From 4722e1f6a0c5978617de52e1ec4611e5d6067142 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Tue, 3 Feb 2015 00:22:10 +0100 Subject: Use method pop to remove item from dict --- module/plugins/hooks/XFileSharingPro.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/XFileSharingPro.py b/module/plugins/hooks/XFileSharingPro.py index 9435d35d9..a1ee7f5ef 100644 --- a/module/plugins/hooks/XFileSharingPro.py +++ b/module/plugins/hooks/XFileSharingPro.py @@ -112,11 +112,11 @@ class XFileSharingPro(Hook): hdict = self.core.pluginManager.hosterPlugins[hoster] if "new_name" in hdict and hdict['new_name'] == "XFileSharingPro": if "module" in hdict: - del hdict['module'] + hdict.pop('module', None) if "new_module" in hdict: - del hdict['new_module'] - del hdict['new_name'] + hdict.pop('new_module', None) + hdict.pop('new_name', None) return True else: -- cgit v1.2.3 From 8d8cfd57fa44cb84eb9709871bf14a3b4d13d994 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Tue, 3 Feb 2015 01:10:04 +0100 Subject: Update Extractor (4) --- module/plugins/hooks/ExtractArchive.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 74dded9b7..47325608d 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -103,7 +103,7 @@ class ArchiveQueue(object): class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.23" + __version__ = "1.24" __config__ = [("activated" , "bool" , "Activated" , True ), ("fullpath" , "bool" , "Extract with full paths" , True ), @@ -205,6 +205,9 @@ class ExtractArchive(Hook): def extract(self, ids): + if not ids: + return False + self.extracting = True processed = [] @@ -226,7 +229,7 @@ class ExtractArchive(Hook): excludefiles = toList(self.getConfig("excludefiles")) if extensions: - self.logDebug("Extensions: %s" % "|.".join(extensions)) + self.logDebug("Use for extensions: %s" % "|.".join(extensions)) # reload from txt file self.reloadPasswords() @@ -462,7 +465,7 @@ class ExtractArchive(Hook): file = fs_encode(self.getConfig("passwordfile")) with open(file) as f: - for pw in f.read().splitlines(): + for pw in f.read().splitlines()[:-1]: passwords.append(pw) except IOError, e: -- cgit v1.2.3 From f6295ec0a2e6a819977afa66bbed3da15017c700 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Tue, 3 Feb 2015 02:37:17 +0100 Subject: [ClickAndLoad] Fix https://github.com/pyload/pyload/issues/1135 --- module/plugins/hooks/ClickAndLoad.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 7ece12781..0bcd6ddef 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -9,13 +9,14 @@ from module.plugins.Hook import Hook, threaded def forward(source, destination): - string = ' ' - while string: - string = source.recv(1024) - if string: - destination.sendall(string) - else: - destination.shutdown(socket.SHUT_WR) + try: + size = 1024 + data = source.recv(size) + while data: + destination.sendall(data) + data = source.recv(size) + finally: + destination.shutdown(socket.SHUT_WR) #: socket.create_connection wrapper for python 2.5 @@ -55,7 +56,7 @@ def create_connection(address, timeout=object(), source_address=None): class ClickAndLoad(Hook): __name__ = "ClickAndLoad" __type__ = "hook" - __version__ = "0.32" + __version__ = "0.33" __config__ = [("activated", "bool", "Activated" , True ), ("port" , "int" , "Port" , 9666 ), @@ -89,21 +90,21 @@ class ClickAndLoad(Hook): def server(self, ip, webport, cnlport): try: dock_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - - dock_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) dock_socket.bind((ip, cnlport)) dock_socket.listen(5) while True: - server_socket = dock_socket.accept()[0] - client_socket = create_connection(("127.0.0.1", webport)) + client_socket = dock_socket.accept()[0] + server_socket = create_connection(("127.0.0.1", webport)) - self.manager.startThread(forward, server_socket, client_socket) self.manager.startThread(forward, client_socket, server_socket) + self.manager.startThread(forward, server_socket, client_socket) except socket.error, e: - self.logError(e) + self.logDebug(e) self.server(ip, webport, cnlport) finally: + client_socket.close() + server_socket.close() dock_socket.close() -- cgit v1.2.3 From 896f1f1437442bb9a93a0664f3d447bbc0f444cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20H=C3=B6rnlein?= <jens.hoernlein@googlemail.com> Date: Wed, 4 Feb 2015 00:02:27 +0100 Subject: Addressed some Extractor Issues --- module/plugins/hooks/ExtractArchive.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 47325608d..e1c05878c 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -103,7 +103,7 @@ class ArchiveQueue(object): class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.24" + __version__ = "1.25" __config__ = [("activated" , "bool" , "Activated" , True ), ("fullpath" , "bool" , "Extract with full paths" , True ), @@ -312,7 +312,7 @@ class ExtractArchive(Hook): self.setPermissions(new_files) for filename in new_files: - file = fs_encode(filename) + file = fs_encode(save_join(filename, os.path.dirname(archive.filename))) if not os.path.exists(file): self.logDebug("New file %s does not exists" % filename) continue @@ -390,7 +390,7 @@ class ExtractArchive(Hook): if not encrypted or not self.getConfig("usepasswordfile"): archive.extract(password) else: - for pw in set(self.getPasswords(False) + [password]): + for pw in uniqify([password] + self.getPasswords(False)): try: self.logDebug("Try password: %s" % pw) @@ -465,7 +465,7 @@ class ExtractArchive(Hook): file = fs_encode(self.getConfig("passwordfile")) with open(file) as f: - for pw in f.read().splitlines()[:-1]: + for pw in f.read().splitlines(): passwords.append(pw) except IOError, e: -- cgit v1.2.3 From 0df373e5da9d33e4dea3e709521d4883ef7f9b45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20H=C3=B6rnlein?= <jens.hoernlein@googlemail.com> Date: Wed, 4 Feb 2015 20:41:03 +0100 Subject: [Unrar] Fix: Deleting All Files after Extraction --- module/plugins/hooks/ExtractArchive.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index e1c05878c..e1d6dff59 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -276,16 +276,16 @@ class ExtractArchive(Hook): for fname, fid in targets: name = os.path.basename(fname) - if not os.path.exists(fname): - self.logDebug(name, "File not found") - continue - pname = replace_patterns(fname, self.NAME_REPLACEMENTS) if pname not in processed: processed.append(pname) #: prevent extracting same file twice else: self.logDebug(name, "Skipped") continue + + if not os.path.exists(fname): + self.logDebug(name, "File not found") + continue self.logInfo(name, _("Extract to: %s") % out) try: -- cgit v1.2.3 From c1268bbbe35ebd8d5308051c169160257ad14c6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20H=C3=B6rnlein?= <jens.hoernlein@googlemail.com> Date: Wed, 4 Feb 2015 23:14:12 +0100 Subject: [ExtractArchive] fixed Queue Get --- module/plugins/hooks/ExtractArchive.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index e1d6dff59..6e6a6862c 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -63,7 +63,7 @@ class ArchiveQueue(object): def get(self): - return self.plugin.getStorage("ExtractArchive:%s" % self.storage, "").decode('base64').split() + return [int(pid) for pid in self.plugin.getStorage("ExtractArchive:%s" % self.storage, "").decode('base64').split()] def set(self, value): -- cgit v1.2.3 From 39e87e03709b663086c96309bd6ebb3e2dc16afc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20H=C3=B6rnlein?= <jens.hoernlein@googlemail.com> Date: Thu, 5 Feb 2015 00:24:08 +0100 Subject: set interval smaller --- module/plugins/hooks/ExtractArchive.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 6e6a6862c..b52fa026b 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -140,7 +140,7 @@ class ExtractArchive(Hook): self.queue = ArchiveQueue(self, "Queue") self.failed = ArchiveQueue(self, "Failed") - self.interval = 300 + self.interval = 60 self.extracting = False self.extractors = [] self.passwords = [] -- cgit v1.2.3 From eac9718c284330ca759d09661b98e070351d80ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20H=C3=B6rnlein?= <jens.hoernlein@googlemail.com> Date: Thu, 5 Feb 2015 00:26:25 +0100 Subject: [RestartSlow] Fixed AttributeError --- module/plugins/hooks/RestartSlow.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/RestartSlow.py b/module/plugins/hooks/RestartSlow.py index c2fdf6f95..9a0b43b1a 100644 --- a/module/plugins/hooks/RestartSlow.py +++ b/module/plugins/hooks/RestartSlow.py @@ -33,7 +33,7 @@ class RestartSlow(Hook): def periodical(self): - if not self.pyfile.req.dl: + if not self.pyfile.plugin.req.dl: return if self.getConfig("safe_mode") and not self.pyfile.plugin.resumeDownload: @@ -44,7 +44,7 @@ class RestartSlow(Hook): time = max(30, self.getConfig("%s_time" % type) * 60) limit = max(5, self.getConfig("%s_limit" % type) * 1024) - chunks = [chunk for chunk in self.pyfile.req.dl.chunks \ + chunks = [chunk for chunk in self.pyfile.plugin.req.dl.chunks \ if chunk.id not in self.info['chunk'] or self.info['chunk'][chunk.id] is not (time, limit)] for chunk in chunks: @@ -57,5 +57,5 @@ class RestartSlow(Hook): def downloadStarts(self, pyfile, url, filename): if self.cb or (self.getConfig("safe_mode") and not pyfile.plugin.resumeDownload): return - + self.pyfile = pyfile super(RestartSlow, self).initPeriodical() -- cgit v1.2.3 From 09b692852ae556cb3f40ffb3f607106faecd5758 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20H=C3=B6rnlein?= <jens.hoernlein@googlemail.com> Date: Thu, 5 Feb 2015 18:41:59 +0100 Subject: [ExtractArchive] Error Handling when broken ExtractArchive was used --- module/plugins/hooks/ExtractArchive.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index b52fa026b..4756d359c 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -63,7 +63,10 @@ class ArchiveQueue(object): def get(self): - return [int(pid) for pid in self.plugin.getStorage("ExtractArchive:%s" % self.storage, "").decode('base64').split()] + try: + return [int(pid) for pid in self.plugin.getStorage("ExtractArchive:%s" % self.storage, "").decode('base64').split()] + except Exception: + return [] def set(self, value): -- cgit v1.2.3 From 767cf1ccb4420e7cb1805bfe302b8909def79679 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20H=C3=B6rnlein?= <jens.hoernlein@googlemail.com> Date: Fri, 6 Feb 2015 21:52:10 +0100 Subject: [ExtractArchive] Fixed: Recursive Extraction --- module/plugins/hooks/ExtractArchive.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 4756d359c..e27c544d6 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -77,10 +77,6 @@ class ArchiveQueue(object): return self.plugin.setStorage("ExtractArchive:%s" % self.storage, item.encode('base64')[:-1]) - def clean(self): - return self.set([]) - - def delete(self): return self.plugin.delStorage("ExtractArchive:%s" % self.storage) @@ -99,6 +95,8 @@ class ArchiveQueue(object): queue.remove(item) except ValueError: pass + if queue == []: + return self.delete() return self.set(queue) @@ -315,7 +313,7 @@ class ExtractArchive(Hook): self.setPermissions(new_files) for filename in new_files: - file = fs_encode(save_join(filename, os.path.dirname(archive.filename))) + file = fs_encode(save_join(os.path.dirname(archive.filename), filename)) if not os.path.exists(file): self.logDebug("New file %s does not exists" % filename) continue -- cgit v1.2.3 From d08c34cb6289ef55c6412d6129e343380f7f20d1 Mon Sep 17 00:00:00 2001 From: stickell <l.stickell@yahoo.it> Date: Sat, 7 Feb 2015 00:03:28 +0100 Subject: [ExtractArchive] bump version number after #1152 --- module/plugins/hooks/ExtractArchive.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index e27c544d6..88036da39 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -104,7 +104,7 @@ class ArchiveQueue(object): class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.25" + __version__ = "1.26" __config__ = [("activated" , "bool" , "Activated" , True ), ("fullpath" , "bool" , "Extract with full paths" , True ), -- cgit v1.2.3 From 23b49f52109942bd8cc121818d054ea134c63e64 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sat, 7 Feb 2015 23:24:13 +0100 Subject: [RestartSlow] Bump up version --- module/plugins/hooks/RestartSlow.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/RestartSlow.py b/module/plugins/hooks/RestartSlow.py index 9a0b43b1a..c3e1e5468 100644 --- a/module/plugins/hooks/RestartSlow.py +++ b/module/plugins/hooks/RestartSlow.py @@ -8,7 +8,7 @@ from module.plugins.Hook import Hook class RestartSlow(Hook): __name__ = "RestartSlow" __type__ = "hook" - __version__ = "0.03" + __version__ = "0.04" __config__ = [("free_limit" , "int" , "Transfer speed threshold in kilobytes" , 100 ), ("free_time" , "int" , "Sample interval in minutes" , 5 ), -- cgit v1.2.3 From b25bc61dd47d8d3c42969bd0f72443b21c4b059e Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sun, 8 Feb 2015 02:09:45 +0100 Subject: Spare code cosmetics --- module/plugins/hooks/AlldebridCom.py | 4 ++-- module/plugins/hooks/Captcha9Kw.py | 6 +++--- module/plugins/hooks/EasybytezCom.py | 4 ++-- module/plugins/hooks/FastixRu.py | 4 ++-- module/plugins/hooks/IRCInterface.py | 4 ++-- module/plugins/hooks/MultishareCz.py | 4 ++-- module/plugins/hooks/OverLoadMe.py | 6 +++--- module/plugins/hooks/PremiumTo.py | 4 ++-- module/plugins/hooks/RealdebridCom.py | 4 ++-- module/plugins/hooks/RehostTo.py | 4 ++-- module/plugins/hooks/SimplydebridCom.py | 4 ++-- 11 files changed, 24 insertions(+), 24 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/AlldebridCom.py b/module/plugins/hooks/AlldebridCom.py index dddd97c0c..fd89571eb 100644 --- a/module/plugins/hooks/AlldebridCom.py +++ b/module/plugins/hooks/AlldebridCom.py @@ -24,6 +24,6 @@ class AlldebridCom(MultiHook): def getHosters(self): https = "https" if self.getConfig("ssl") else "http" - page = self.getURL(https + "://www.alldebrid.com/api.php", get={'action': "get_host"}).replace("\"", "").strip() + html = self.getURL(https + "://www.alldebrid.com/api.php", get={'action': "get_host"}).replace("\"", "").strip() - return [x.strip() for x in page.split(",") if x.strip()] + return [x.strip() for x in html.split(",") if x.strip()] diff --git a/module/plugins/hooks/Captcha9Kw.py b/module/plugins/hooks/Captcha9Kw.py index 1031ef224..544965b0f 100644 --- a/module/plugins/hooks/Captcha9Kw.py +++ b/module/plugins/hooks/Captcha9Kw.py @@ -206,9 +206,9 @@ class Captcha9Kw(Hook): for d in details: hosteroption = d.split("=") - if (len(hosteroption) > 1 - and hosteroption[0].lower() == 'timeout' - and hosteroption[1].isdigit()): + if len(hosteroption) > 1 \ + and hosteroption[0].lower() == 'timeout' \ + and hosteroption[1].isdigit(): timeout = int(hosteroption[1]) break diff --git a/module/plugins/hooks/EasybytezCom.py b/module/plugins/hooks/EasybytezCom.py index e08127514..85c616054 100644 --- a/module/plugins/hooks/EasybytezCom.py +++ b/module/plugins/hooks/EasybytezCom.py @@ -27,6 +27,6 @@ class EasybytezCom(MultiHook): user, data = self.account.selectAccount() req = self.account.getAccountRequest(user) - page = req.load("http://www.easybytez.com") + html = req.load("http://www.easybytez.com") - return re.search(r'</textarea>\s*Supported sites:(.*)', page).group(1).split(',') + return re.search(r'</textarea>\s*Supported sites:(.*)', html).group(1).split(',') diff --git a/module/plugins/hooks/FastixRu.py b/module/plugins/hooks/FastixRu.py index 25126fbd3..6373da8d9 100644 --- a/module/plugins/hooks/FastixRu.py +++ b/module/plugins/hooks/FastixRu.py @@ -23,9 +23,9 @@ class FastixRu(MultiHook): def getHosters(self): - page = self.getURL("http://fastix.ru/api_v2", + html = self.getURL("http://fastix.ru/api_v2", get={'apikey': "5182964c3f8f9a7f0b00000a_kelmFB4n1IrnCDYuIFn2y", 'sub' : "allowed_sources"}) - host_list = json_loads(page) + host_list = json_loads(html) host_list = host_list['allow'] return host_list diff --git a/module/plugins/hooks/IRCInterface.py b/module/plugins/hooks/IRCInterface.py index 98fa1d030..623f2d1bf 100644 --- a/module/plugins/hooks/IRCInterface.py +++ b/module/plugins/hooks/IRCInterface.py @@ -79,10 +79,10 @@ class IRCInterface(Thread, Hook): task.handler.append(self) task.setWaiting(60) - page = getURL("http://www.freeimagehosting.net/upload.php", + html = getURL("http://www.freeimagehosting.net/upload.php", post={"attached": (FORM_FILE, task.captchaFile)}, multipart=True) - url = re.search(r"\[img\]([^\[]+)\[/img\]\[/url\]", page).group(1) + url = re.search(r"\[img\]([^\[]+)\[/img\]\[/url\]", html).group(1) self.response(_("New Captcha Request: %s") % url) self.response(_("Answer with 'c %s text on the captcha'") % task.id) diff --git a/module/plugins/hooks/MultishareCz.py b/module/plugins/hooks/MultishareCz.py index 8349e0de8..d02f4f8e3 100644 --- a/module/plugins/hooks/MultishareCz.py +++ b/module/plugins/hooks/MultishareCz.py @@ -27,5 +27,5 @@ class MultishareCz(MultiHook): def getHosters(self): - page = self.getURL("http://www.multishare.cz/monitoring/") - return re.findall(self.HOSTER_PATTERN, page) + html = self.getURL("http://www.multishare.cz/monitoring/") + return re.findall(self.HOSTER_PATTERN, html) diff --git a/module/plugins/hooks/OverLoadMe.py b/module/plugins/hooks/OverLoadMe.py index 1872f8ccb..b15ce2766 100644 --- a/module/plugins/hooks/OverLoadMe.py +++ b/module/plugins/hooks/OverLoadMe.py @@ -24,8 +24,8 @@ class OverLoadMe(MultiHook): def getHosters(self): https = "https" if self.getConfig("ssl") else "http" - page = self.getURL(https + "://api.over-load.me/hoster.php", + html = self.getURL(https + "://api.over-load.me/hoster.php", get={'auth': "0001-cb1f24dadb3aa487bda5afd3b76298935329be7700cd7-5329be77-00cf-1ca0135f"}).replace("\"", "").strip() - self.logDebug("Hosterlist", page) + self.logDebug("Hosterlist", html) - return [x.strip() for x in page.split(",") if x.strip()] + return [x.strip() for x in html.split(",") if x.strip()] diff --git a/module/plugins/hooks/PremiumTo.py b/module/plugins/hooks/PremiumTo.py index 844ecc89d..b629b111e 100644 --- a/module/plugins/hooks/PremiumTo.py +++ b/module/plugins/hooks/PremiumTo.py @@ -24,6 +24,6 @@ class PremiumTo(MultiHook): def getHosters(self): - page = self.getURL("http://premium.to/api/hosters.php", + html = self.getURL("http://premium.to/api/hosters.php", get={'username': self.account.username, 'password': self.account.password}) - return [x.strip() for x in page.replace("\"", "").split(";")] + return [x.strip() for x in html.replace("\"", "").split(";")] diff --git a/module/plugins/hooks/RealdebridCom.py b/module/plugins/hooks/RealdebridCom.py index cff97c2f9..d9c9407dd 100644 --- a/module/plugins/hooks/RealdebridCom.py +++ b/module/plugins/hooks/RealdebridCom.py @@ -24,6 +24,6 @@ class RealdebridCom(MultiHook): def getHosters(self): https = "https" if self.getConfig("ssl") else "http" - page = self.getURL(https + "://real-debrid.com/api/hosters.php").replace("\"", "").strip() + html = self.getURL(https + "://real-debrid.com/api/hosters.php").replace("\"", "").strip() - return [x.strip() for x in page.split(",") if x.strip()] + return [x.strip() for x in html.split(",") if x.strip()] diff --git a/module/plugins/hooks/RehostTo.py b/module/plugins/hooks/RehostTo.py index ddb8b3eb0..845601c3f 100644 --- a/module/plugins/hooks/RehostTo.py +++ b/module/plugins/hooks/RehostTo.py @@ -23,7 +23,7 @@ class RehostTo(MultiHook): def getHosters(self): user, data = self.account.selectAccount() - page = self.getURL("http://rehost.to/api.php", + html = self.getURL("http://rehost.to/api.php", get={'cmd' : "get_supported_och_dl", 'long_ses': self.account.getAccountInfo(user)['session']}) - return [x.strip() for x in page.replace("\"", "").split(",")] + return [x.strip() for x in html.replace("\"", "").split(",")] diff --git a/module/plugins/hooks/SimplydebridCom.py b/module/plugins/hooks/SimplydebridCom.py index 10c613fb5..4d27f5ae4 100644 --- a/module/plugins/hooks/SimplydebridCom.py +++ b/module/plugins/hooks/SimplydebridCom.py @@ -22,5 +22,5 @@ class SimplydebridCom(MultiHook): def getHosters(self): - page = self.getURL("http://simply-debrid.com/api.php", get={'list': 1}) - return [x.strip() for x in page.rstrip(';').replace("\"", "").split(";")] + html = self.getURL("http://simply-debrid.com/api.php", get={'list': 1}) + return [x.strip() for x in html.rstrip(';').replace("\"", "").split(";")] -- cgit v1.2.3 From 3cea8ed5afb68060951cb20a6e07e3d0dca01e24 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sun, 8 Feb 2015 02:10:34 +0100 Subject: [ExternalScripts] Wait option --- module/plugins/hooks/ExternalScripts.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index bbd442963..42f4ec481 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -12,9 +12,10 @@ from module.utils import save_join class ExternalScripts(Hook): __name__ = "ExternalScripts" __type__ = "hook" - __version__ = "0.27" + __version__ = "0.28" - __config__ = [("activated", "bool", "Activated", True)] + __config__ = [("activated", "bool", "Activated" , True), + ("wait" , "bool", "Wait script ending", True)] __description__ = """Run external scripts""" __license__ = "GPLv3" @@ -58,6 +59,7 @@ class ExternalScripts(Hook): if not os.path.exists(path): try: os.makedirs(path) + except Exception: self.logDebug("Script folder %s not created" % folder) return @@ -75,9 +77,13 @@ class ExternalScripts(Hook): def callScript(self, script, *args): try: cmd = [script] + [str(x) if not isinstance(x, basestring) else x for x in args] + self.logDebug("Executing", os.path.abspath(script), " ".join(cmd)) - #output goes to pyload - subprocess.Popen(cmd, bufsize=-1) + + p = subprocess.Popen(cmd, bufsize=-1) #@NOTE: output goes to pyload + if self.getConfig('wait'): + p.communicate() + except Exception, e: self.logError(_("Error in %(script)s: %(error)s") % {"script": os.path.basename(script), "error": e}) -- cgit v1.2.3 From 45295be158d77aa38e7803fbcd90d7ad4ddc7961 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sun, 8 Feb 2015 14:08:55 +0100 Subject: [ExternalScripts] Wait option (2) --- module/plugins/hooks/ExternalScripts.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index 42f4ec481..8bd803308 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -12,10 +12,10 @@ from module.utils import save_join class ExternalScripts(Hook): __name__ = "ExternalScripts" __type__ = "hook" - __version__ = "0.28" + __version__ = "0.29" - __config__ = [("activated", "bool", "Activated" , True), - ("wait" , "bool", "Wait script ending", True)] + __config__ = [("activated", "bool", "Activated" , True ), + ("wait" , "bool", "Wait script ending", False)] __description__ = """Run external scripts""" __license__ = "GPLv3" -- cgit v1.2.3 From c5daf5fa18490ff5977f06416b14bf0474822974 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20H=C3=B6rnlein?= <jens.hoernlein@googlemail.com> Date: Sat, 7 Feb 2015 03:08:28 +0100 Subject: [ExtractArchive] Fix: Show Status/Progressbar --- module/plugins/hooks/ExtractArchive.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 88036da39..81655b108 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -198,14 +198,14 @@ class ExtractArchive(Hook): @threaded - def allDownloadsProcessed(self): - if self.extract(self.queue.get()): #@NOTE: check only if all gone fine, no failed reporting for now + def allDownloadsProcessed(self, thread): + if self.extract(self.queue.get(), thread): #@NOTE: check only if all gone fine, no failed reporting for now self.manager.dispatchEvent("all_archives_extracted") self.manager.dispatchEvent("all_archives_processed") - def extract(self, ids): + def extract(self, ids, thread=None): if not ids: return False @@ -302,7 +302,7 @@ class ExtractArchive(Hook): fid) archive.init() - new_files = self._extract(archive, fid, pypack.password) + new_files = self._extract(archive, fid, pypack.password, thread) except Exception, e: self.logError(name, e) @@ -348,10 +348,11 @@ class ExtractArchive(Hook): return True if not failed else False - def _extract(self, archive, fid, password): + def _extract(self, archive, fid, password, thread): pyfile = self.core.files.getFile(fid) name = os.path.basename(archive.filename) + thread.addActive(pyfile) pyfile.setStatus("processing") encrypted = False -- cgit v1.2.3 From 2a809297f288a585d96af0d8afd894c2a2f695fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20H=C3=B6rnlein?= <jens.hoernlein@googlemail.com> Date: Sun, 8 Feb 2015 13:47:59 +0100 Subject: [ExtractArchive] correct fullpath behavior, bugfix --- module/plugins/hooks/ExtractArchive.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 81655b108..6c0177ae9 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -104,7 +104,7 @@ class ArchiveQueue(object): class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.26" + __version__ = "1.27" __config__ = [("activated" , "bool" , "Activated" , True ), ("fullpath" , "bool" , "Extract with full paths" , True ), @@ -258,14 +258,14 @@ class ExtractArchive(Hook): matched = False success = True - files_ids = [(save_join(dl, pypack.folder, pylink['name']), pylink['id']) for pylink in pypack.getChildren().itervalues()] + files_ids = [(save_join(dl, pypack.folder, pylink['name']), pylink['id'], out) for pylink in pypack.getChildren().itervalues()] # check as long there are unseen files while files_ids: new_files_ids = [] if extensions: - files_ids = [(fname, fid) for fname, fid in files_ids \ + files_ids = [(fname, fid, fout) for fname, fid, fout in files_ids \ if filter(lambda ext: fname.lower().endswith(ext), extensions)] for Extractor in self.extractors: @@ -274,7 +274,7 @@ class ExtractArchive(Hook): self.logDebug("Targets for %s: %s" % (Extractor.__name__, targets)) matched = True - for fname, fid in targets: + for fname, fid, fout in targets: name = os.path.basename(fname) pname = replace_patterns(fname, self.NAME_REPLACEMENTS) @@ -283,16 +283,16 @@ class ExtractArchive(Hook): else: self.logDebug(name, "Skipped") continue - + if not os.path.exists(fname): self.logDebug(name, "File not found") continue - self.logInfo(name, _("Extract to: %s") % out) + self.logInfo(name, _("Extract to: %s") % fout) try: archive = Extractor(self, fname, - out, + fout, fullpath, overwrite, excludefiles, @@ -319,7 +319,7 @@ class ExtractArchive(Hook): continue if recursive and os.path.isfile(file): - new_files_ids.append((filename, fid)) # append as new target + new_files_ids.append((filename, fid, os.path.dirname(filename))) # append as new target files_ids = new_files_ids # also check extracted files -- cgit v1.2.3 From 25fc80b4e973049ff85122fefac9fbf8c2bf4c45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20H=C3=B6rnlein?= <jens.hoernlein@googlemail.com> Date: Sun, 8 Feb 2015 17:03:27 +0100 Subject: [ExtractArchive] don't try '' as password --- module/plugins/hooks/ExtractArchive.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 6c0177ae9..a0c0ca366 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -104,7 +104,7 @@ class ArchiveQueue(object): class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.27" + __version__ = "1.28" __config__ = [("activated" , "bool" , "Activated" , True ), ("fullpath" , "bool" , "Extract with full paths" , True ), @@ -392,7 +392,7 @@ class ExtractArchive(Hook): if not encrypted or not self.getConfig("usepasswordfile"): archive.extract(password) else: - for pw in uniqify([password] + self.getPasswords(False)): + for pw in filter(None, uniqify([password] + self.getPasswords(False))): try: self.logDebug("Try password: %s" % pw) -- cgit v1.2.3 From 2dc3536e36956eab99fa5f7945dcf60073b5fd57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20H=C3=B6rnlein?= <jens.hoernlein@googlemail.com> Date: Mon, 9 Feb 2015 23:36:10 +0100 Subject: [ExtractArchive] better Multipart behavior, new version output --- module/plugins/hooks/ExtractArchive.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index a0c0ca366..3ea8839dc 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -104,7 +104,7 @@ class ArchiveQueue(object): class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.28" + __version__ = "1.29" __config__ = [("activated" , "bool" , "Activated" , True ), ("fullpath" , "bool" , "Extract with full paths" , True ), @@ -124,7 +124,8 @@ class ExtractArchive(Hook): __description__ = """Extract different kind of archives""" __license__ = "GPLv3" - __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] + __authors__ = [("Walter Purcaro", "vuolter@gmail.com"), + ("Immenz" , "immenz@gmx.net" )] event_list = ["allDownloadsProcessed"] @@ -171,7 +172,7 @@ class ExtractArchive(Hook): print_exc() if self.extractors: - self.logInfo(_("Activated") + " " + " ".join(Extractor.__name__ for Extractor in self.extractors)) + self.logInfo(_("Activated") + " " + "|".join("%s %s" % (Extractor.__name__,Extractor.VERSION) for Extractor in self.extractors)) if self.getConfig("waitall"): self.extractPackage(*self.queue.get()) #: Resume unfinished extractions @@ -277,13 +278,6 @@ class ExtractArchive(Hook): for fname, fid, fout in targets: name = os.path.basename(fname) - pname = replace_patterns(fname, self.NAME_REPLACEMENTS) - if pname not in processed: - processed.append(pname) #: prevent extracting same file twice - else: - self.logDebug(name, "Skipped") - continue - if not os.path.exists(fname): self.logDebug(name, "File not found") continue @@ -309,6 +303,7 @@ class ExtractArchive(Hook): success = False continue + files_ids.remove((fname, fid, fout)) # don't let other extractors spam log self.logDebug("Extracted files: %s" % new_files) self.setPermissions(new_files) -- cgit v1.2.3 From e58ca4183db292918e4434b22739761185a74b8d Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Wed, 11 Feb 2015 04:26:40 +0100 Subject: [AndroidPhoneNotify][WindowsPhoneNotify] Don't use storage --- module/plugins/hooks/AndroidPhoneNotify.py | 9 +-- module/plugins/hooks/WindowsPhoneNotify.py | 96 +++++++++++++++++++++++++ module/plugins/hooks/WindowsPhoneToastNotify.py | 95 ------------------------ 3 files changed, 101 insertions(+), 99 deletions(-) create mode 100644 module/plugins/hooks/WindowsPhoneNotify.py delete mode 100644 module/plugins/hooks/WindowsPhoneToastNotify.py (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/AndroidPhoneNotify.py b/module/plugins/hooks/AndroidPhoneNotify.py index fbc2acd5c..d4536842d 100644 --- a/module/plugins/hooks/AndroidPhoneNotify.py +++ b/module/plugins/hooks/AndroidPhoneNotify.py @@ -9,7 +9,7 @@ from module.plugins.Hook import Hook class AndroidPhoneNotify(Hook): __name__ = "AndroidPhoneNotify" __type__ = "hook" - __version__ = "0.03" + __version__ = "0.04" __config__ = [("apikey" , "str" , "API key" , "" ), ("notifycaptcha" , "bool", "Notify captcha request" , True ), @@ -33,14 +33,15 @@ class AndroidPhoneNotify(Hook): def setup(self): - self.info = {} #@TODO: Remove in 0.4.10 + self.info = {} #@TODO: Remove in 0.4.10 + self.last_notify = 0 def newCaptchaTask(self, task): if not self.getConfig("notifycaptcha"): return False - if time() - float(self.getStorage("AndroidPhoneNotify", 0)) < self.getConf("timeout"): + if time() - self.last_notify < self.getConf("timeout"): return False self.notify(_("Captcha"), _("New request waiting user input")) @@ -76,4 +77,4 @@ class AndroidPhoneNotify(Hook): 'event' : event, 'description': msg}) - self.setStorage("AndroidPhoneNotify", time()) + self.last_notify = time() diff --git a/module/plugins/hooks/WindowsPhoneNotify.py b/module/plugins/hooks/WindowsPhoneNotify.py new file mode 100644 index 000000000..821b9643c --- /dev/null +++ b/module/plugins/hooks/WindowsPhoneNotify.py @@ -0,0 +1,96 @@ +# -*- coding: utf-8 -*- + +import httplib + +from time import time + +from module.plugins.Hook import Hook + + +class WindowsPhoneNotify(Hook): + __name__ = "WindowsPhoneNotify" + __type__ = "hook" + __version__ = "0.06" + + __config__ = [("id" , "str" , "Push ID" , "" ), + ("url" , "str" , "Push url" , "" ), + ("notifycaptcha" , "bool", "Notify captcha request" , True ), + ("notifypackage" , "bool", "Notify package finished" , True ), + ("notifyprocessed", "bool", "Notify processed packages status" , True ), + ("timeout" , "int" , "Timeout between captchas in seconds" , 5 ), + ("force" , "bool", "Send notifications if client is connected", False)] + + __description__ = """Send push notifications to Windows Phone""" + __license__ = "GPLv3" + __authors__ = [("Andy Voigt", "phone-support@hotmail.de"), + ("Walter Purcaro", "vuolter@gmail.com")] + + + event_list = ["allDownloadsProcessed"] + + + #@TODO: Remove in 0.4.10 + def initPeriodical(self): + pass + + + def setup(self): + self.info = {} #@TODO: Remove in 0.4.10 + self.last_notify = 0 + + + def newCaptchaTask(self, task): + if not self.getConfig("notifycaptcha"): + return False + + if time() - self.last_notify < self.getConf("timeout"): + return False + + self.notify(_("Captcha"), _("New request waiting user input")) + + + def packageFinished(self, pypack): + if self.getConfig("notifypackage"): + self.notify(_("Package finished"), pypack.name) + + + def allDownloadsProcessed(self): + if not self.getConfig("notifyprocessed"): + return False + + if any(True for pdata in self.core.api.getQueue() if pdata.linksdone < pdata.linkstotal): + self.notify(_("Package failed"), _("One or more packages was not completed successfully")) + else: + self.notify(_("All packages finished")) + + + def getXmlData(self, msg): + return ("<?xml version='1.0' encoding='utf-8'?> <wp:Notification xmlns:wp='WPNotification'> " + "<wp:Toast> <wp:Text1>pyLoad</wp:Text1> <wp:Text2>%s</wp:Text2> " + "</wp:Toast> </wp:Notification>" % msg) + + + def notify(self, event, msg=""): + id = self.getConfig("id") + url = self.getConfig("url") + + if not id or not url: + return False + + if self.core.isClientConnected() and not self.getConfig("force"): + return False + + request = self.getXmlData("%s: %s" % (event, msg) if msg else event) + webservice = httplib.HTTP(url) + + webservice.putrequest("POST", id) + webservice.putheader("Host", url) + webservice.putheader("Content-type", "text/xml") + webservice.putheader("X-NotificationClass", "2") + webservice.putheader("X-WindowsPhone-Target", "toast") + webservice.putheader("Content-length", "%d" % len(request)) + webservice.endheaders() + webservice.send(request) + webservice.close() + + self.last_notify = time() diff --git a/module/plugins/hooks/WindowsPhoneToastNotify.py b/module/plugins/hooks/WindowsPhoneToastNotify.py deleted file mode 100644 index 20686ee36..000000000 --- a/module/plugins/hooks/WindowsPhoneToastNotify.py +++ /dev/null @@ -1,95 +0,0 @@ -# -*- coding: utf-8 -*- - -import httplib - -from time import time - -from module.plugins.Hook import Hook - - -class WindowsPhoneToastNotify(Hook): - __name__ = "WindowsPhoneToastNotify" - __type__ = "hook" - __version__ = "0.05" - - __config__ = [("id" , "str" , "Push ID" , "" ), - ("url" , "str" , "Push url" , "" ), - ("notifycaptcha" , "bool", "Notify captcha request" , True ), - ("notifypackage" , "bool", "Notify package finished" , True ), - ("notifyprocessed", "bool", "Notify processed packages status" , True ), - ("timeout" , "int" , "Timeout between captchas in seconds" , 5 ), - ("force" , "bool", "Send notifications if client is connected", False)] - - __description__ = """Send push notifications to Windows Phone""" - __license__ = "GPLv3" - __authors__ = [("Andy Voigt", "phone-support@hotmail.de"), - ("Walter Purcaro", "vuolter@gmail.com")] - - - event_list = ["allDownloadsProcessed"] - - - #@TODO: Remove in 0.4.10 - def initPeriodical(self): - pass - - - def setup(self): - self.info = {} #@TODO: Remove in 0.4.10 - - - def newCaptchaTask(self, task): - if not self.getConfig("notifycaptcha"): - return False - - if time() - float(self.getStorage("WindowsPhoneToastNotify", 0)) < self.getConf("timeout"): - return False - - self.notify(_("Captcha"), _("New request waiting user input")) - - - def packageFinished(self, pypack): - if self.getConfig("notifypackage"): - self.notify(_("Package finished"), pypack.name) - - - def allDownloadsProcessed(self): - if not self.getConfig("notifyprocessed"): - return False - - if any(True for pdata in self.core.api.getQueue() if pdata.linksdone < pdata.linkstotal): - self.notify(_("Package failed"), _("One or more packages was not completed successfully")) - else: - self.notify(_("All packages finished")) - - - def getXmlData(self, msg): - return ("<?xml version='1.0' encoding='utf-8'?> <wp:Notification xmlns:wp='WPNotification'> " - "<wp:Toast> <wp:Text1>pyLoad</wp:Text1> <wp:Text2>%s</wp:Text2> " - "</wp:Toast> </wp:Notification>" % msg) - - - def notify(self, event, msg=""): - id = self.getConfig("id") - url = self.getConfig("url") - - if not id or not url: - return False - - if self.core.isClientConnected() and not self.getConfig("force"): - return False - - request = self.getXmlData("%s: %s" % (event, msg) if msg else event) - webservice = httplib.HTTP(url) - - webservice.putrequest("POST", id) - webservice.putheader("Host", url) - webservice.putheader("Content-type", "text/xml") - webservice.putheader("X-NotificationClass", "2") - webservice.putheader("X-WindowsPhone-Target", "toast") - webservice.putheader("Content-length", "%d" % len(request)) - webservice.endheaders() - webservice.send(request) - webservice.close() - - self.setStorage("WindowsPhoneToastNotify", time()) -- cgit v1.2.3 From ee6746b16c8f56d24f48f55387fee799d8e28b4d Mon Sep 17 00:00:00 2001 From: Stefano <l.stickell@yahoo.it> Date: Wed, 11 Feb 2015 18:40:04 +0100 Subject: [UpdateManager] Bump version number to refresh broken plugins See #1168 --- module/plugins/hooks/AndroidPhoneNotify.py | 2 +- module/plugins/hooks/WindowsPhoneNotify.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/AndroidPhoneNotify.py b/module/plugins/hooks/AndroidPhoneNotify.py index d4536842d..a3b24a255 100644 --- a/module/plugins/hooks/AndroidPhoneNotify.py +++ b/module/plugins/hooks/AndroidPhoneNotify.py @@ -9,7 +9,7 @@ from module.plugins.Hook import Hook class AndroidPhoneNotify(Hook): __name__ = "AndroidPhoneNotify" __type__ = "hook" - __version__ = "0.04" + __version__ = "0.05" __config__ = [("apikey" , "str" , "API key" , "" ), ("notifycaptcha" , "bool", "Notify captcha request" , True ), diff --git a/module/plugins/hooks/WindowsPhoneNotify.py b/module/plugins/hooks/WindowsPhoneNotify.py index 821b9643c..e0dd75f92 100644 --- a/module/plugins/hooks/WindowsPhoneNotify.py +++ b/module/plugins/hooks/WindowsPhoneNotify.py @@ -10,7 +10,7 @@ from module.plugins.Hook import Hook class WindowsPhoneNotify(Hook): __name__ = "WindowsPhoneNotify" __type__ = "hook" - __version__ = "0.06" + __version__ = "0.07" __config__ = [("id" , "str" , "Push ID" , "" ), ("url" , "str" , "Push url" , "" ), -- cgit v1.2.3 From fd7e1994a94c58aa0ba69808223f5f6a9b99f718 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Thu, 12 Feb 2015 00:02:41 +0100 Subject: [ClickAndLoad] Fix https://github.com/pyload/pyload/issues/1158 --- module/plugins/hooks/ClickAndLoad.py | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 0bcd6ddef..40e6ded65 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -10,16 +10,16 @@ from module.plugins.Hook import Hook, threaded def forward(source, destination): try: - size = 1024 - data = source.recv(size) + bufsize = 1024 + data = source.recv(bufsize) while data: destination.sendall(data) - data = source.recv(size) + data = source.recv(bufsize) finally: destination.shutdown(socket.SHUT_WR) -#: socket.create_connection wrapper for python 2.5 +#: create_connection wrapper for python 2.5 socket module def create_connection(address, timeout=object(), source_address=None): if hasattr(socket, 'create_connection'): if type(timeout) == object: @@ -56,7 +56,7 @@ def create_connection(address, timeout=object(), source_address=None): class ClickAndLoad(Hook): __name__ = "ClickAndLoad" __type__ = "hook" - __version__ = "0.33" + __version__ = "0.34" __config__ = [("activated", "bool", "Activated" , True ), ("port" , "int" , "Port" , 9666 ), @@ -72,7 +72,7 @@ class ClickAndLoad(Hook): if not self.config['webinterface']['activated']: return - ip = "0.0.0.0" if self.getConfig("extern") else "127.0.0.1" + ip = socket.gethostbyname(socket.gethostname()) if self.getConfig("extern") else "127.0.0.1" webport = int(self.config['webinterface']['port']) cnlport = self.getConfig('port') @@ -89,22 +89,23 @@ class ClickAndLoad(Hook): def server(self, ip, webport, cnlport): try: - dock_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - dock_socket.bind((ip, cnlport)) - dock_socket.listen(5) + server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + server_socket.bind((ip, cnlport)) + server_socket.listen(5) while True: - client_socket = dock_socket.accept()[0] - server_socket = create_connection(("127.0.0.1", webport)) + client_socket = server_socket.accept()[0] + dock_socket = create_connection(("127.0.0.1", webport)) - self.manager.startThread(forward, client_socket, server_socket) - self.manager.startThread(forward, server_socket, client_socket) + self.manager.startThread(forward, client_socket, dock_socket) + self.manager.startThread(forward, dock_socket, client_socket) + client_socket.close() + dock_socket.close() except socket.error, e: self.logDebug(e) self.server(ip, webport, cnlport) finally: - client_socket.close() server_socket.close() - dock_socket.close() -- cgit v1.2.3 From 65a02207360423ea83314eb3ea3178095c1bbd2e Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Thu, 12 Feb 2015 00:29:23 +0100 Subject: [ClickAndLoad] Small code cosmetics --- module/plugins/hooks/ClickAndLoad.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 40e6ded65..d0f340aae 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -3,7 +3,6 @@ import socket from threading import Thread, Lock -from time import sleep from module.plugins.Hook import Hook, threaded @@ -100,6 +99,7 @@ class ClickAndLoad(Hook): self.manager.startThread(forward, client_socket, dock_socket) self.manager.startThread(forward, dock_socket, client_socket) + client_socket.close() dock_socket.close() -- cgit v1.2.3 From 71abae13c5f866e3e2b609ea2da3ab86405840ff Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Thu, 12 Feb 2015 02:48:03 +0100 Subject: [SkipRev] Fix https://github.com/pyload/pyload/issues/1007 --- module/plugins/hooks/SkipRev.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py index 51d385bb4..0bbdec3b2 100644 --- a/module/plugins/hooks/SkipRev.py +++ b/module/plugins/hooks/SkipRev.py @@ -18,7 +18,7 @@ def _setup(self): class SkipRev(Hook): __name__ = "SkipRev" __type__ = "hook" - __version__ = "0.24" + __version__ = "0.25" __config__ = [("tokeep", "int", "Number of rev files to keep for package (-1 to auto)", -1)] @@ -60,10 +60,12 @@ class SkipRev(Hook): tokeep = self.getConfig("tokeep") if tokeep: - saved = [True for link in self.core.api.getPackageData(pyfile.package().id).links \ - if link.name.endswith(".rev") and link.status in (0, 12)].count(True) + status_list = (1, 4, 8, 9, 14) if tokeep < 0 else (1, 3, 4, 8, 9, 14) - if not saved or saved < tokeep: #: keep one rev at least in auto mode + queued = [True for link in self.core.api.getPackageData(pyfile.package().id).links \ + if link.name.endswith(".rev") and link.status not in status_list].count(True) + + if not queued or queued < tokeep: #: keep one rev at least in auto mode return pyfile.setCustomStatus("SkipRev", "skipped") -- cgit v1.2.3 From 8ef57f185a386883da33c83ccdd96a12d51f03b8 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sun, 15 Feb 2015 01:51:37 +0100 Subject: [ClickAndLoad] Fixup --- module/plugins/hooks/ClickAndLoad.py | 49 +++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 18 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index d0f340aae..8b53872e4 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -2,7 +2,7 @@ import socket -from threading import Thread, Lock +from threading import Lock from module.plugins.Hook import Hook, threaded @@ -10,10 +10,10 @@ from module.plugins.Hook import Hook, threaded def forward(source, destination): try: bufsize = 1024 - data = source.recv(bufsize) - while data: - destination.sendall(data) - data = source.recv(bufsize) + bufdata = source.recv(bufsize) + while bufdata: + destination.sendall(bufdata) + bufdata = source.recv(bufsize) finally: destination.shutdown(socket.SHUT_WR) @@ -55,11 +55,11 @@ def create_connection(address, timeout=object(), source_address=None): class ClickAndLoad(Hook): __name__ = "ClickAndLoad" __type__ = "hook" - __version__ = "0.34" + __version__ = "0.35" - __config__ = [("activated", "bool", "Activated" , True ), - ("port" , "int" , "Port" , 9666 ), - ("extern" , "bool", "Listen for requests coming from WAN (internet)", False)] + __config__ = [("activated", "bool", "Activated" , True), + ("port" , "int" , "Port" , 9666), + ("extern" , "bool", "Listen on the public network interface", True)] __description__ = """Click'N'Load hook plugin""" __license__ = "GPLv3" @@ -67,6 +67,11 @@ class ClickAndLoad(Hook): ("Walter Purcaro", "vuolter@gmail.com")] + #@TODO: Remove in 0.4.10 + def initPeriodical(self): + pass + + def coreReady(self): if not self.config['webinterface']['activated']: return @@ -80,13 +85,13 @@ class ClickAndLoad(Hook): @threaded def proxy(self, ip, webport, cnlport): - self.manager.startThread(self.server, ip, webport, cnlport) + self.manager.startThread(self._server, ip, webport, cnlport) lock = Lock() lock.acquire() lock.acquire() - def server(self, ip, webport, cnlport): + def _server(self, ip, webport, cnlport, thread): try: server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) @@ -97,15 +102,23 @@ class ClickAndLoad(Hook): client_socket = server_socket.accept()[0] dock_socket = create_connection(("127.0.0.1", webport)) - self.manager.startThread(forward, client_socket, dock_socket) self.manager.startThread(forward, dock_socket, client_socket) - - client_socket.close() - dock_socket.close() + self.manager.startThread(forward, client_socket, dock_socket) except socket.error, e: self.logDebug(e) - self.server(ip, webport, cnlport) + self._server(ip, webport, cnlport, thread) - finally: - server_socket.close() + except Exception, e: + self.logError(e) + + try: + client_socket.close() + dock_socket.close() + except Exception: + pass + + try: + server_socket.close() + except Exception: + pass -- cgit v1.2.3 From e98807ebce1220afdac21e7dfabe04f7ee2acdcf Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Wed, 18 Feb 2015 22:09:19 +0100 Subject: [ClickAndLoad] Fix https://github.com/pyload/pyload/issues/1186 --- module/plugins/hooks/ClickAndLoad.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 8b53872e4..a0eacd10f 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -21,7 +21,7 @@ def forward(source, destination): #: create_connection wrapper for python 2.5 socket module def create_connection(address, timeout=object(), source_address=None): if hasattr(socket, 'create_connection'): - if type(timeout) == object: + if type(timeout) is object: timeout = socket._GLOBAL_DEFAULT_TIMEOUT return socket.create_connection(address, timeout, source_address) @@ -29,11 +29,11 @@ def create_connection(address, timeout=object(), source_address=None): else: host, port = address err = None - for res in getaddrinfo(host, port, 0, SOCK_STREAM): + for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM): af, socktype, proto, canonname, sa = res sock = None try: - sock = socket(af, socktype, proto) + sock = socket.socket(af, socktype, proto) if type(timeout) != object: sock.settimeout(timeout) if source_address: @@ -41,21 +41,18 @@ def create_connection(address, timeout=object(), source_address=None): sock.connect(sa) return sock - except socket.error, _: - err = _ + except socket.error, e: + err = e if sock is not None: sock.close() - - if err is not None: - raise err else: - raise socket.error("getaddrinfo returns an empty list") + raise socket.error(err or "getaddrinfo returns an empty list") class ClickAndLoad(Hook): __name__ = "ClickAndLoad" __type__ = "hook" - __version__ = "0.35" + __version__ = "0.36" __config__ = [("activated", "bool", "Activated" , True), ("port" , "int" , "Port" , 9666), @@ -76,7 +73,7 @@ class ClickAndLoad(Hook): if not self.config['webinterface']['activated']: return - ip = socket.gethostbyname(socket.gethostname()) if self.getConfig("extern") else "127.0.0.1" + ip = "0.0.0.0" if self.getConfig("extern") else "127.0.0.1" webport = int(self.config['webinterface']['port']) cnlport = self.getConfig('port') @@ -85,6 +82,7 @@ class ClickAndLoad(Hook): @threaded def proxy(self, ip, webport, cnlport): + self.logInfo(_("Proxy listening on %s:%s") % (ip, cnlport)) self.manager.startThread(self._server, ip, webport, cnlport) lock = Lock() lock.acquire() -- cgit v1.2.3 From ada50c34aecdedbc0fcecb59ce941bc650ff02e5 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Thu, 19 Feb 2015 01:11:30 +0100 Subject: [XFileSharingPro] Remove 180upload.com from HOSTER_BUILTIN --- module/plugins/hooks/XFileSharingPro.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/XFileSharingPro.py b/module/plugins/hooks/XFileSharingPro.py index a1ee7f5ef..495140652 100644 --- a/module/plugins/hooks/XFileSharingPro.py +++ b/module/plugins/hooks/XFileSharingPro.py @@ -8,7 +8,7 @@ from module.plugins.Hook import Hook class XFileSharingPro(Hook): __name__ = "XFileSharingPro" __type__ = "hook" - __version__ = "0.31" + __version__ = "0.32" __config__ = [("activated" , "bool", "Activated" , True ), ("use_hoster_list" , "bool", "Load listed hosters only" , False), @@ -29,7 +29,7 @@ class XFileSharingPro(Hook): r'https?://(?:[^/]+\.)?(?P<DOMAIN>%s)/(?:user|folder)s?/\w+')} HOSTER_BUILTIN = [#WORKING HOSTERS: - "180upload.com", "backin.net", "eyesfile.ca", "file4safe.com", "fileband.com", "filedwon.com", + "backin.net", "eyesfile.ca", "file4safe.com", "fileband.com", "filedwon.com", "fileparadox.in", "filevice.com", "hostingbulk.com", "junkyvideo.com", "linestorage.com", "ravishare.com", "ryushare.com", "salefiles.com", "sendmyway.com", "sharesix.com", "thefile.me", "verzend.be", "xvidstage.com", #NOT TESTED: -- cgit v1.2.3 From 547e5991a861c68d3b87d59eda3aeb8b41116cbd Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Fri, 20 Feb 2015 16:20:42 +0100 Subject: [ClickAndLoad] Improve --- module/plugins/hooks/ClickAndLoad.py | 81 ++++++++++++------------------------ 1 file changed, 27 insertions(+), 54 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index a0eacd10f..0d95a801d 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import socket +import time from threading import Lock @@ -18,41 +19,11 @@ def forward(source, destination): destination.shutdown(socket.SHUT_WR) -#: create_connection wrapper for python 2.5 socket module -def create_connection(address, timeout=object(), source_address=None): - if hasattr(socket, 'create_connection'): - if type(timeout) is object: - timeout = socket._GLOBAL_DEFAULT_TIMEOUT - - return socket.create_connection(address, timeout, source_address) - - else: - host, port = address - err = None - for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM): - af, socktype, proto, canonname, sa = res - sock = None - try: - sock = socket.socket(af, socktype, proto) - if type(timeout) != object: - sock.settimeout(timeout) - if source_address: - sock.bind(source_address) - sock.connect(sa) - return sock - - except socket.error, e: - err = e - if sock is not None: - sock.close() - else: - raise socket.error(err or "getaddrinfo returns an empty list") - - +#@TODO: IPv6 support class ClickAndLoad(Hook): __name__ = "ClickAndLoad" __type__ = "hook" - __version__ = "0.36" + __version__ = "0.37" __config__ = [("activated", "bool", "Activated" , True), ("port" , "int" , "Port" , 9666), @@ -73,7 +44,7 @@ class ClickAndLoad(Hook): if not self.config['webinterface']['activated']: return - ip = "0.0.0.0" if self.getConfig("extern") else "127.0.0.1" + ip = "" if self.getConfig("extern") else "127.0.0.1" webport = int(self.config['webinterface']['port']) cnlport = self.getConfig('port') @@ -91,32 +62,34 @@ class ClickAndLoad(Hook): def _server(self, ip, webport, cnlport, thread): try: - server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) - server_socket.bind((ip, cnlport)) - server_socket.listen(5) + try: + server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - while True: - client_socket = server_socket.accept()[0] - dock_socket = create_connection(("127.0.0.1", webport)) + server_socket.bind((ip, cnlport)) + server_socket.listen(5) - self.manager.startThread(forward, dock_socket, client_socket) - self.manager.startThread(forward, client_socket, dock_socket) + while True: + client_socket = server_socket.accept()[0] + dock_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - except socket.error, e: - self.logDebug(e) - self._server(ip, webport, cnlport, thread) + dock_socket.connect(("127.0.0.1", webport)) - except Exception, e: - self.logError(e) + self.manager.startThread(forward, dock_socket, client_socket) + self.manager.startThread(forward, client_socket, dock_socket) - try: + except socket.timeout: + self.logDebug("Connection timed out, retrying...") + return self._server(ip, webport, cnlport, thread) + + finally: + server_socket.close() client_socket.close() dock_socket.close() - except Exception: - pass - try: - server_socket.close() - except Exception: - pass + except socket.error, e: + self.logError(e) + time.sleep(120) + self._server(ip, webport, cnlport, thread) + + except Exception, e: + self.logError(e) -- cgit v1.2.3 From d371d98a4a6a803efce3f1cfc779ee2b887cd4e7 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Fri, 20 Feb 2015 16:21:36 +0100 Subject: [ClickAndLoad] Improve (2) --- module/plugins/hooks/ClickAndLoad.py | 3 --- 1 file changed, 3 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 0d95a801d..6691bb1fe 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -90,6 +90,3 @@ class ClickAndLoad(Hook): self.logError(e) time.sleep(120) self._server(ip, webport, cnlport, thread) - - except Exception, e: - self.logError(e) -- cgit v1.2.3 From 56caf611ab8f733ac8a7ea09d2a3d492bd485762 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20H=C3=B6rnlein?= <jens.hoernlein@googlemail.com> Date: Sun, 22 Feb 2015 03:09:40 +0100 Subject: Some more changes --- module/plugins/hooks/ExtractArchive.py | 161 +++++++++++++++++++-------------- 1 file changed, 94 insertions(+), 67 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 3ea8839dc..a1e85ba57 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -104,13 +104,14 @@ class ArchiveQueue(object): class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.29" + __version__ = "1.30" __config__ = [("activated" , "bool" , "Activated" , True ), ("fullpath" , "bool" , "Extract with full paths" , True ), ("overwrite" , "bool" , "Overwrite files" , False ), ("keepbroken" , "bool" , "Try to extract broken archives" , False ), - ("repair" , "bool" , "Repair broken archives" , True ), + ("repair" , "bool" , "Repair broken archives (rar required)" , False ), + ("test" , "bool" , "Test archive before extracting" , False ), ("usepasswordfile" , "bool" , "Use password file" , True ), ("passwordfile" , "file" , "Password file" , "archive_password.txt" ), ("delete" , "bool" , "Delete archive when successfully extracted", False ), @@ -128,35 +129,32 @@ class ExtractArchive(Hook): ("Immenz" , "immenz@gmx.net" )] - event_list = ["allDownloadsProcessed"] + event_list = ["allDownloadsProcessed","packageDeleted"] NAME_REPLACEMENTS = [(r'\.part\d+\.rar$', ".part.rar")] - #@TODO: Remove in 0.4.10 - def initPeriodical(self): - pass - - def setup(self): self.queue = ArchiveQueue(self, "Queue") self.failed = ArchiveQueue(self, "Failed") - self.interval = 60 - self.extracting = False - self.extractors = [] - self.passwords = [] + self.interval = 60 + self.extracting = False + self.lastPackage = False + self.extractors = [] + self.passwords = [] + self.repair = False def coreReady(self): - # self.extracting = False - for p in ("UnRar", "SevenZip", "UnZip"): try: module = self.core.pluginManager.loadModule("internal", p) klass = getattr(module, p) if klass.isUsable(): self.extractors.append(klass) + if klass.REPAIR: + self.repair = self.getConfig("repair") except OSError, e: if e.errno == 2: @@ -173,37 +171,49 @@ class ExtractArchive(Hook): if self.extractors: self.logInfo(_("Activated") + " " + "|".join("%s %s" % (Extractor.__name__,Extractor.VERSION) for Extractor in self.extractors)) - - if self.getConfig("waitall"): - self.extractPackage(*self.queue.get()) #: Resume unfinished extractions - else: - super(ExtractArchive, self).initPeriodical() - + self.extractQueued() #: Resume unfinished extractions else: self.logInfo(_("No Extract plugins activated")) + @threaded + def extractQueued(self,thread): + packages = self.queue.get() + while packages: + if self.lastPackage: # called from allDownloadsProcessed + self.lastPackage = False + if self.extract(packages, thread): #@NOTE: check only if all gone fine, no failed reporting for now + self.manager.dispatchEvent("all_archives_extracted") + self.manager.dispatchEvent("all_archives_processed") + else: + if self.extract(packages, thread): #@NOTE: check only if all gone fine, no failed reporting for now + pass - def periodical(self): - if not self.extracting: - self.extractPackage(*self.queue.get()) + packages = self.queue.get() # check for packages added during extraction @Expose def extractPackage(self, *ids): """ Extract packages with given id""" - self.manager.startThread(self.extract, ids) + for id in ids: + self.queue.add(id) + if not self.getConfig("waitall") and not self.extracting: + self.extractQueued() + + + def packageDeleted(self, pid): + self.queue.remove(pid) def packageFinished(self, pypack): self.queue.add(pypack.id) + if not self.getConfig("waitall") and not self.extracting: + self.extractQueued() - @threaded - def allDownloadsProcessed(self, thread): - if self.extract(self.queue.get(), thread): #@NOTE: check only if all gone fine, no failed reporting for now - self.manager.dispatchEvent("all_archives_extracted") - - self.manager.dispatchEvent("all_archives_processed") + def allDownloadsProcessed(self): + self.lastPackage = True + if not self.extracting: + self.extractQueued() def extract(self, ids, thread=None): @@ -315,13 +325,17 @@ class ExtractArchive(Hook): if recursive and os.path.isfile(file): new_files_ids.append((filename, fid, os.path.dirname(filename))) # append as new target - + + pyfile = self.core.files.getFile(fid) + self.manager.dispatchEvent("archive_extracted", pyfile, archive.out, archive.filename, new_files) + files_ids = new_files_ids # also check extracted files if matched: if success: extracted.append(pid) self.manager.dispatchEvent("package_extracted", pypack) + else: failed.append(pid) self.manager.dispatchEvent("package_extract_failed", pypack) @@ -352,50 +366,65 @@ class ExtractArchive(Hook): encrypted = False try: - try: - archive.check() - - except CRCError, e: - self.logDebug(name, e) - self.logInfo(name, _("Header protected")) - - if self.getConfig("repair"): - self.logWarning(name, _("Repairing...")) - - pyfile.setCustomStatus(_("repairing")) - pyfile.setProgress(0) - - repaired = archive.repair() - - pyfile.setProgress(100) - - if not repaired and not self.getConfig("keepbroken"): - raise CRCError("Archive damaged") - - except PasswordError: - self.logInfo(name, _("Password protected")) - encrypted = True - - except ArchiveError, e: - raise ArchiveError(e) - - self.logDebug("Password: %s" % (password or "No provided")) + self.logDebug("Password: %s" % (password or "None provided")) + passwords = uniqify([password] + self.getPasswords(False)) if self.getConfig("usepasswordfile") else [password] + for pw in passwords: + try: + if self.getConfig("test") or self.repair: + pyfile.setCustomStatus(_("testing")) + if pw: + self.logDebug("Testing with password: %s" % pw) + pyfile.setProgress(0) + archive.test(pw) + pyfile.setProgress(100) + else: + archive.check(pw) + + self.addPassword(pw) + break + + except PasswordError: + if not encrypted: + self.logInfo(name, _("Password protected")) + encrypted = True + + except CRCError, e: + self.logDebug(name, e) + self.logInfo(name, _("CRC Error")) + + if self.repair: + self.logWarning(name, _("Repairing...")) + + pyfile.setCustomStatus(_("repairing")) + pyfile.setProgress(0) + repaired = archive.repair() + pyfile.setProgress(100) + + if not repaired and not self.getConfig("keepbroken"): + raise CRCError("Archive damaged") + + self.addPassword(pw) + break + + raise CRCError("Archive damaged") + + except ArchiveError, e: + raise ArchiveError(e) pyfile.setCustomStatus(_("extracting")) pyfile.setProgress(0) if not encrypted or not self.getConfig("usepasswordfile"): + self.logDebug("Extracting using password: %s" % (password or "None")) archive.extract(password) else: for pw in filter(None, uniqify([password] + self.getPasswords(False))): try: - self.logDebug("Try password: %s" % pw) + self.logDebug("Extracting using password: %s" % pw) - ispw = archive.isPassword(pw) - if ispw or ispw is None: - archive.extract(pw) - self.addPassword(pw) - break + archive.extract(pw) + self.addPassword(pw) + break except PasswordError: self.logDebug("Password was wrong") @@ -419,9 +448,7 @@ class ExtractArchive(Hook): self.logDebug("%s does not exists" % f) self.logInfo(name, _("Extracting finished")) - extracted_files = archive.files or archive.list() - self.manager.dispatchEvent("archive_extracted", pyfile, archive.out, archive.filename, extracted_files) return extracted_files -- cgit v1.2.3 From 8701d26fed036f70f99fa212dff172c3fd0bce28 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sun, 22 Feb 2015 16:42:31 +0100 Subject: [HotFolder] Fixup (thx zapp-brannigan) --- module/plugins/hooks/HotFolder.py | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/HotFolder.py b/module/plugins/hooks/HotFolder.py index 1ff02c319..302bc909f 100644 --- a/module/plugins/hooks/HotFolder.py +++ b/module/plugins/hooks/HotFolder.py @@ -2,10 +2,9 @@ from __future__ import with_statement +import os import time -from os import listdir, makedirs -from os.path import exists, isfile, join from shutil import move from module.plugins.Hook import Hook @@ -15,12 +14,12 @@ from module.utils import fs_encode, save_join class HotFolder(Hook): __name__ = "HotFolder" __type__ = "hook" - __version__ = "0.12" + __version__ = "0.13" - __config__ = [("folder", "str", "Folder to observe", "container"), - ("watch_file", "bool", "Observe link file", False), - ("keep", "bool", "Keep added containers", True), - ("file", "str", "Link file", "links.txt")] + __config__ = [("folder" , "str" , "Folder to observe" , "container"), + ("watch_file", "bool", "Observe link file" , False ), + ("keep" , "bool", "Keep added containers", True ), + ("file" , "str" , "Link file" , "links.txt")] __description__ = """Observe folder and file for changes and add container and links""" __license__ = "GPLv3" @@ -28,36 +27,40 @@ class HotFolder(Hook): def setup(self): - self.interval = 10 + self.interval = 30 def periodical(self): folder = fs_encode(self.getConfig("folder")) + file = fs_encode(self.getConfig("file")) try: - if not exists(join(folder, "finished")): - makedirs(join(folder, "finished")) + if not os.path.isdir(os.path.join(folder, "finished")): + os.makedirs(os.path.join(folder, "finished")) if self.getConfig("watch_file"): - file = fs_encode(self.getConfig("file")) with open(file, "a+") as f: + f.seek(0) content = f.read().strip() if content: - name = "%s_%s.txt" % (self.getConfig("file"), time.strftime("%H-%M-%S_%d%b%Y")) + f = open(file, "wb") + f.close() + + name = "%s_%s.txt" % (file, time.strftime("%H-%M-%S_%d%b%Y")) with open(save_join(folder, "finished", name), "wb") as f: f.write(content) self.core.api.addPackage(f.name, [f.name], 1) - for f in listdir(folder): - path = join(folder, f) + for f in os.listdir(folder): + path = os.path.join(folder, f) - if not isfile(path) or f.endswith("~") or f.startswith("#") or f.startswith("."): + if not os.path.isfile(path) or f.endswith("~") or f.startswith("#") or f.startswith("."): continue - newpath = join(folder, "finished", f if self.getConfig("keep") else "tmp_" + f) + newpath = os.path.join(folder, "finished", f if self.getConfig("keep") else "tmp_" + f) move(path, newpath) self.logInfo(_("Added %s from HotFolder") % f) -- cgit v1.2.3 From c2e18511923ebda7a8a87ef9c35a9cb88c799e19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20H=C3=B6rnlein?= <jens.hoernlein@googlemail.com> Date: Sun, 22 Feb 2015 17:53:32 +0100 Subject: [ExtractArchive] preventing duplicate files extraction --- module/plugins/hooks/ExtractArchive.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index a1e85ba57..8b84966fd 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -104,7 +104,7 @@ class ArchiveQueue(object): class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.30" + __version__ = "1.31" __config__ = [("activated" , "bool" , "Activated" , True ), ("fullpath" , "bool" , "Extract with full paths" , True ), @@ -269,7 +269,8 @@ class ExtractArchive(Hook): matched = False success = True - files_ids = [(save_join(dl, pypack.folder, pylink['name']), pylink['id'], out) for pylink in pypack.getChildren().itervalues()] + files_ids = dict((pylink['name'],((save_join(dl, pypack.folder, pylink['name'])), pylink['id'], out)) for pylink \ + in sorted(pypack.getChildren().itervalues(), key=lambda k: k['name'])).values() # remove duplicates # check as long there are unseen files while files_ids: -- cgit v1.2.3 From 64f4b1f856f3653136f8f0ac7150491598966f67 Mon Sep 17 00:00:00 2001 From: flubshi <flubshi@web.de> Date: Mon, 23 Feb 2015 12:26:22 +0100 Subject: [Hook] Free-way.me: Use login data while getting host list --- module/plugins/hooks/FreeWayMe.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/FreeWayMe.py b/module/plugins/hooks/FreeWayMe.py index 6fec037d8..f819f730d 100644 --- a/module/plugins/hooks/FreeWayMe.py +++ b/module/plugins/hooks/FreeWayMe.py @@ -6,7 +6,7 @@ from module.plugins.internal.MultiHook import MultiHook class FreeWayMe(MultiHook): __name__ = "FreeWayMe" __type__ = "hook" - __version__ = "0.14" + __version__ = "0.15" __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), @@ -22,6 +22,13 @@ class FreeWayMe(MultiHook): def getHosters(self): - hostis = self.getURL("https://www.free-way.me/ajax/jd.php", get={'id': 3}).replace("\"", "").strip() - self.logDebug("Hosters", hostis) + # Get account data + if not self.account or not self.account.canUse(): + hostis = self.getURL("https://www.free-way.me/ajax/jd.php", get={"id": 3}).replace("\"", "").strip() + else: + self.logDebug("AccountInfo available - Get HosterList with User Pass") + (user, data) = self.account.selectAccount() + hostis = self.getURL("https://www.free-way.me/ajax/jd.php", get={"id": 3, "user": user, "pass": data['password']}).replace("\"", "").strip() + + self.logDebug("hosters: %s" % hostis) return [x.strip() for x in hostis.split(",") if x.strip()] -- cgit v1.2.3 From 0e7a0295c60e93a7e095207176e465e82c03dc9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20H=C3=B6rnlein?= <jens.hoernlein@googlemail.com> Date: Tue, 24 Feb 2015 10:28:47 +0100 Subject: [ExtractArchive] fixes https://github.com/pyload/pyload/issues/1206 --- module/plugins/hooks/ExtractArchive.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 8b84966fd..dc0ee3f41 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -104,7 +104,7 @@ class ArchiveQueue(object): class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.31" + __version__ = "1.32" __config__ = [("activated" , "bool" , "Activated" , True ), ("fullpath" , "bool" , "Extract with full paths" , True ), @@ -254,6 +254,7 @@ class ExtractArchive(Hook): pypack = self.core.files.getPackage(pid) if not pypack: + self.queue.remove(pid) continue self.logInfo(_("Check package: %s") % pypack.name) -- cgit v1.2.3 From ed9bbe7332d8f6e2bf33b09ae5382a4925d2eac3 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Tue, 24 Feb 2015 23:57:38 +0100 Subject: [ExternalScripts] Code cosmetics --- module/plugins/hooks/ExternalScripts.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index 8bd803308..3b9c9ca05 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -3,8 +3,6 @@ import os import subprocess -from itertools import chain - from module.plugins.Hook import Hook from module.utils import save_join @@ -142,10 +140,10 @@ class ExternalScripts(Hook): def allDownloadsFinished(self): - for script in chain(self.scripts['all_downloads_finished'], self.scripts['all_dls_finished']): + for script in self.scripts['all_downloads_finished'] + self.scripts['all_dls_finished']): self.callScript(script) def allDownloadsProcessed(self): - for script in chain(self.scripts['all_downloads_processed'], self.scripts['all_dls_processed']): + for script in self.scripts['all_downloads_processed'] + self.scripts['all_dls_processed']: self.callScript(script) -- cgit v1.2.3 From 808d8036fc8cc13c4b26240818bd86ac82567e0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20H=C3=B6rnlein?= <jens.hoernlein@googlemail.com> Date: Wed, 25 Feb 2015 20:25:20 +0100 Subject: [ExternalScripts] Code cosmetics - cosmetics --- module/plugins/hooks/ExternalScripts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index 3b9c9ca05..f49220c2a 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -140,7 +140,7 @@ class ExternalScripts(Hook): def allDownloadsFinished(self): - for script in self.scripts['all_downloads_finished'] + self.scripts['all_dls_finished']): + for script in self.scripts['all_downloads_finished'] + self.scripts['all_dls_finished']: self.callScript(script) -- cgit v1.2.3 From 93eb54614d512396a5505cb9bdea4e201920b434 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sun, 1 Mar 2015 00:33:21 +0100 Subject: Spare code cosmetics --- module/plugins/hooks/ClickAndLoad.py | 2 +- module/plugins/hooks/ExtractArchive.py | 12 ++++++------ module/plugins/hooks/FreeWayMe.py | 2 +- module/plugins/hooks/JustPremium.py | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 6691bb1fe..5b21aec96 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -53,7 +53,7 @@ class ClickAndLoad(Hook): @threaded def proxy(self, ip, webport, cnlport): - self.logInfo(_("Proxy listening on %s:%s") % (ip, cnlport)) + self.logInfo(_("Proxy listening on %s:%s") % (ip or "0.0.0.0", cnlport)) self.manager.startThread(self._server, ip, webport, cnlport) lock = Lock() lock.acquire() diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index dc0ee3f41..c9e43eaaf 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -327,10 +327,10 @@ class ExtractArchive(Hook): if recursive and os.path.isfile(file): new_files_ids.append((filename, fid, os.path.dirname(filename))) # append as new target - + pyfile = self.core.files.getFile(fid) self.manager.dispatchEvent("archive_extracted", pyfile, archive.out, archive.filename, new_files) - + files_ids = new_files_ids # also check extracted files if matched: @@ -381,7 +381,7 @@ class ExtractArchive(Hook): pyfile.setProgress(100) else: archive.check(pw) - + self.addPassword(pw) break @@ -389,7 +389,7 @@ class ExtractArchive(Hook): if not encrypted: self.logInfo(name, _("Password protected")) encrypted = True - + except CRCError, e: self.logDebug(name, e) self.logInfo(name, _("CRC Error")) @@ -407,9 +407,9 @@ class ExtractArchive(Hook): self.addPassword(pw) break - + raise CRCError("Archive damaged") - + except ArchiveError, e: raise ArchiveError(e) diff --git a/module/plugins/hooks/FreeWayMe.py b/module/plugins/hooks/FreeWayMe.py index f819f730d..4e79783bb 100644 --- a/module/plugins/hooks/FreeWayMe.py +++ b/module/plugins/hooks/FreeWayMe.py @@ -29,6 +29,6 @@ class FreeWayMe(MultiHook): self.logDebug("AccountInfo available - Get HosterList with User Pass") (user, data) = self.account.selectAccount() hostis = self.getURL("https://www.free-way.me/ajax/jd.php", get={"id": 3, "user": user, "pass": data['password']}).replace("\"", "").strip() - + self.logDebug("hosters: %s" % hostis) return [x.strip() for x in hostis.split(",") if x.strip()] diff --git a/module/plugins/hooks/JustPremium.py b/module/plugins/hooks/JustPremium.py index b70d8dd2c..30a72c70f 100644 --- a/module/plugins/hooks/JustPremium.py +++ b/module/plugins/hooks/JustPremium.py @@ -12,7 +12,7 @@ class JustPremium(Hook): __config__ = [("excluded", "str", "Exclude hosters (comma separated)", "")] - __description__ = """Remove all not premium links from urls added""" + __description__ = """Remove not-premium links from added urls""" __license__ = "GPLv3" __authors__ = [("mazleu", "mazleica@gmail.com"), ("Walter Purcaro", "vuolter@gmail.com"), -- cgit v1.2.3 From 5eb1729ab45fcdb4862f2b4e54bdb79d7f59a6a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20H=C3=B6rnlein?= <jens.hoernlein@googlemail.com> Date: Sun, 1 Mar 2015 14:14:32 +0100 Subject: [JustPremium] Include hoster to remove --- module/plugins/hooks/JustPremium.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/JustPremium.py b/module/plugins/hooks/JustPremium.py index 30a72c70f..daefbc30f 100644 --- a/module/plugins/hooks/JustPremium.py +++ b/module/plugins/hooks/JustPremium.py @@ -8,9 +8,10 @@ from module.plugins.Hook import Hook class JustPremium(Hook): __name__ = "JustPremium" __type__ = "hook" - __version__ = "0.21" + __version__ = "0.22" - __config__ = [("excluded", "str", "Exclude hosters (comma separated)", "")] + __config__ = [("excluded", "str", "Exclude hosters (comma separated)", ""), + ("included", "str", "Include hosters (comma separated)", "")] __description__ = """Remove not-premium links from added urls""" __license__ = "GPLv3" @@ -32,14 +33,18 @@ class JustPremium(Hook): if 'new_name' in hosterdict[hoster] \ and hosterdict[hoster]['new_name'] in premiumplugins) - #: Found at least one hoster with account or multihoster - if not any(True for pluginname in linkdict if pluginname in premiumplugins | multihosters): - return - excluded = map(lambda domain: "".join(part.capitalize() for part in re.split(r'(\.|\d+)', domain) if part != '.'), self.getConfig('excluded').replace(' ', '').replace(',', '|').replace(';', '|').split('|')) + included = map(lambda domain: "".join(part.capitalize() for part in re.split(r'(\.|\d+)', domain) if part != '.'), + self.getConfig('included').replace(' ', '').replace(',', '|').replace(';', '|').split('|')) + + hosterlist = (premiumplugins | multihosters).union(excluded).difference(included) + + #: Found at least one hoster with account or multihoster + if not any( True for pluginname in linkdict if pluginname in hosterlist ): + return - for pluginname in set(linkdict.keys()) - (premiumplugins | multihosters).union(excluded): + for pluginname in set(linkdict.keys()) - hosterlist: self.logInfo(_("Remove links of plugin: %s") % pluginname) for link in linkdict[pluginname]: self.logDebug("Remove link: %s" % link) -- cgit v1.2.3 From 6c6ff624f7445ad8fb92c5947ad23248d62058c6 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sun, 1 Mar 2015 21:56:38 +0100 Subject: [UpdateManager] Fix https://github.com/pyload/pyload/issues/1089 --- module/plugins/hooks/UpdateManager.py | 76 +++++++++++++++++++++-------------- 1 file changed, 45 insertions(+), 31 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index b6a8bac7c..a0b044edb 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -2,21 +2,33 @@ from __future__ import with_statement +import os import re import sys from operator import itemgetter -from os import path, remove, stat from module.network.RequestFactory import getURL from module.plugins.Hook import Expose, Hook, threaded from module.utils import save_join +# Case-sensitive os.path.exists +def exists(path): + if os.path.exists(path): + if os.name == 'nt': + dir, name = os.path.split(path) + return name in os.listdir(dir) + else: + return True + else: + return False + + class UpdateManager(Hook): __name__ = "UpdateManager" __type__ = "hook" - __version__ = "0.43" + __version__ = "0.44" __config__ = [("activated" , "bool" , "Activated" , True ), ("mode" , "pyLoad + plugins;plugins only", "Check updates for" , "pyLoad + plugins"), @@ -95,10 +107,10 @@ class UpdateManager(Hook): id = (type, name) if type in self.core.pluginManager.plugins: f = m.__file__.replace(".pyc", ".py") - if not path.isfile(f): + if not os.path.isfile(f): continue - mtime = stat(f).st_mtime + mtime = os.stat(f).st_mtime if id not in self.mtimes: self.mtimes[id] = mtime @@ -114,9 +126,10 @@ class UpdateManager(Hook): self.updateThread() - def server_request(self): + def server_response(self): try: return getURL(self.SERVER_URL, get={'v': self.core.api.getServerVersion()}).splitlines() + except Exception: self.logWarning(_("Unable to contact server to get updates")) @@ -142,7 +155,7 @@ class UpdateManager(Hook): @Expose def update(self, onlyplugin=False): """ check for updates """ - data = self.server_request() + data = self.server_response() if not data: exitcode = 0 @@ -202,7 +215,7 @@ class UpdateManager(Hook): break for t, n in self.removePlugins(sorted(blacklisted)): - self.logInfo(_("Removed blacklisted plugin [%(type)s] %(name)s") % { + self.logInfo(_("Removed blacklisted plugin: [%(type)s] %(name)s") % { 'type': t, 'name': n, }) @@ -217,7 +230,7 @@ class UpdateManager(Hook): else: name = filename.replace(".py", "") - #@TODO: obsolete after 0.4.10 + #@TODO: Remove in 0.4.10 if prefix.endswith("s"): type = prefix[:-1] else: @@ -276,35 +289,36 @@ class UpdateManager(Hook): if not type_plugins: return - self.logDebug("Requested deletion of plugins: %s" % type_plugins) + removed = set() - removed = [] + self.logDebug("Requested deletion of plugins: %s" % type_plugins) for type, name in type_plugins: - err = False - file = name + ".py" + rootplugins = os.path.join(pypath, "module", "plugins") - for root in ("userplugins", path.join(pypath, "module", "plugins")): + for dir in ("userplugins", rootplugins): + py_filename = save_join(dir, type, name + ".py") + pyc_filename = py_filename + "c" - filename = save_join(root, type, file) - try: - remove(filename) - except Exception, e: - self.logDebug("Error removing: %s" % path.basename(filename), str(e)) - err = True - - filename += "c" - if path.isfile(filename): + if type == "hook": try: - if type == "hook": - self.manager.deactivateHook(name) - remove(filename) + self.manager.deactivateHook(name) + except Exception, e: - self.logDebug("Error removing: %s" % path.basename(filename), str(e)) - err = True + self.logDebug(e) + + for filename in (py_filename, pyc_filename): + if not exists(filename): + continue + + try: + os.remove(filename) + + except IOError, e: + self.logError(_("Error removing: %s") % filename, e) - if not err: - id = (type, name) - removed.append(id) + else: + id = (type, name) + removed.add(id) - return removed #: return a list of the plugins successfully removed + return list(removed) #: return a list of the plugins successfully removed -- cgit v1.2.3 From 3a9c167ceca27d57dbef927626fe853a3d0e30b2 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sun, 1 Mar 2015 22:41:08 +0100 Subject: [Extractor] Use self.target --- module/plugins/hooks/ExtractArchive.py | 37 +++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 16 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index c9e43eaaf..6a25602e8 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -33,6 +33,7 @@ if sys.version_info < (2, 7) and os.name != "nt": if self.returncode is None: try: pid, sts = _eintr_retry_call(os.waitpid, self.pid, 0) + except OSError, e: if e.errno != errno.ECHILD: raise @@ -93,10 +94,13 @@ class ArchiveQueue(object): queue = self.get() try: queue.remove(item) + except ValueError: pass + if queue == []: return self.delete() + return self.set(queue) @@ -106,22 +110,22 @@ class ExtractArchive(Hook): __type__ = "hook" __version__ = "1.32" - __config__ = [("activated" , "bool" , "Activated" , True ), - ("fullpath" , "bool" , "Extract with full paths" , True ), - ("overwrite" , "bool" , "Overwrite files" , False ), - ("keepbroken" , "bool" , "Try to extract broken archives" , False ), - ("repair" , "bool" , "Repair broken archives (rar required)" , False ), - ("test" , "bool" , "Test archive before extracting" , False ), - ("usepasswordfile" , "bool" , "Use password file" , True ), - ("passwordfile" , "file" , "Password file" , "archive_password.txt" ), - ("delete" , "bool" , "Delete archive when successfully extracted", False ), - ("subfolder" , "bool" , "Create subfolder for each package" , False ), - ("destination" , "folder", "Extract files to folder" , "" ), - ("extensions" , "str" , "Extract the following extensions" , "7z,bz2,bzip2,gz,gzip,lha,lzh,lzma,rar,tar,taz,tbz,tbz2,tgz,xar,xz,z,zip"), - ("excludefiles" , "str" , "Don't extract the following files" , "*.nfo,*.DS_Store,index.dat,thumb.db" ), - ("recursive" , "bool" , "Extract archives in archives" , True ), - ("waitall" , "bool" , "Wait for all downloads to be finished" , False ), - ("renice" , "int" , "CPU priority" , 0 )] + __config__ = [("activated" , "bool" , "Activated" , True ), + ("fullpath" , "bool" , "Extract with full paths" , True ), + ("overwrite" , "bool" , "Overwrite files" , False ), + ("keepbroken" , "bool" , "Try to extract broken archives" , False ), + ("repair" , "bool" , "Repair broken archives (rar required)" , False ), + ("test" , "bool" , "Test archive before extracting" , False ), + ("usepasswordfile", "bool" , "Use password file" , True ), + ("passwordfile" , "file" , "Password file" , "archive_password.txt" ), + ("delete" , "bool" , "Delete archive when successfully extracted", False ), + ("subfolder" , "bool" , "Create subfolder for each package" , False ), + ("destination" , "folder", "Extract files to folder" , "" ), + ("extensions" , "str" , "Extract the following extensions" , "7z,bz2,bzip2,gz,gzip,lha,lzh,lzma,rar,tar,taz,tbz,tbz2,tgz,xar,xz,z,zip"), + ("excludefiles" , "str" , "Don't extract the following files" , "*.nfo,*.DS_Store,index.dat,thumb.db" ), + ("recursive" , "bool" , "Extract archives in archives" , True ), + ("waitall" , "bool" , "Wait for all downloads to be finished" , False ), + ("renice" , "int" , "CPU priority" , 0 )] __description__ = """Extract different kind of archives""" __license__ = "GPLv3" @@ -175,6 +179,7 @@ class ExtractArchive(Hook): else: self.logInfo(_("No Extract plugins activated")) + @threaded def extractQueued(self,thread): packages = self.queue.get() -- cgit v1.2.3 From 5ea0fe898b435a5654e0a14172025779c82182d6 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Mon, 2 Mar 2015 00:39:51 +0100 Subject: [ClickAndLoad] Revert and improve --- module/plugins/hooks/ClickAndLoad.py | 50 +++++++++++++++++------------------- 1 file changed, 24 insertions(+), 26 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 5b21aec96..1a7dec6ac 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -16,6 +16,7 @@ def forward(source, destination): destination.sendall(bufdata) bufdata = source.recv(bufsize) finally: + source.shutdown(socket.SHUT_RD) destination.shutdown(socket.SHUT_WR) @@ -23,13 +24,13 @@ def forward(source, destination): class ClickAndLoad(Hook): __name__ = "ClickAndLoad" __type__ = "hook" - __version__ = "0.37" + __version__ = "0.38" __config__ = [("activated", "bool", "Activated" , True), ("port" , "int" , "Port" , 9666), ("extern" , "bool", "Listen on the public network interface", True)] - __description__ = """Click'N'Load hook plugin""" + __description__ = """Click'n'Load hook plugin""" __license__ = "GPLv3" __authors__ = [("RaNaN", "RaNaN@pyload.de"), ("Walter Purcaro", "vuolter@gmail.com")] @@ -45,7 +46,7 @@ class ClickAndLoad(Hook): return ip = "" if self.getConfig("extern") else "127.0.0.1" - webport = int(self.config['webinterface']['port']) + webport = self.config['webinterface']['port'] cnlport = self.getConfig('port') self.proxy(ip, webport, cnlport) @@ -54,39 +55,36 @@ class ClickAndLoad(Hook): @threaded def proxy(self, ip, webport, cnlport): self.logInfo(_("Proxy listening on %s:%s") % (ip or "0.0.0.0", cnlport)) - self.manager.startThread(self._server, ip, webport, cnlport) + + self._server(ip, webport, cnlport) + lock = Lock() lock.acquire() lock.acquire() - def _server(self, ip, webport, cnlport, thread): + @threaded + def _server(self, ip, webport, cnlport): try: - try: - server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + dock_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + dock_socket.bind((ip, cnlport)) + dock_socket.listen(1) - server_socket.bind((ip, cnlport)) - server_socket.listen(5) + while True: + client_socket, client_addr = dock_socket.accept() + self.logDebug("Connection from: %s" % client_addr) - while True: - client_socket = server_socket.accept()[0] - dock_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - - dock_socket.connect(("127.0.0.1", webport)) - - self.manager.startThread(forward, dock_socket, client_socket) - self.manager.startThread(forward, client_socket, dock_socket) + server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + server_socket.connect(("127.0.0.1", webport)) - except socket.timeout: - self.logDebug("Connection timed out, retrying...") - return self._server(ip, webport, cnlport, thread) + self.manager.startThread(forward, client_socket, server_socket) + self.manager.startThread(forward, server_socket, client_socket) - finally: - server_socket.close() - client_socket.close() - dock_socket.close() + except socket.timeout: + self.logDebug("Connection timed out, retrying...") + return self._server(ip, webport, cnlport) except socket.error, e: self.logError(e) - time.sleep(120) - self._server(ip, webport, cnlport, thread) + time.sleep(240) + return self._server(ip, webport, cnlport) -- cgit v1.2.3 From 8d85fb7c11dfa83052d09402dbae21dde44392aa Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Wed, 4 Mar 2015 03:12:58 +0100 Subject: [ClickAndLoad] Fix https://github.com/pyload/pyload/issues/1220 --- module/plugins/hooks/ClickAndLoad.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 1a7dec6ac..f3396be77 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -16,15 +16,15 @@ def forward(source, destination): destination.sendall(bufdata) bufdata = source.recv(bufsize) finally: - source.shutdown(socket.SHUT_RD) destination.shutdown(socket.SHUT_WR) + destination.close() #@TODO: IPv6 support class ClickAndLoad(Hook): __name__ = "ClickAndLoad" __type__ = "hook" - __version__ = "0.38" + __version__ = "0.39" __config__ = [("activated", "bool", "Activated" , True), ("port" , "int" , "Port" , 9666), @@ -68,11 +68,11 @@ class ClickAndLoad(Hook): try: dock_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) dock_socket.bind((ip, cnlport)) - dock_socket.listen(1) + dock_socket.listen(5) while True: client_socket, client_addr = dock_socket.accept() - self.logDebug("Connection from: %s" % client_addr) + self.logDebug("Connection from %s:%s" % client_addr) server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server_socket.connect(("127.0.0.1", webport)) -- cgit v1.2.3 From 9854d2f81577dc3c5c7c97cefd61404f739f4a24 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Thu, 5 Mar 2015 23:15:19 +0100 Subject: [ClickAndLoad] Fixup --- module/plugins/hooks/ClickAndLoad.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index f3396be77..938269795 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -17,14 +17,14 @@ def forward(source, destination): bufdata = source.recv(bufsize) finally: destination.shutdown(socket.SHUT_WR) - destination.close() + # destination.close() #@TODO: IPv6 support class ClickAndLoad(Hook): __name__ = "ClickAndLoad" __type__ = "hook" - __version__ = "0.39" + __version__ = "0.40" __config__ = [("activated", "bool", "Activated" , True), ("port" , "int" , "Port" , 9666), -- cgit v1.2.3 From 0685e1f1d55e8a1a3083ca147ad4087430fc2620 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Fri, 6 Mar 2015 03:32:08 +0100 Subject: [SkipRev] Fix https://github.com/pyload/pyload/issues/1217 --- module/plugins/hooks/SkipRev.py | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py index 0bbdec3b2..3ebfa378e 100644 --- a/module/plugins/hooks/SkipRev.py +++ b/module/plugins/hooks/SkipRev.py @@ -18,9 +18,10 @@ def _setup(self): class SkipRev(Hook): __name__ = "SkipRev" __type__ = "hook" - __version__ = "0.25" + __version__ = "0.26" - __config__ = [("tokeep", "int", "Number of rev files to keep for package (-1 to auto)", -1)] + __config__ = [("mode" , "Auto;Manual", "Choose rev files to keep for package", "Auto"), + ("tokeep", "int" , "Custom number of files to keep" , 0 )] __description__ = """Skip files ending with extension rev""" __license__ = "GPLv3" @@ -32,8 +33,8 @@ class SkipRev(Hook): pass - def _pyname(self, pyfile): - if hasattr(pyfile.pluginmodule, "getInfo"): + def _name(self, pyfile): + if hasattr(pyfile.pluginmodule, "getInfo"): #@NOTE: getInfo is deprecated in 0.4.10 return getattr(pyfile.pluginmodule, "getInfo")([pyfile.url]).next()[0] else: self.logWarning("Unable to grab file name") @@ -54,16 +55,19 @@ class SkipRev(Hook): def downloadPreparing(self, pyfile): - if pyfile.statusname is "unskipped" or not self._pyname(pyfile).endswith(".rev"): + name = self._name(pyfile) + + if pyfile.statusname is "unskipped" or not name.endswith(".rev") or not '.part' in name: return - tokeep = self.getConfig("tokeep") + tokeep = -1 if self.getConfig('mode') == "Auto" else self.getConfig('tokeep') if tokeep: status_list = (1, 4, 8, 9, 14) if tokeep < 0 else (1, 3, 4, 8, 9, 14) + pyname = re.compile(r'%s\.part\d+\.rev$' % name.rsplit('.', 2)[0].replace('.', '\.')) queued = [True for link in self.core.api.getPackageData(pyfile.package().id).links \ - if link.name.endswith(".rev") and link.status not in status_list].count(True) + if link.status not in status_list and pyname.match(link.name)].count(True) if not queued or queued < tokeep: #: keep one rev at least in auto mode return @@ -76,16 +80,18 @@ class SkipRev(Hook): def downloadFailed(self, pyfile): #: Check if pyfile is still "failed", # maybe might has been restarted in meantime - if pyfile.status != 8: + if pyfile.status != 8 or pyfile.name.rsplit('.', 1)[-1].strip() not in ("rar", "rev"): return - tokeep = self.getConfig("tokeep") + tokeep = -1 if self.getConfig('mode') == "Auto" else self.getConfig('tokeep') if not tokeep: return + pyname = re.compile(r'%s\.part\d+\.rev$' % pyfile.name.rsplit('.', 2)[0].replace('.', '\.')) + for link in self.core.api.getPackageData(pyfile.package().id).links: - if link.status is 4 and link.name.endswith(".rev"): + if link.status is 4 and pyname.match(link.name): pylink = self._pyfile(link) if tokeep > -1 or pyfile.name.endswith(".rev"): -- cgit v1.2.3 From cb52389931917fee9a6116b45922f502480350d6 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Fri, 6 Mar 2015 03:45:46 +0100 Subject: [SkipRev] Fix setup loop on download preparing --- module/plugins/hooks/SkipRev.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py index 3ebfa378e..a543ef71c 100644 --- a/module/plugins/hooks/SkipRev.py +++ b/module/plugins/hooks/SkipRev.py @@ -18,7 +18,7 @@ def _setup(self): class SkipRev(Hook): __name__ = "SkipRev" __type__ = "hook" - __version__ = "0.26" + __version__ = "0.27" __config__ = [("mode" , "Auto;Manual", "Choose rev files to keep for package", "Auto"), ("tokeep", "int" , "Custom number of files to keep" , 0 )] @@ -57,7 +57,7 @@ class SkipRev(Hook): def downloadPreparing(self, pyfile): name = self._name(pyfile) - if pyfile.statusname is "unskipped" or not name.endswith(".rev") or not '.part' in name: + if pyfile.statusname is "unskipped" or not name.endswith(".rev") or not ".part" in name: return tokeep = -1 if self.getConfig('mode') == "Auto" else self.getConfig('tokeep') @@ -73,8 +73,10 @@ class SkipRev(Hook): return pyfile.setCustomStatus("SkipRev", "skipped") - pyfile.plugin._setup = pyfile.plugin.setup - pyfile.plugin.setup = MethodType(_setup, pyfile.plugin) #: work-around: inject status checker inside the preprocessing routine of the plugin + + if not hasattr(pyfile.plugin, "_setup"): + pyfile.plugin._setup = pyfile.plugin.setup + pyfile.plugin.setup = MethodType(_setup, pyfile.plugin) #: work-around: inject status checker inside the preprocessing routine of the plugin def downloadFailed(self, pyfile): -- cgit v1.2.3 From 5f4b7afb0bf8f770032ee21ce67c76194d8d6cb0 Mon Sep 17 00:00:00 2001 From: jellysheep <max.mail@dameweb.de> Date: Fri, 6 Mar 2015 14:24:22 +0100 Subject: [ExternalScripts] Encode unicode characters If a file with unicode characters in the filename is downloaded ExternalScripts.py fails with e.g. this error: ExternalScripts: Error in download_finished.sh: 'ascii' codec can't decode byte 0xc3 in position 29: ordinal not in range(128) This commit makes the plugin encode unicode characters to UTF-8. --- module/plugins/hooks/ExternalScripts.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index f49220c2a..76a9d9c52 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -74,7 +74,8 @@ class ExternalScripts(Hook): def callScript(self, script, *args): try: - cmd = [script] + [str(x) if not isinstance(x, basestring) else x for x in args] + cmd = [script] + [x.encode("UTF-8") if isinstance(x, unicode) else + str(x) if not isinstance(x, basestring) else x for x in args] self.logDebug("Executing", os.path.abspath(script), " ".join(cmd)) -- cgit v1.2.3 From 6aa9ab4f05a9fb5f5fc9cbe1758591cd239ba089 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Fri, 6 Mar 2015 18:30:56 +0100 Subject: [SkipRev] Fix https://github.com/pyload/pyload/issues/1217 (2) --- module/plugins/hooks/SkipRev.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py index a543ef71c..034d2b803 100644 --- a/module/plugins/hooks/SkipRev.py +++ b/module/plugins/hooks/SkipRev.py @@ -1,5 +1,7 @@ # -*- coding: utf-8 -*- +import re + from types import MethodType from urllib import unquote from urlparse import urlparse @@ -18,7 +20,7 @@ def _setup(self): class SkipRev(Hook): __name__ = "SkipRev" __type__ = "hook" - __version__ = "0.27" + __version__ = "0.28" __config__ = [("mode" , "Auto;Manual", "Choose rev files to keep for package", "Auto"), ("tokeep", "int" , "Custom number of files to keep" , 0 )] @@ -35,7 +37,7 @@ class SkipRev(Hook): def _name(self, pyfile): if hasattr(pyfile.pluginmodule, "getInfo"): #@NOTE: getInfo is deprecated in 0.4.10 - return getattr(pyfile.pluginmodule, "getInfo")([pyfile.url]).next()[0] + return pyfile.pluginmodule.getInfo([pyfile.url]).next()[0] else: self.logWarning("Unable to grab file name") return urlparse(unquote(pyfile.url)).path.split('/')[-1] -- cgit v1.2.3 From acc20db31c63ed03ce3e0c530a0b0bc24444e980 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Fri, 6 Mar 2015 22:31:52 +0100 Subject: [ExternalScripts] Version up --- module/plugins/hooks/ExternalScripts.py | 5 ++--- module/plugins/hooks/SkipRev.py | 18 +++++++++--------- 2 files changed, 11 insertions(+), 12 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index 76a9d9c52..a09d5e92e 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -10,7 +10,7 @@ from module.utils import save_join class ExternalScripts(Hook): __name__ = "ExternalScripts" __type__ = "hook" - __version__ = "0.29" + __version__ = "0.30" __config__ = [("activated", "bool", "Activated" , True ), ("wait" , "bool", "Wait script ending", False)] @@ -74,8 +74,7 @@ class ExternalScripts(Hook): def callScript(self, script, *args): try: - cmd = [script] + [x.encode("UTF-8") if isinstance(x, unicode) else - str(x) if not isinstance(x, basestring) else x for x in args] + cmd = [script] + [(str(x) if not isinstance(x, basestring) else x).encode('utf-8') for x in args] self.logDebug("Executing", os.path.abspath(script), " ".join(cmd)) diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py index 034d2b803..a4d46316e 100644 --- a/module/plugins/hooks/SkipRev.py +++ b/module/plugins/hooks/SkipRev.py @@ -22,8 +22,8 @@ class SkipRev(Hook): __type__ = "hook" __version__ = "0.28" - __config__ = [("mode" , "Auto;Manual", "Choose rev files to keep for package", "Auto"), - ("tokeep", "int" , "Custom number of files to keep" , 0 )] + __config__ = [("mode" , "Auto;Manual", "Choose rev files to keep for package", "Auto"), + ("revtokeep", "int" , "Custom number of files to keep" , 0 )] __description__ = """Skip files ending with extension rev""" __license__ = "GPLv3" @@ -62,16 +62,16 @@ class SkipRev(Hook): if pyfile.statusname is "unskipped" or not name.endswith(".rev") or not ".part" in name: return - tokeep = -1 if self.getConfig('mode') == "Auto" else self.getConfig('tokeep') + revtokeep = -1 if self.getConfig('mode') == "Auto" else self.getConfig('revtokeep') - if tokeep: - status_list = (1, 4, 8, 9, 14) if tokeep < 0 else (1, 3, 4, 8, 9, 14) + if revtokeep: + status_list = (1, 4, 8, 9, 14) if revtokeep < 0 else (1, 3, 4, 8, 9, 14) pyname = re.compile(r'%s\.part\d+\.rev$' % name.rsplit('.', 2)[0].replace('.', '\.')) queued = [True for link in self.core.api.getPackageData(pyfile.package().id).links \ if link.status not in status_list and pyname.match(link.name)].count(True) - if not queued or queued < tokeep: #: keep one rev at least in auto mode + if not queued or queued < revtokeep: #: keep one rev at least in auto mode return pyfile.setCustomStatus("SkipRev", "skipped") @@ -87,9 +87,9 @@ class SkipRev(Hook): if pyfile.status != 8 or pyfile.name.rsplit('.', 1)[-1].strip() not in ("rar", "rev"): return - tokeep = -1 if self.getConfig('mode') == "Auto" else self.getConfig('tokeep') + revtokeep = -1 if self.getConfig('mode') == "Auto" else self.getConfig('revtokeep') - if not tokeep: + if not revtokeep: return pyname = re.compile(r'%s\.part\d+\.rev$' % pyfile.name.rsplit('.', 2)[0].replace('.', '\.')) @@ -98,7 +98,7 @@ class SkipRev(Hook): if link.status is 4 and pyname.match(link.name): pylink = self._pyfile(link) - if tokeep > -1 or pyfile.name.endswith(".rev"): + if revtokeep > -1 or pyfile.name.endswith(".rev"): pylink.setStatus("queued") else: pylink.setCustomStatus("unskipped", "queued") -- cgit v1.2.3 From 9b8bd41059d87e120d2d64bc0e01e0a521ec1082 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sat, 7 Mar 2015 03:32:50 +0100 Subject: New addon: AntiVirus --- module/plugins/hooks/AntiVirus.py | 85 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 module/plugins/hooks/AntiVirus.py (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/AntiVirus.py b/module/plugins/hooks/AntiVirus.py new file mode 100644 index 000000000..4bb2396d9 --- /dev/null +++ b/module/plugins/hooks/AntiVirus.py @@ -0,0 +1,85 @@ +# -*- coding: utf-8 -*- + +import os +import subprocess + +from module.plugins.Hook import Hook, Expose, threaded +from module.utils import fs_encode, save_join + + +class AntiVirus(Hook): + __name__ = "AntiVirus" + __type__ = "hook" + __version__ = "0.01" + + __config__ = [("action" , "Antivirus default;Delete;Quarantine", "Manage infected files" , "Antivirus default"), + ("quarpath" , "folder" , "Quarantine folder" , "" ), + ("scanfailed", "bool" , "Scan incompleted files (failed downloads)", False ), + ("cmdpath" , "file" , "Antivirus executable" , "" ), + ("cmdargs" , "str" , "Scan options" , "" )] + + __description__ = """Scan downloaded files with antivirus program""" + __license__ = "GPLv3" + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] + + + #@TODO: Remove in 0.4.10 + def initPeriodical(self): + pass + + + @Expose + @threaded + def scan(self, pyfile, thread): + name = os.path.basename(pyfile.plugin.lastDownload) + filename = fs_encode(pyfile.plugin.lastDownload) + cmdpath = fs_encode(self.getConfig('cmdpath')) + cmdargs = fs_encode(self.getConfig('cmdargs').strip()) + + if not os.path.isfile(filename) or not os.path.isfile(cmdpath): + return + + pyfile.setCustomStatus(_("virus scanning")) + thread.addActive(pyfile) + + try: + p = subprocess.Popen([cmdpath, cmdargs], bufsize=-1, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + + out, err = map(str.strip, p.communicate()) + + if out: + self.logInfo(name, out) + + if err: + self.logWarning(name, err) + return + + if p.returncode: + action = self.getConfig('action') + try: + if action == "Delete": + os.remove(filename) + + elif action == "Quarantine": + new_filename = save_join(self.getConfig('quarpath'), name) + os.rename(filename, new_filename) + + except IOError, e: + self.logError(name, action + " action failed!", e) + + elif not out: + self.logDebug(name, "No virus found") + + finally: + thread.finishFile(pyfile) + + + def downloadFinished(self, pyfile): + return self.scan(pyfile) + + + def downloadFailed(self, pyfile): + #: Check if pyfile is still "failed", + # maybe might has been restarted in meantime + if pyfile.status == 8 and self.getConfig('scanfailed'): + return self.scan(pyfile) -- cgit v1.2.3 From c4f3a79f8ce19eab13ea7e53ff7a58fad43c6698 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sat, 7 Mar 2015 03:39:08 +0100 Subject: [AntiVirus] Fix quarantine file moving --- module/plugins/hooks/AntiVirus.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/AntiVirus.py b/module/plugins/hooks/AntiVirus.py index 4bb2396d9..c5d6b8321 100644 --- a/module/plugins/hooks/AntiVirus.py +++ b/module/plugins/hooks/AntiVirus.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import os +import shutil import subprocess from module.plugins.Hook import Hook, Expose, threaded @@ -10,7 +11,7 @@ from module.utils import fs_encode, save_join class AntiVirus(Hook): __name__ = "AntiVirus" __type__ = "hook" - __version__ = "0.01" + __version__ = "0.02" __config__ = [("action" , "Antivirus default;Delete;Quarantine", "Manage infected files" , "Antivirus default"), ("quarpath" , "folder" , "Quarantine folder" , "" ), @@ -62,9 +63,9 @@ class AntiVirus(Hook): elif action == "Quarantine": new_filename = save_join(self.getConfig('quarpath'), name) - os.rename(filename, new_filename) + shutil.move(filename, new_filename) - except IOError, e: + except (IOError, shutil.Error), e: self.logError(name, action + " action failed!", e) elif not out: -- cgit v1.2.3 From 3551cd44c7fad9cf5159d5920b6e8ec7aa3d1b9b Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sat, 7 Mar 2015 18:33:23 +0100 Subject: Spare code cosmetics --- module/plugins/hooks/AntiVirus.py | 45 ++++++++++++++++++++++----------------- module/plugins/hooks/SkipRev.py | 4 ++-- 2 files changed, 28 insertions(+), 21 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/AntiVirus.py b/module/plugins/hooks/AntiVirus.py index c5d6b8321..5dbc640ee 100644 --- a/module/plugins/hooks/AntiVirus.py +++ b/module/plugins/hooks/AntiVirus.py @@ -11,13 +11,14 @@ from module.utils import fs_encode, save_join class AntiVirus(Hook): __name__ = "AntiVirus" __type__ = "hook" - __version__ = "0.02" + __version__ = "0.03" __config__ = [("action" , "Antivirus default;Delete;Quarantine", "Manage infected files" , "Antivirus default"), - ("quarpath" , "folder" , "Quarantine folder" , "" ), + ("quardir" , "folder" , "Quarantine folder" , "" ), ("scanfailed", "bool" , "Scan incompleted files (failed downloads)", False ), - ("cmdpath" , "file" , "Antivirus executable" , "" ), - ("cmdargs" , "str" , "Scan options" , "" )] + ("cmdfile" , "file" , "Antivirus executable" , "" ), + ("cmdargs" , "str" , "Scan options" , "" ), + ("ignore-err", "bool" , "Ignore scan errors" , False )] __description__ = """Scan downloaded files with antivirus program""" __license__ = "GPLv3" @@ -32,46 +33,52 @@ class AntiVirus(Hook): @Expose @threaded def scan(self, pyfile, thread): - name = os.path.basename(pyfile.plugin.lastDownload) - filename = fs_encode(pyfile.plugin.lastDownload) - cmdpath = fs_encode(self.getConfig('cmdpath')) + file = fs_encode(pyfile.plugin.lastDownload) + filename = os.path.basename(pyfile.plugin.lastDownload) + cmdfile = fs_encode(self.getConfig('cmdfile')) cmdargs = fs_encode(self.getConfig('cmdargs').strip()) - if not os.path.isfile(filename) or not os.path.isfile(cmdpath): + if not os.path.isfile(file) or not os.path.isfile(cmdfile): return - pyfile.setCustomStatus(_("virus scanning")) thread.addActive(pyfile) + pyfile.setCustomStatus(_("virus scanning")) try: - p = subprocess.Popen([cmdpath, cmdargs], bufsize=-1, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + p = subprocess.Popen([cmdfile, cmdargs], bufsize=-1, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = map(str.strip, p.communicate()) if out: - self.logInfo(name, out) + self.logInfo(filename, out) if err: - self.logWarning(name, err) - return + self.logWarning(filename, err) + if not self.getConfig('ignore-err') + self.logDebug("Delete/Quarantine action aborted") + return if p.returncode: + pyfile.error = _("infected file") action = self.getConfig('action') try: if action == "Delete": - os.remove(filename) + os.remove(file) elif action == "Quarantine": - new_filename = save_join(self.getConfig('quarpath'), name) - shutil.move(filename, new_filename) + pyfile.setCustomStatus(_("file moving")) + pyfile.setProgress(0) + new_filename = save_join(self.getConfig('quardir'), filename) + shutil.move(file, new_filename) except (IOError, shutil.Error), e: - self.logError(name, action + " action failed!", e) + self.logError(filename, action + " action failed!", e) - elif not out: - self.logDebug(name, "No virus found") + elif not out and not err: + self.logDebug(filename, "No infected file found") finally: + pyfile.setProgress(100) thread.finishFile(pyfile) diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py index a4d46316e..521c2c39e 100644 --- a/module/plugins/hooks/SkipRev.py +++ b/module/plugins/hooks/SkipRev.py @@ -22,8 +22,8 @@ class SkipRev(Hook): __type__ = "hook" __version__ = "0.28" - __config__ = [("mode" , "Auto;Manual", "Choose rev files to keep for package", "Auto"), - ("revtokeep", "int" , "Custom number of files to keep" , 0 )] + __config__ = [("mode" , "Auto;Manual", "Choose rev files to skip for package", "Auto"), + ("revtokeep", "int" , "Number of rev files to keep" , 0 )] __description__ = """Skip files ending with extension rev""" __license__ = "GPLv3" -- cgit v1.2.3 From 696ae23db1192f919961685f4026bb917b15868d Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sat, 7 Mar 2015 21:06:53 +0100 Subject: [AntiVirus] Missed something big! :P --- module/plugins/hooks/AntiVirus.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/AntiVirus.py b/module/plugins/hooks/AntiVirus.py index 5dbc640ee..695852683 100644 --- a/module/plugins/hooks/AntiVirus.py +++ b/module/plugins/hooks/AntiVirus.py @@ -11,7 +11,7 @@ from module.utils import fs_encode, save_join class AntiVirus(Hook): __name__ = "AntiVirus" __type__ = "hook" - __version__ = "0.03" + __version__ = "0.04" __config__ = [("action" , "Antivirus default;Delete;Quarantine", "Manage infected files" , "Antivirus default"), ("quardir" , "folder" , "Quarantine folder" , "" ), @@ -45,7 +45,7 @@ class AntiVirus(Hook): pyfile.setCustomStatus(_("virus scanning")) try: - p = subprocess.Popen([cmdfile, cmdargs], bufsize=-1, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + p = subprocess.Popen([cmdfile, cmdargs, file], bufsize=-1, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = map(str.strip, p.communicate()) -- cgit v1.2.3 From af353df35ef05b699f464ad2dca1b7b2bfe732e4 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sun, 8 Mar 2015 01:14:57 +0100 Subject: [ExternalScripts] Improve --- module/plugins/hooks/ExternalScripts.py | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index a09d5e92e..76444d4b3 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -4,16 +4,16 @@ import os import subprocess from module.plugins.Hook import Hook -from module.utils import save_join +from module.utils import fs_encode, save_join class ExternalScripts(Hook): __name__ = "ExternalScripts" __type__ = "hook" - __version__ = "0.30" + __version__ = "0.31" __config__ = [("activated", "bool", "Activated" , True ), - ("wait" , "bool", "Wait script ending", False)] + ("waitend" , "bool", "Wait script ending", False)] __description__ = """Run external scripts""" __license__ = "GPLv3" @@ -50,7 +50,7 @@ class ExternalScripts(Hook): for script_type, names in self.scripts.iteritems(): if names: - self.logInfo(_("Installed scripts for"), script_type, ", ".join(map(os.path.basename, names))) + self.logInfo(_("Installed scripts for ") + script_type, ", ".join(map(os.path.basename, names))) def initPluginType(self, folder, path): @@ -58,28 +58,33 @@ class ExternalScripts(Hook): try: os.makedirs(path) - except Exception: - self.logDebug("Script folder %s not created" % folder) + except IOError, e: + self.logDebug(e) return - for f in os.listdir(path): - if f.startswith("#") or f.startswith(".") or f.startswith("_") or f.endswith("~") or f.endswith(".swp"): + for filename in os.listdir(path): + file = os.path.join(path, filename) + + if not os.path.isfile(file): + continue + + if filename[0] in ("#", "_") or filename.endswith("~") or filename.endswith(".swp"): continue - if not os.access(os.path.join(path, f), os.X_OK): - self.logWarning(_("Script not executable:") + " %s/%s" % (folder, f)) + if not os.access(file, os.X_OK): + self.logWarning(_("Script not executable:") + " %s/%s" % (folder, filename)) - self.scripts[folder].append(os.path.join(path, f)) + self.scripts[folder].append(file) def callScript(self, script, *args): try: - cmd = [script] + [(str(x) if not isinstance(x, basestring) else x).encode('utf-8') for x in args] + cmd = [(str(x) if not isinstance(x, basestring) else x).encode('utf-8') for x in args] self.logDebug("Executing", os.path.abspath(script), " ".join(cmd)) - p = subprocess.Popen(cmd, bufsize=-1) #@NOTE: output goes to pyload - if self.getConfig('wait'): + p = subprocess.Popen([script, fs_encode(cmd)], bufsize=-1) #@NOTE: output goes to pyload + if self.getConfig('waitend'): p.communicate() except Exception, e: -- cgit v1.2.3 From db330ae85f9de5a9a19c7141c1a2d6877e02e7da Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sun, 8 Mar 2015 23:32:11 +0100 Subject: Update notify addon --- module/plugins/hooks/AndroidPhoneNotify.py | 53 +++++++++++++++++++----------- module/plugins/hooks/WindowsPhoneNotify.py | 52 ++++++++++++++++++----------- 2 files changed, 65 insertions(+), 40 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/AndroidPhoneNotify.py b/module/plugins/hooks/AndroidPhoneNotify.py index a3b24a255..7a9e6d6f8 100644 --- a/module/plugins/hooks/AndroidPhoneNotify.py +++ b/module/plugins/hooks/AndroidPhoneNotify.py @@ -1,27 +1,28 @@ # -*- coding: utf-8 -*- -from time import time +import time from module.network.RequestFactory import getURL -from module.plugins.Hook import Hook +from module.plugins.Hook import Hook, Expose class AndroidPhoneNotify(Hook): __name__ = "AndroidPhoneNotify" __type__ = "hook" - __version__ = "0.05" + __version__ = "0.06" __config__ = [("apikey" , "str" , "API key" , "" ), ("notifycaptcha" , "bool", "Notify captcha request" , True ), ("notifypackage" , "bool", "Notify package finished" , True ), - ("notifyprocessed", "bool", "Notify processed packages status" , True ), - ("timeout" , "int" , "Timeout between captchas in seconds" , 5 ), - ("force" , "bool", "Send notifications if client is connected", False)] + ("notifyprocessed", "bool", "Notify status of processed packages" , True ), + ("sendtimewait" , "int" , "Timewait in seconds between notifications", 5 ), + ("sendpermin" , "int" , "Max notifications per minute" , 12 ), + ("ignoreclient" , "bool", "Send notifications if client is connected", False)] - __description__ = """Send push notifications to your Android Phone using notifymyandroid.com""" + __description__ = """Send push notifications to your Android Phone (using notifymyandroid.com)""" __license__ = "GPLv3" - __authors__ = [("Steven Kosyra", "steven.kosyra@gmail.com"), - ("Walter Purcaro", "vuolter@gmail.com")] + __authors__ = [("Steven Kosyra" , "steven.kosyra@gmail.com"), + ("Walter Purcaro", "vuolter@gmail.com" )] event_list = ["allDownloadsProcessed"] @@ -33,16 +34,14 @@ class AndroidPhoneNotify(Hook): def setup(self): - self.info = {} #@TODO: Remove in 0.4.10 - self.last_notify = 0 + self.info = {} #@TODO: Remove in 0.4.10 + self.last_notify = 0 + self.notifications = 0 def newCaptchaTask(self, task): if not self.getConfig("notifycaptcha"): - return False - - if time() - self.last_notify < self.getConf("timeout"): - return False + return self.notify(_("Captcha"), _("New request waiting user input")) @@ -54,7 +53,7 @@ class AndroidPhoneNotify(Hook): def allDownloadsProcessed(self): if not self.getConfig("notifyprocessed"): - return False + return if any(True for pdata in self.core.api.getQueue() if pdata.linksdone < pdata.linkstotal): self.notify(_("Package failed"), _("One or more packages was not completed successfully")) @@ -62,14 +61,27 @@ class AndroidPhoneNotify(Hook): self.notify(_("All packages finished")) + @Expose def notify(self, event, msg=""): apikey = self.getConfig("apikey") if not apikey: - return False + return + + if self.core.isClientConnected() and not self.getConfig("ignoreclient"): + return + + elapsed_time = time.time() - self.last_notify + + if elapsed_time < self.getConf("sendtimewait"): + return + + if elapsed_time > 60: + self.notifications = 0 + + elif self.notifications >= self.getConf("sendpermin"): + return - if self.core.isClientConnected() and not self.getConfig("force"): - return False getURL("http://www.notifymyandroid.com/publicapi/notify", get={'apikey' : apikey, @@ -77,4 +89,5 @@ class AndroidPhoneNotify(Hook): 'event' : event, 'description': msg}) - self.last_notify = time() + self.last_notify = time.time() + self.notifications += 1 diff --git a/module/plugins/hooks/WindowsPhoneNotify.py b/module/plugins/hooks/WindowsPhoneNotify.py index e0dd75f92..010198bf1 100644 --- a/module/plugins/hooks/WindowsPhoneNotify.py +++ b/module/plugins/hooks/WindowsPhoneNotify.py @@ -1,29 +1,29 @@ # -*- coding: utf-8 -*- import httplib +import time -from time import time - -from module.plugins.Hook import Hook +from module.plugins.Hook import Hook, Expose class WindowsPhoneNotify(Hook): __name__ = "WindowsPhoneNotify" __type__ = "hook" - __version__ = "0.07" + __version__ = "0.08" __config__ = [("id" , "str" , "Push ID" , "" ), ("url" , "str" , "Push url" , "" ), ("notifycaptcha" , "bool", "Notify captcha request" , True ), ("notifypackage" , "bool", "Notify package finished" , True ), - ("notifyprocessed", "bool", "Notify processed packages status" , True ), - ("timeout" , "int" , "Timeout between captchas in seconds" , 5 ), - ("force" , "bool", "Send notifications if client is connected", False)] + ("notifyprocessed", "bool", "Notify status of processed packages" , True ), + ("sendtimewait" , "int" , "Timewait in seconds between notifications", 5 ), + ("sendpermin" , "int" , "Max notifications per minute" , 12 ), + ("ignoreclient" , "bool", "Send notifications if client is connected", False)] __description__ = """Send push notifications to Windows Phone""" __license__ = "GPLv3" - __authors__ = [("Andy Voigt", "phone-support@hotmail.de"), - ("Walter Purcaro", "vuolter@gmail.com")] + __authors__ = [("Andy Voigt" , "phone-support@hotmail.de"), + ("Walter Purcaro", "vuolter@gmail.com" )] event_list = ["allDownloadsProcessed"] @@ -35,16 +35,14 @@ class WindowsPhoneNotify(Hook): def setup(self): - self.info = {} #@TODO: Remove in 0.4.10 - self.last_notify = 0 + self.info = {} #@TODO: Remove in 0.4.10 + self.last_notify = 0 + self.notifications = 0 def newCaptchaTask(self, task): if not self.getConfig("notifycaptcha"): - return False - - if time() - self.last_notify < self.getConf("timeout"): - return False + return self.notify(_("Captcha"), _("New request waiting user input")) @@ -56,7 +54,7 @@ class WindowsPhoneNotify(Hook): def allDownloadsProcessed(self): if not self.getConfig("notifyprocessed"): - return False + return if any(True for pdata in self.core.api.getQueue() if pdata.linksdone < pdata.linkstotal): self.notify(_("Package failed"), _("One or more packages was not completed successfully")) @@ -70,15 +68,28 @@ class WindowsPhoneNotify(Hook): "</wp:Toast> </wp:Notification>" % msg) + @Expose def notify(self, event, msg=""): id = self.getConfig("id") url = self.getConfig("url") if not id or not url: - return False + return + + if self.core.isClientConnected() and not self.getConfig("ignoreclient"): + return + + elapsed_time = time.time() - self.last_notify + + if elapsed_time < self.getConf("sendtimewait"): + return + + if elapsed_time > 60: + self.notifications = 0 + + elif self.notifications >= self.getConf("sendpermin"): + return - if self.core.isClientConnected() and not self.getConfig("force"): - return False request = self.getXmlData("%s: %s" % (event, msg) if msg else event) webservice = httplib.HTTP(url) @@ -93,4 +104,5 @@ class WindowsPhoneNotify(Hook): webservice.send(request) webservice.close() - self.last_notify = time() + self.last_notify = time.time() + self.notifications += 1 -- cgit v1.2.3 From 6f7002bcc3520c47fafe5122b0e0cbada313887d Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sun, 8 Mar 2015 23:39:59 +0100 Subject: Whitespace cosmetics --- module/plugins/hooks/BypassCaptcha.py | 4 ++-- module/plugins/hooks/Captcha9Kw.py | 2 +- module/plugins/hooks/CaptchaBrotherhood.py | 2 +- module/plugins/hooks/Checksum.py | 6 +++--- module/plugins/hooks/ClickAndLoad.py | 2 +- module/plugins/hooks/DeathByCaptcha.py | 2 +- module/plugins/hooks/DebridItaliaCom.py | 4 ++-- module/plugins/hooks/ExpertDecoders.py | 2 +- module/plugins/hooks/ExternalScripts.py | 8 ++++---- module/plugins/hooks/ImageTyperz.py | 2 +- module/plugins/hooks/JustPremium.py | 6 +++--- module/plugins/hooks/PremiumTo.py | 2 +- module/plugins/hooks/ZeveraCom.py | 4 ++-- 13 files changed, 23 insertions(+), 23 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/BypassCaptcha.py b/module/plugins/hooks/BypassCaptcha.py index cf8754dae..777564554 100644 --- a/module/plugins/hooks/BypassCaptcha.py +++ b/module/plugins/hooks/BypassCaptcha.py @@ -35,9 +35,9 @@ class BypassCaptcha(Hook): __description__ = """Send captchas to BypassCaptcha.com""" __license__ = "GPLv3" - __authors__ = [("RaNaN", "RaNaN@pyload.org"), + __authors__ = [("RaNaN" , "RaNaN@pyload.org" ), ("Godofdream", "soilfcition@gmail.com"), - ("zoidberg", "zoidberg@mujmail.cz")] + ("zoidberg" , "zoidberg@mujmail.cz" )] PYLOAD_KEY = "4f771155b640970d5607f919a615bdefc67e7d32" diff --git a/module/plugins/hooks/Captcha9Kw.py b/module/plugins/hooks/Captcha9Kw.py index 544965b0f..2b4f405ed 100644 --- a/module/plugins/hooks/Captcha9Kw.py +++ b/module/plugins/hooks/Captcha9Kw.py @@ -32,7 +32,7 @@ class Captcha9Kw(Hook): __description__ = """Send captchas to 9kw.eu""" __license__ = "GPLv3" - __authors__ = [("RaNaN", "RaNaN@pyload.org"), + __authors__ = [("RaNaN" , "RaNaN@pyload.org" ), ("Walter Purcaro", "vuolter@gmail.com")] diff --git a/module/plugins/hooks/CaptchaBrotherhood.py b/module/plugins/hooks/CaptchaBrotherhood.py index 3c08f5e36..478138c3b 100644 --- a/module/plugins/hooks/CaptchaBrotherhood.py +++ b/module/plugins/hooks/CaptchaBrotherhood.py @@ -46,7 +46,7 @@ class CaptchaBrotherhood(Hook): __description__ = """Send captchas to CaptchaBrotherhood.com""" __license__ = "GPLv3" - __authors__ = [("RaNaN", "RaNaN@pyload.org"), + __authors__ = [("RaNaN" , "RaNaN@pyload.org" ), ("zoidberg", "zoidberg@mujmail.cz")] diff --git a/module/plugins/hooks/Checksum.py b/module/plugins/hooks/Checksum.py index 064375a41..7d08e6552 100644 --- a/module/plugins/hooks/Checksum.py +++ b/module/plugins/hooks/Checksum.py @@ -50,9 +50,9 @@ class Checksum(Hook): __description__ = """Verify downloaded file size and checksum""" __license__ = "GPLv3" - __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), - ("Walter Purcaro", "vuolter@gmail.com"), - ("stickell", "l.stickell@yahoo.it")] + __authors__ = [("zoidberg" , "zoidberg@mujmail.cz"), + ("Walter Purcaro", "vuolter@gmail.com" ), + ("stickell" , "l.stickell@yahoo.it")] methods = {'sfv' : 'crc32', diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 938269795..2f5938101 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -32,7 +32,7 @@ class ClickAndLoad(Hook): __description__ = """Click'n'Load hook plugin""" __license__ = "GPLv3" - __authors__ = [("RaNaN", "RaNaN@pyload.de"), + __authors__ = [("RaNaN" , "RaNaN@pyload.de" ), ("Walter Purcaro", "vuolter@gmail.com")] diff --git a/module/plugins/hooks/DeathByCaptcha.py b/module/plugins/hooks/DeathByCaptcha.py index d513c446d..a67e70c7e 100644 --- a/module/plugins/hooks/DeathByCaptcha.py +++ b/module/plugins/hooks/DeathByCaptcha.py @@ -59,7 +59,7 @@ class DeathByCaptcha(Hook): __description__ = """Send captchas to DeathByCaptcha.com""" __license__ = "GPLv3" - __authors__ = [("RaNaN", "RaNaN@pyload.org"), + __authors__ = [("RaNaN" , "RaNaN@pyload.org" ), ("zoidberg", "zoidberg@mujmail.cz")] diff --git a/module/plugins/hooks/DebridItaliaCom.py b/module/plugins/hooks/DebridItaliaCom.py index 719f3dd3a..399f6462f 100644 --- a/module/plugins/hooks/DebridItaliaCom.py +++ b/module/plugins/hooks/DebridItaliaCom.py @@ -20,8 +20,8 @@ class DebridItaliaCom(MultiHook): __description__ = """Debriditalia.com hook plugin""" __license__ = "GPLv3" - __authors__ = [("stickell", "l.stickell@yahoo.it"), - ("Walter Purcaro", "vuolter@gmail.com")] + __authors__ = [("stickell" , "l.stickell@yahoo.it"), + ("Walter Purcaro", "vuolter@gmail.com" )] def getHosters(self): diff --git a/module/plugins/hooks/ExpertDecoders.py b/module/plugins/hooks/ExpertDecoders.py index c9f8204c4..d6ecca680 100644 --- a/module/plugins/hooks/ExpertDecoders.py +++ b/module/plugins/hooks/ExpertDecoders.py @@ -21,7 +21,7 @@ class ExpertDecoders(Hook): __description__ = """Send captchas to expertdecoders.com""" __license__ = "GPLv3" - __authors__ = [("RaNaN", "RaNaN@pyload.org"), + __authors__ = [("RaNaN" , "RaNaN@pyload.org" ), ("zoidberg", "zoidberg@mujmail.cz")] diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index 76444d4b3..14387e234 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -17,9 +17,9 @@ class ExternalScripts(Hook): __description__ = """Run external scripts""" __license__ = "GPLv3" - __authors__ = [("mkaay", "mkaay@mkaay.de"), - ("RaNaN", "ranan@pyload.org"), - ("spoob", "spoob@pyload.org"), + __authors__ = [("mkaay" , "mkaay@mkaay.de" ), + ("RaNaN" , "ranan@pyload.org" ), + ("spoob" , "spoob@pyload.org" ), ("Walter Purcaro", "vuolter@gmail.com")] @@ -67,7 +67,7 @@ class ExternalScripts(Hook): if not os.path.isfile(file): continue - + if filename[0] in ("#", "_") or filename.endswith("~") or filename.endswith(".swp"): continue diff --git a/module/plugins/hooks/ImageTyperz.py b/module/plugins/hooks/ImageTyperz.py index d62fed385..b9dbfcdbe 100644 --- a/module/plugins/hooks/ImageTyperz.py +++ b/module/plugins/hooks/ImageTyperz.py @@ -40,7 +40,7 @@ class ImageTyperz(Hook): __description__ = """Send captchas to ImageTyperz.com""" __license__ = "GPLv3" - __authors__ = [("RaNaN", "RaNaN@pyload.org"), + __authors__ = [("RaNaN" , "RaNaN@pyload.org" ), ("zoidberg", "zoidberg@mujmail.cz")] diff --git a/module/plugins/hooks/JustPremium.py b/module/plugins/hooks/JustPremium.py index daefbc30f..3064743e2 100644 --- a/module/plugins/hooks/JustPremium.py +++ b/module/plugins/hooks/JustPremium.py @@ -15,9 +15,9 @@ class JustPremium(Hook): __description__ = """Remove not-premium links from added urls""" __license__ = "GPLv3" - __authors__ = [("mazleu", "mazleica@gmail.com"), - ("Walter Purcaro", "vuolter@gmail.com"), - ("immenz", "immenz@gmx.net")] + __authors__ = [("mazleu" , "mazleica@gmail.com"), + ("Walter Purcaro", "vuolter@gmail.com" ), + ("immenz" , "immenz@gmx.net" )] event_list = ["linksAdded"] diff --git a/module/plugins/hooks/PremiumTo.py b/module/plugins/hooks/PremiumTo.py index b629b111e..250125016 100644 --- a/module/plugins/hooks/PremiumTo.py +++ b/module/plugins/hooks/PremiumTo.py @@ -18,7 +18,7 @@ class PremiumTo(MultiHook): __description__ = """Premium.to hook plugin""" __license__ = "GPLv3" - __authors__ = [("RaNaN", "RaNaN@pyload.org"), + __authors__ = [("RaNaN" , "RaNaN@pyload.org" ), ("zoidberg", "zoidberg@mujmail.cz"), ("stickell", "l.stickell@yahoo.it")] diff --git a/module/plugins/hooks/ZeveraCom.py b/module/plugins/hooks/ZeveraCom.py index 215ec3673..33c49d8be 100644 --- a/module/plugins/hooks/ZeveraCom.py +++ b/module/plugins/hooks/ZeveraCom.py @@ -18,8 +18,8 @@ class ZeveraCom(MultiHook): __description__ = """Zevera.com hook plugin""" __license__ = "GPLv3" - __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), - ("Walter Purcaro", "vuolter@gmail.com")] + __authors__ = [("zoidberg" , "zoidberg@mujmail.cz"), + ("Walter Purcaro", "vuolter@gmail.com" )] def getHosters(self): -- cgit v1.2.3 From 04f2d0f9a377fcbabebd99c98ffc0638459acd6d Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Mon, 9 Mar 2015 04:06:15 +0100 Subject: [ExternalScripts] Fixup --- module/plugins/hooks/ExternalScripts.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index 14387e234..5f2790656 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -10,7 +10,7 @@ from module.utils import fs_encode, save_join class ExternalScripts(Hook): __name__ = "ExternalScripts" __type__ = "hook" - __version__ = "0.31" + __version__ = "0.32" __config__ = [("activated", "bool", "Activated" , True ), ("waitend" , "bool", "Wait script ending", False)] @@ -79,11 +79,11 @@ class ExternalScripts(Hook): def callScript(self, script, *args): try: - cmd = [(str(x) if not isinstance(x, basestring) else x).encode('utf-8') for x in args] + cmd = [script] + [(str(x) if not isinstance(x, basestring) else x).encode('utf-8') for x in args] self.logDebug("Executing", os.path.abspath(script), " ".join(cmd)) - p = subprocess.Popen([script, fs_encode(cmd)], bufsize=-1) #@NOTE: output goes to pyload + p = subprocess.Popen(cmd, bufsize=-1) #@NOTE: output goes to pyload if self.getConfig('waitend'): p.communicate() @@ -99,8 +99,8 @@ class ExternalScripts(Hook): def downloadFinished(self, pyfile): download_folder = self.config['general']['download_folder'] for script in self.scripts['download_finished']: - filename = save_join(download_folder, pyfile.package().folder, pyfile.name) - self.callScript(script, pyfile.pluginname, pyfile.url, pyfile.name, filename, pyfile.id) + file = save_join(download_folder, pyfile.package().folder, pyfile.name) + self.callScript(script, pyfile.pluginname, pyfile.url, pyfile.name, file, pyfile.id) def packageFinished(self, pypack): -- cgit v1.2.3 From 164ff94bd87b8b0de3c872b0b60153ac5abfad4b Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Mon, 9 Mar 2015 23:26:18 +0100 Subject: [ExtractArchive] Fix https://github.com/pyload/pyload/issues/1241 --- module/plugins/hooks/ExtractArchive.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 6a25602e8..edf25b8c7 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -108,7 +108,7 @@ class ArchiveQueue(object): class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.32" + __version__ = "1.33" __config__ = [("activated" , "bool" , "Activated" , True ), ("fullpath" , "bool" , "Extract with full paths" , True ), @@ -474,7 +474,7 @@ class ExtractArchive(Hook): print_exc() finally: - pyfile.finishIfDone() + thread.finishFile(pyfile) self.manager.dispatchEvent("archive_extract_failed", pyfile) -- cgit v1.2.3 From f85e28e565a1e0a76e6271d0b0853d6d48b4a043 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Tue, 10 Mar 2015 01:16:29 +0100 Subject: [MultiHook] Fix _pluginSet (fix LinkdecrypterCom issue) --- module/plugins/hooks/LinkdecrypterCom.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/LinkdecrypterCom.py b/module/plugins/hooks/LinkdecrypterCom.py index f85a598bc..769e63e81 100644 --- a/module/plugins/hooks/LinkdecrypterCom.py +++ b/module/plugins/hooks/LinkdecrypterCom.py @@ -8,7 +8,7 @@ from module.plugins.internal.MultiHook import MultiHook class LinkdecrypterCom(MultiHook): __name__ = "LinkdecrypterCom" __type__ = "hook" - __version__ = "1.02" + __version__ = "1.03" __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), @@ -22,4 +22,4 @@ class LinkdecrypterCom(MultiHook): def getCrypters(self): return re.search(r'>Supported\(\d+\)</b>: <i>(.[\w.\-, ]+)', - self.getURL("http://linkdecrypter.com/").replace("(g)", "")).group(1).split(', ') + self.getURL("http://linkdecrypter.com/", decode=True).replace("(g)", "")).group(1).split(', ') -- cgit v1.2.3 From 7beb65e991bc6d1913c3b5bb2ef69e659d5b8342 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Tue, 10 Mar 2015 01:55:52 +0100 Subject: Spare code cosmetics --- module/plugins/hooks/AlldebridCom.py | 2 +- module/plugins/hooks/AndroidPhoneNotify.py | 18 ++++++++------- module/plugins/hooks/AntiVirus.py | 7 +++--- module/plugins/hooks/BypassCaptcha.py | 10 ++++----- module/plugins/hooks/Captcha9Kw.py | 36 +++++++++++++++--------------- module/plugins/hooks/CaptchaBrotherhood.py | 14 ++++++------ module/plugins/hooks/Checksum.py | 12 +++++----- module/plugins/hooks/ClickAndLoad.py | 2 +- module/plugins/hooks/DeathByCaptcha.py | 10 ++++----- module/plugins/hooks/DownloadScheduler.py | 4 ++-- module/plugins/hooks/ExpertDecoders.py | 10 ++++----- module/plugins/hooks/ExternalScripts.py | 19 ++++++++-------- module/plugins/hooks/HotFolder.py | 8 +++---- module/plugins/hooks/IRCInterface.py | 22 +++++++++--------- module/plugins/hooks/ImageTyperz.py | 18 +++++++-------- module/plugins/hooks/MultiHome.py | 2 +- module/plugins/hooks/OverLoadMe.py | 2 +- module/plugins/hooks/RealdebridCom.py | 2 +- module/plugins/hooks/RestartFailed.py | 8 +++---- module/plugins/hooks/RestartSlow.py | 4 ++-- module/plugins/hooks/SkipRev.py | 22 +++++++++--------- module/plugins/hooks/UnSkipOnFail.py | 2 +- module/plugins/hooks/UpdateManager.py | 16 ++++++------- module/plugins/hooks/WindowsPhoneNotify.py | 17 ++++++++------ module/plugins/hooks/XFileSharingPro.py | 14 ++++++------ module/plugins/hooks/XMPPInterface.py | 14 ++++++------ 26 files changed, 150 insertions(+), 145 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/AlldebridCom.py b/module/plugins/hooks/AlldebridCom.py index fd89571eb..517adcb68 100644 --- a/module/plugins/hooks/AlldebridCom.py +++ b/module/plugins/hooks/AlldebridCom.py @@ -23,7 +23,7 @@ class AlldebridCom(MultiHook): def getHosters(self): - https = "https" if self.getConfig("ssl") else "http" + https = "https" if self.getConfig('ssl') else "http" html = self.getURL(https + "://www.alldebrid.com/api.php", get={'action': "get_host"}).replace("\"", "").strip() return [x.strip() for x in html.split(",") if x.strip()] diff --git a/module/plugins/hooks/AndroidPhoneNotify.py b/module/plugins/hooks/AndroidPhoneNotify.py index 7a9e6d6f8..180ad0d78 100644 --- a/module/plugins/hooks/AndroidPhoneNotify.py +++ b/module/plugins/hooks/AndroidPhoneNotify.py @@ -40,19 +40,19 @@ class AndroidPhoneNotify(Hook): def newCaptchaTask(self, task): - if not self.getConfig("notifycaptcha"): + if not self.getConfig('notifycaptcha'): return self.notify(_("Captcha"), _("New request waiting user input")) def packageFinished(self, pypack): - if self.getConfig("notifypackage"): + if self.getConfig('notifypackage'): self.notify(_("Package finished"), pypack.name) def allDownloadsProcessed(self): - if not self.getConfig("notifyprocessed"): + if not self.getConfig('notifyprocessed'): return if any(True for pdata in self.core.api.getQueue() if pdata.linksdone < pdata.linkstotal): @@ -62,13 +62,15 @@ class AndroidPhoneNotify(Hook): @Expose - def notify(self, event, msg=""): - apikey = self.getConfig("apikey") + def notify(self, + event, + msg="", + key=self.getConfig('apikey')): - if not apikey: + if not key: return - if self.core.isClientConnected() and not self.getConfig("ignoreclient"): + if self.core.isClientConnected() and not self.getConfig('ignoreclient'): return elapsed_time = time.time() - self.last_notify @@ -84,7 +86,7 @@ class AndroidPhoneNotify(Hook): getURL("http://www.notifymyandroid.com/publicapi/notify", - get={'apikey' : apikey, + get={'apikey' : key, 'application': "pyLoad", 'event' : event, 'description': msg}) diff --git a/module/plugins/hooks/AntiVirus.py b/module/plugins/hooks/AntiVirus.py index 695852683..b8a659f99 100644 --- a/module/plugins/hooks/AntiVirus.py +++ b/module/plugins/hooks/AntiVirus.py @@ -13,7 +13,7 @@ class AntiVirus(Hook): __type__ = "hook" __version__ = "0.04" - __config__ = [("action" , "Antivirus default;Delete;Quarantine", "Manage infected files" , "Antivirus default"), + __config__ = [("action" , "Antivirus default;Delete;Quarantine", "Manage infected files" , "Antivirus default"), #@TODO: add trash option (use Send2Trash lib) ("quardir" , "folder" , "Quarantine folder" , "" ), ("scanfailed", "bool" , "Scan incompleted files (failed downloads)", False ), ("cmdfile" , "file" , "Antivirus executable" , "" ), @@ -55,7 +55,7 @@ class AntiVirus(Hook): if err: self.logWarning(filename, err) if not self.getConfig('ignore-err') - self.logDebug("Delete/Quarantine action aborted") + self.logDebug("Delete/Quarantine task is aborted") return if p.returncode: @@ -68,8 +68,7 @@ class AntiVirus(Hook): elif action == "Quarantine": pyfile.setCustomStatus(_("file moving")) pyfile.setProgress(0) - new_filename = save_join(self.getConfig('quardir'), filename) - shutil.move(file, new_filename) + shutil.move(file, self.getConfig('quardir')) except (IOError, shutil.Error), e: self.logError(filename, action + " action failed!", e) diff --git a/module/plugins/hooks/BypassCaptcha.py b/module/plugins/hooks/BypassCaptcha.py index 777564554..d7995650b 100644 --- a/module/plugins/hooks/BypassCaptcha.py +++ b/module/plugins/hooks/BypassCaptcha.py @@ -57,7 +57,7 @@ class BypassCaptcha(Hook): def getCredits(self): - res = getURL(self.GETCREDITS_URL, post={"key": self.getConfig("passkey")}) + res = getURL(self.GETCREDITS_URL, post={"key": self.getConfig('passkey')}) data = dict(x.split(' ', 1) for x in res.splitlines()) return int(data['Left']) @@ -72,7 +72,7 @@ class BypassCaptcha(Hook): try: res = req.load(self.SUBMIT_URL, post={'vendor_key': self.PYLOAD_KEY, - 'key': self.getConfig("passkey"), + 'key': self.getConfig('passkey'), 'gen_task_id': "1", 'file': (FORM_FILE, captcha)}, multipart=True) @@ -92,7 +92,7 @@ class BypassCaptcha(Hook): def respond(self, ticket, success): try: - res = getURL(self.RESPOND_URL, post={"task_id": ticket, "key": self.getConfig("passkey"), + res = getURL(self.RESPOND_URL, post={"task_id": ticket, "key": self.getConfig('passkey'), "cv": 1 if success else 0}) except BadHeader, e: self.logError(_("Could not send response"), e) @@ -105,10 +105,10 @@ class BypassCaptcha(Hook): if not task.isTextual(): return False - if not self.getConfig("passkey"): + if not self.getConfig('passkey'): return False - if self.core.isClientConnected() and not self.getConfig("force"): + if self.core.isClientConnected() and not self.getConfig('force'): return False if self.getCredits() > 0: diff --git a/module/plugins/hooks/Captcha9Kw.py b/module/plugins/hooks/Captcha9Kw.py index 2b4f405ed..6d42416ff 100644 --- a/module/plugins/hooks/Captcha9Kw.py +++ b/module/plugins/hooks/Captcha9Kw.py @@ -46,13 +46,13 @@ class Captcha9Kw(Hook): def setup(self): self.info = {} #@TODO: Remove in 0.4.10 - if self.getConfig("ssl"): + if self.getConfig('ssl'): self.API_URL = self.API_URL.replace("http://", "https://") def getCredits(self): res = getURL(self.API_URL, - get={'apikey': self.getConfig("passkey"), + get={'apikey': self.getConfig('passkey'), 'pyload': "1", 'source': "pyload", 'action': "usercaptchaguthaben"}) @@ -83,14 +83,14 @@ class Captcha9Kw(Hook): 'numeric' : 0, 'case_sensitive': 0, 'math' : 0, - 'prio' : min(max(self.getConfig("prio"), 0), 10), - 'confirm' : self.getConfig("confirm"), - 'timeout' : min(max(self.getConfig("timeout"), 300), 3999), - 'selfsolve' : self.getConfig("selfsolve"), - 'cph' : self.getConfig("captchaperhour"), - 'cpm' : self.getConfig("captchapermin")} + 'prio' : min(max(self.getConfig('prio'), 0), 10), + 'confirm' : self.getConfig('confirm'), + 'timeout' : min(max(self.getConfig('timeout'), 300), 3999), + 'selfsolve' : self.getConfig('selfsolve'), + 'cph' : self.getConfig('captchaperhour'), + 'cpm' : self.getConfig('captchapermin')} - for opt in str(self.getConfig("hoster_options").split('|')): + for opt in str(self.getConfig('hoster_options').split('|')): details = map(str.strip, opt.split(':')) @@ -109,7 +109,7 @@ class Captcha9Kw(Hook): break - post_data = {'apikey' : self.getConfig("passkey"), + post_data = {'apikey' : self.getConfig('passkey'), 'prio' : option['prio'], 'confirm' : option['confirm'], 'maxtimeout' : option['timeout'], @@ -146,9 +146,9 @@ class Captcha9Kw(Hook): task.data["ticket"] = res - for _i in xrange(int(self.getConfig("timeout") / 5)): + for _i in xrange(int(self.getConfig('timeout') / 5)): result = getURL(self.API_URL, - get={'apikey': self.getConfig("passkey"), + get={'apikey': self.getConfig('passkey'), 'id' : res, 'pyload': "1", 'info' : "1", @@ -172,10 +172,10 @@ class Captcha9Kw(Hook): if not task.isTextual() and not task.isPositional(): return - if not self.getConfig("passkey"): + if not self.getConfig('passkey'): return - if self.core.isClientConnected() and not self.getConfig("force"): + if self.core.isClientConnected() and not self.getConfig('force'): return credits = self.getCredits() @@ -184,8 +184,8 @@ class Captcha9Kw(Hook): self.logError(_("Your captcha 9kw.eu account has not enough credits")) return - queue = min(self.getConfig("queue"), 999) - timeout = min(max(self.getConfig("timeout"), 300), 3999) + queue = min(self.getConfig('queue'), 999) + timeout = min(max(self.getConfig('timeout'), 300), 3999) pluginname = re.search(r'_([^_]*)_\d+.\w+', task.captchaFile).group(1) for _i in xrange(5): @@ -197,7 +197,7 @@ class Captcha9Kw(Hook): else: self.fail(_("Too many captchas in queue")) - for opt in str(self.getConfig("hoster_options").split('|')): + for opt in str(self.getConfig('hoster_options').split('|')): details = map(str.strip, opt.split(':')) if not details or details[0].lower() != pluginname.lower(): @@ -227,7 +227,7 @@ class Captcha9Kw(Hook): self.logDebug("No CaptchaID for %s request (task: %s)" % (type, task)) return - passkey = self.getConfig("passkey") + passkey = self.getConfig('passkey') for _i in xrange(3): res = getURL(self.API_URL, diff --git a/module/plugins/hooks/CaptchaBrotherhood.py b/module/plugins/hooks/CaptchaBrotherhood.py index 478138c3b..5350b4f7d 100644 --- a/module/plugins/hooks/CaptchaBrotherhood.py +++ b/module/plugins/hooks/CaptchaBrotherhood.py @@ -64,7 +64,7 @@ class CaptchaBrotherhood(Hook): def getCredits(self): res = getURL(self.API_URL + "askCredits.aspx", - get={"username": self.getConfig("username"), "password": self.getConfig("passkey")}) + get={"username": self.getConfig('username'), "password": self.getConfig('passkey')}) if not res.startswith("OK"): raise CaptchaBrotherhoodException(res) else: @@ -93,8 +93,8 @@ class CaptchaBrotherhood(Hook): req = getRequest() url = "%ssendNewCaptcha.aspx?%s" % (self.API_URL, - urlencode({'username' : self.getConfig("username"), - 'password' : self.getConfig("passkey"), + urlencode({'username' : self.getConfig('username'), + 'password' : self.getConfig('passkey'), 'captchaSource': "pyLoad", 'timeout' : "80"})) @@ -127,8 +127,8 @@ class CaptchaBrotherhood(Hook): def api_response(self, api, ticket): res = getURL("%s%s.aspx" % (self.API_URL, api), - get={"username": self.getConfig("username"), - "password": self.getConfig("passkey"), + get={"username": self.getConfig('username'), + "password": self.getConfig('passkey'), "captchaID": ticket}) if not res.startswith("OK"): raise CaptchaBrotherhoodException("Unknown response: %s" % res) @@ -143,10 +143,10 @@ class CaptchaBrotherhood(Hook): if not task.isTextual(): return False - if not self.getConfig("username") or not self.getConfig("passkey"): + if not self.getConfig('username') or not self.getConfig('passkey'): return False - if self.core.isClientConnected() and not self.getConfig("force"): + if self.core.isClientConnected() and not self.getConfig('force'): return False if self.getCredits() > 10: diff --git a/module/plugins/hooks/Checksum.py b/module/plugins/hooks/Checksum.py index 7d08e6552..9474f6968 100644 --- a/module/plugins/hooks/Checksum.py +++ b/module/plugins/hooks/Checksum.py @@ -70,7 +70,7 @@ class Checksum(Hook): def coreReady(self): - if not self.getConfig("check_checksum"): + if not self.getConfig('check_checksum'): self.logInfo(_("Checksum validation is disabled in plugin configuration")) @@ -125,7 +125,7 @@ class Checksum(Hook): data.pop('size', None) # validate checksum - if data and self.getConfig("check_checksum"): + if data and self.getConfig('check_checksum'): if not 'md5' in data: for type in ("checksum", "hashsum", "hash"): @@ -152,14 +152,14 @@ class Checksum(Hook): def checkFailed(self, pyfile, local_file, msg): - check_action = self.getConfig("check_action") + check_action = self.getConfig('check_action') if check_action == "retry": - max_tries = self.getConfig("max_tries") - retry_action = self.getConfig("retry_action") + max_tries = self.getConfig('max_tries') + retry_action = self.getConfig('retry_action') if pyfile.plugin.retries < max_tries: if local_file: remove(local_file) - pyfile.plugin.retry(max_tries, self.getConfig("wait_time"), msg) + pyfile.plugin.retry(max_tries, self.getConfig('wait_time'), msg) elif retry_action == "nothing": return elif check_action == "nothing": diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 2f5938101..731c8bd7e 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -45,7 +45,7 @@ class ClickAndLoad(Hook): if not self.config['webinterface']['activated']: return - ip = "" if self.getConfig("extern") else "127.0.0.1" + ip = "" if self.getConfig('extern') else "127.0.0.1" webport = self.config['webinterface']['port'] cnlport = self.getConfig('port') diff --git a/module/plugins/hooks/DeathByCaptcha.py b/module/plugins/hooks/DeathByCaptcha.py index a67e70c7e..4eefb2bff 100644 --- a/module/plugins/hooks/DeathByCaptcha.py +++ b/module/plugins/hooks/DeathByCaptcha.py @@ -82,8 +82,8 @@ class DeathByCaptcha(Hook): if post: if not isinstance(post, dict): post = {} - post.update({"username": self.getConfig("username"), - "password": self.getConfig("passkey")}) + post.update({"username": self.getConfig('username'), + "password": self.getConfig('passkey')}) res = None try: @@ -136,7 +136,7 @@ class DeathByCaptcha(Hook): def submit(self, captcha, captchaType="file", match=None): #@NOTE: Workaround multipart-post bug in HTTPRequest.py - if re.match("^\w*$", self.getConfig("passkey")): + if re.match("^\w*$", self.getConfig('passkey')): multipart = True data = (FORM_FILE, captcha) else: @@ -172,10 +172,10 @@ class DeathByCaptcha(Hook): if not task.isTextual(): return False - if not self.getConfig("username") or not self.getConfig("passkey"): + if not self.getConfig('username') or not self.getConfig('passkey'): return False - if self.core.isClientConnected() and not self.getConfig("force"): + if self.core.isClientConnected() and not self.getConfig('force'): return False try: diff --git a/module/plugins/hooks/DownloadScheduler.py b/module/plugins/hooks/DownloadScheduler.py index 4996e212d..3b7ae524c 100644 --- a/module/plugins/hooks/DownloadScheduler.py +++ b/module/plugins/hooks/DownloadScheduler.py @@ -37,7 +37,7 @@ class DownloadScheduler(Hook): def updateSchedule(self, schedule=None): if schedule is None: - schedule = self.getConfig("timetable") + schedule = self.getConfig('timetable') schedule = re.findall("(\d{1,2}):(\d{2})[\s]*(-?\d+)", schedule.lower().replace("full", "-1").replace("none", "0")) @@ -65,7 +65,7 @@ class DownloadScheduler(Hook): def setDownloadSpeed(self, speed): if speed == 0: - abort = self.getConfig("abort") + abort = self.getConfig('abort') self.logInfo(_("Stopping download server. (Running downloads will %sbe aborted.)") % '' if abort else _('not ')) self.core.api.pauseServer() if abort: diff --git a/module/plugins/hooks/ExpertDecoders.py b/module/plugins/hooks/ExpertDecoders.py index d6ecca680..fa1c7a14b 100644 --- a/module/plugins/hooks/ExpertDecoders.py +++ b/module/plugins/hooks/ExpertDecoders.py @@ -38,7 +38,7 @@ class ExpertDecoders(Hook): def getCredits(self): - res = getURL(self.API_URL, post={"key": self.getConfig("passkey"), "action": "balance"}) + res = getURL(self.API_URL, post={"key": self.getConfig('passkey'), "action": "balance"}) if res.isdigit(): self.logInfo(_("%s credits left") % res) @@ -64,7 +64,7 @@ class ExpertDecoders(Hook): try: result = req.load(self.API_URL, post={'action' : "upload", - 'key' : self.getConfig("passkey"), + 'key' : self.getConfig('passkey'), 'file' : b64encode(data), 'gen_task_id': ticket}) finally: @@ -78,10 +78,10 @@ class ExpertDecoders(Hook): if not task.isTextual(): return False - if not self.getConfig("passkey"): + if not self.getConfig('passkey'): return False - if self.core.isClientConnected() and not self.getConfig("force"): + if self.core.isClientConnected() and not self.getConfig('force'): return False if self.getCredits() > 0: @@ -98,7 +98,7 @@ class ExpertDecoders(Hook): try: res = getURL(self.API_URL, - post={'action': "refund", 'key': self.getConfig("passkey"), 'gen_task_id': task.data['ticket']}) + post={'action': "refund", 'key': self.getConfig('passkey'), 'gen_task_id': task.data['ticket']}) self.logInfo(_("Request refund"), res) except BadHeader, e: diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index 5f2790656..d17e4740c 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -44,26 +44,25 @@ class ExternalScripts(Hook): for folder in folders: self.scripts[folder] = [] - - self.initPluginType(folder, os.path.join(pypath, 'scripts', folder)) - self.initPluginType(folder, os.path.join('scripts', folder)) + for dir in (pypath, ''): + self.initPluginType(folder, os.path.join(dir, 'scripts', folder)) for script_type, names in self.scripts.iteritems(): if names: self.logInfo(_("Installed scripts for ") + script_type, ", ".join(map(os.path.basename, names))) - def initPluginType(self, folder, path): - if not os.path.exists(path): + def initPluginType(self, name, dir): + if not os.path.isdir(dir): try: - os.makedirs(path) + os.makedirs(dir) except IOError, e: self.logDebug(e) return - for filename in os.listdir(path): - file = os.path.join(path, filename) + for filename in os.listdir(dir): + file = os.path.join(dir, filename) if not os.path.isfile(file): continue @@ -72,9 +71,9 @@ class ExternalScripts(Hook): continue if not os.access(file, os.X_OK): - self.logWarning(_("Script not executable:") + " %s/%s" % (folder, filename)) + self.logWarning(_("Script not executable:") + " %s/%s" % (name, filename)) - self.scripts[folder].append(file) + self.scripts[name].append(file) def callScript(self, script, *args): diff --git a/module/plugins/hooks/HotFolder.py b/module/plugins/hooks/HotFolder.py index 302bc909f..a046e55e7 100644 --- a/module/plugins/hooks/HotFolder.py +++ b/module/plugins/hooks/HotFolder.py @@ -31,14 +31,14 @@ class HotFolder(Hook): def periodical(self): - folder = fs_encode(self.getConfig("folder")) - file = fs_encode(self.getConfig("file")) + folder = fs_encode(self.getConfig('folder')) + file = fs_encode(self.getConfig('file')) try: if not os.path.isdir(os.path.join(folder, "finished")): os.makedirs(os.path.join(folder, "finished")) - if self.getConfig("watch_file"): + if self.getConfig('watch_file'): with open(file, "a+") as f: f.seek(0) content = f.read().strip() @@ -60,7 +60,7 @@ class HotFolder(Hook): if not os.path.isfile(path) or f.endswith("~") or f.startswith("#") or f.startswith("."): continue - newpath = os.path.join(folder, "finished", f if self.getConfig("keep") else "tmp_" + f) + newpath = os.path.join(folder, "finished", f if self.getConfig('keep') else "tmp_" + f) move(path, newpath) self.logInfo(_("Added %s from HotFolder") % f) diff --git a/module/plugins/hooks/IRCInterface.py b/module/plugins/hooks/IRCInterface.py index 623f2d1bf..1c90c0e2f 100644 --- a/module/plugins/hooks/IRCInterface.py +++ b/module/plugins/hooks/IRCInterface.py @@ -59,7 +59,7 @@ class IRCInterface(Thread, Hook): def packageFinished(self, pypack): try: - if self.getConfig("info_pack"): + if self.getConfig('info_pack'): self.response(_("Package finished: %s") % pypack.name) except Exception: pass @@ -67,7 +67,7 @@ class IRCInterface(Thread, Hook): def downloadFinished(self, pyfile): try: - if self.getConfig("info_file"): + if self.getConfig('info_file'): self.response( _("Download finished: %(name)s @ %(plugin)s ") % {"name": pyfile.name, "plugin": pyfile.pluginname}) except Exception: @@ -75,7 +75,7 @@ class IRCInterface(Thread, Hook): def newCaptchaTask(self, task): - if self.getConfig("captcha") and task.isTextual(): + if self.getConfig('captcha') and task.isTextual(): task.handler.append(self) task.setWaiting(60) @@ -90,16 +90,16 @@ class IRCInterface(Thread, Hook): def run(self): # connect to IRC etc. self.sock = socket.socket() - host = self.getConfig("host") - self.sock.connect((host, self.getConfig("port"))) + host = self.getConfig('host') + self.sock.connect((host, self.getConfig('port'))) - if self.getConfig("ssl"): + if self.getConfig('ssl'): self.sock = ssl.wrap_socket(self.sock, cert_reqs=ssl.CERT_NONE) #@TODO: support certificate - nick = self.getConfig("nick") + nick = self.getConfig('nick') self.sock.send("NICK %s\r\n" % nick) self.sock.send("USER %s %s bla :%s\r\n" % (nick, host, nick)) - for t in self.getConfig("owner").split(): + for t in self.getConfig('owner').split(): if t.strip().startswith("#"): self.sock.send("JOIN %s\r\n" % t.strip()) self.logInfo(_("Connected to"), host) @@ -153,10 +153,10 @@ class IRCInterface(Thread, Hook): def handle_events(self, msg): - if not msg['origin'].split("!", 1)[0] in self.getConfig("owner").split(): + if not msg['origin'].split("!", 1)[0] in self.getConfig('owner').split(): return - if msg['target'].split("!", 1)[0] != self.getConfig("nick"): + if msg['target'].split("!", 1)[0] != self.getConfig('nick'): return if msg['action'] != "PRIVMSG": @@ -197,7 +197,7 @@ class IRCInterface(Thread, Hook): def response(self, msg, origin=""): if origin == "": - for t in self.getConfig("owner").split(): + for t in self.getConfig('owner').split(): self.sock.send("PRIVMSG %s :%s\r\n" % (t.strip(), msg)) else: self.sock.send("PRIVMSG %s :%s\r\n" % (origin.split("!", 1)[0], msg)) diff --git a/module/plugins/hooks/ImageTyperz.py b/module/plugins/hooks/ImageTyperz.py index b9dbfcdbe..2cf611b9f 100644 --- a/module/plugins/hooks/ImageTyperz.py +++ b/module/plugins/hooks/ImageTyperz.py @@ -61,8 +61,8 @@ class ImageTyperz(Hook): def getCredits(self): res = getURL(self.GETCREDITS_URL, post={'action': "REQUESTBALANCE", - 'username': self.getConfig("username"), - 'password': self.getConfig("passkey")}) + 'username': self.getConfig('username'), + 'password': self.getConfig('passkey')}) if res.startswith('ERROR'): raise ImageTyperzException(res) @@ -83,7 +83,7 @@ class ImageTyperz(Hook): try: #@NOTE: Workaround multipart-post bug in HTTPRequest.py - if re.match("^\w*$", self.getConfig("passkey")): + if re.match("^\w*$", self.getConfig('passkey')): multipart = True data = (FORM_FILE, captcha) else: @@ -94,8 +94,8 @@ class ImageTyperz(Hook): res = req.load(self.SUBMIT_URL, post={'action': "UPLOADCAPTCHA", - 'username': self.getConfig("username"), - 'password': self.getConfig("passkey"), "file": data}, + 'username': self.getConfig('username'), + 'password': self.getConfig('passkey'), "file": data}, multipart=multipart) finally: req.close() @@ -119,10 +119,10 @@ class ImageTyperz(Hook): if not task.isTextual(): return False - if not self.getConfig("username") or not self.getConfig("passkey"): + if not self.getConfig('username') or not self.getConfig('passkey'): return False - if self.core.isClientConnected() and not self.getConfig("force"): + if self.core.isClientConnected() and not self.getConfig('force'): return False if self.getCredits() > 0: @@ -139,8 +139,8 @@ class ImageTyperz(Hook): if task.data['service'] == self.__name__ and "ticket" in task.data: res = getURL(self.RESPOND_URL, post={'action': "SETBADIMAGE", - 'username': self.getConfig("username"), - 'password': self.getConfig("passkey"), + 'username': self.getConfig('username'), + 'password': self.getConfig('passkey'), 'imageid': task.data['ticket']}) if res == "SUCCESS": diff --git a/module/plugins/hooks/MultiHome.py b/module/plugins/hooks/MultiHome.py index c9f6fc30c..9093c8459 100644 --- a/module/plugins/hooks/MultiHome.py +++ b/module/plugins/hooks/MultiHome.py @@ -25,7 +25,7 @@ class MultiHome(Hook): def setup(self): self.register = {} self.interfaces = [] - self.parseInterfaces(self.getConfig("interfaces").split(";")) + self.parseInterfaces(self.getConfig('interfaces').split(";")) if not self.interfaces: self.parseInterfaces([self.config['download']['interface']]) self.setConfig("interfaces", self.toConfig()) diff --git a/module/plugins/hooks/OverLoadMe.py b/module/plugins/hooks/OverLoadMe.py index b15ce2766..5e1040da7 100644 --- a/module/plugins/hooks/OverLoadMe.py +++ b/module/plugins/hooks/OverLoadMe.py @@ -23,7 +23,7 @@ class OverLoadMe(MultiHook): def getHosters(self): - https = "https" if self.getConfig("ssl") else "http" + https = "https" if self.getConfig('ssl') else "http" html = self.getURL(https + "://api.over-load.me/hoster.php", get={'auth': "0001-cb1f24dadb3aa487bda5afd3b76298935329be7700cd7-5329be77-00cf-1ca0135f"}).replace("\"", "").strip() self.logDebug("Hosterlist", html) diff --git a/module/plugins/hooks/RealdebridCom.py b/module/plugins/hooks/RealdebridCom.py index d9c9407dd..c97bc257c 100644 --- a/module/plugins/hooks/RealdebridCom.py +++ b/module/plugins/hooks/RealdebridCom.py @@ -23,7 +23,7 @@ class RealdebridCom(MultiHook): def getHosters(self): - https = "https" if self.getConfig("ssl") else "http" + https = "https" if self.getConfig('ssl') else "http" html = self.getURL(https + "://real-debrid.com/api/hosters.php").replace("\"", "").strip() return [x.strip() for x in html.split(",") if x.strip()] diff --git a/module/plugins/hooks/RestartFailed.py b/module/plugins/hooks/RestartFailed.py index 07fb80967..7752b6a61 100644 --- a/module/plugins/hooks/RestartFailed.py +++ b/module/plugins/hooks/RestartFailed.py @@ -17,13 +17,13 @@ class RestartFailed(Hook): # event_list = ["pluginConfigChanged"] - MIN_INTERVAL = 15 * 60 #: 15m minimum check interval (value is in seconds) + MIN_CHECK_INTERVAL = 15 * 60 #: 15 minutes def pluginConfigChanged(self, plugin, name, value): if name == "interval": interval = value * 60 - if self.MIN_INTERVAL <= interval != self.interval: + if self.MIN_CHECK_INTERVAL <= interval != self.interval: self.core.scheduler.removeJob(self.cb) self.interval = interval self.initPeriodical() @@ -37,8 +37,8 @@ class RestartFailed(Hook): def setup(self): - self.interval = self.MIN_INTERVAL + self.interval = self.MIN_CHECK_INTERVAL def coreReady(self): - self.pluginConfigChanged(self.__name__, "interval", self.getConfig("interval")) + self.pluginConfigChanged(self.__name__, "interval", self.getConfig('interval')) diff --git a/module/plugins/hooks/RestartSlow.py b/module/plugins/hooks/RestartSlow.py index c3e1e5468..834128489 100644 --- a/module/plugins/hooks/RestartSlow.py +++ b/module/plugins/hooks/RestartSlow.py @@ -36,7 +36,7 @@ class RestartSlow(Hook): if not self.pyfile.plugin.req.dl: return - if self.getConfig("safe_mode") and not self.pyfile.plugin.resumeDownload: + if self.getConfig('safe_mode') and not self.pyfile.plugin.resumeDownload: time = 30 limit = 5 else: @@ -55,7 +55,7 @@ class RestartSlow(Hook): def downloadStarts(self, pyfile, url, filename): - if self.cb or (self.getConfig("safe_mode") and not pyfile.plugin.resumeDownload): + if self.cb or (self.getConfig('safe_mode') and not pyfile.plugin.resumeDownload): return self.pyfile = pyfile super(RestartSlow, self).initPeriodical() diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py index 521c2c39e..88ffb0103 100644 --- a/module/plugins/hooks/SkipRev.py +++ b/module/plugins/hooks/SkipRev.py @@ -11,16 +11,10 @@ from module.plugins.Hook import Hook from module.plugins.Plugin import SkipDownload -def _setup(self): - self.pyfile.plugin._setup() - if self.pyfile.hasStatus("skipped"): - raise SkipDownload(self.pyfile.statusname or self.pyfile.pluginname) - - class SkipRev(Hook): __name__ = "SkipRev" __type__ = "hook" - __version__ = "0.28" + __version__ = "0.29" __config__ = [("mode" , "Auto;Manual", "Choose rev files to skip for package", "Auto"), ("revtokeep", "int" , "Number of rev files to keep" , 0 )] @@ -35,6 +29,13 @@ class SkipRev(Hook): pass + @staticmethod + def _setup(self): + self.pyfile.plugin._setup() + if self.pyfile.hasStatus("skipped"): + raise SkipDownload(self.pyfile.statusname or self.pyfile.pluginname) + + def _name(self, pyfile): if hasattr(pyfile.pluginmodule, "getInfo"): #@NOTE: getInfo is deprecated in 0.4.10 return pyfile.pluginmodule.getInfo([pyfile.url]).next()[0] @@ -59,7 +60,7 @@ class SkipRev(Hook): def downloadPreparing(self, pyfile): name = self._name(pyfile) - if pyfile.statusname is "unskipped" or not name.endswith(".rev") or not ".part" in name: + if pyfile.statusname is _("unskipped") or not name.endswith(".rev") or not ".part" in name: return revtokeep = -1 if self.getConfig('mode') == "Auto" else self.getConfig('revtokeep') @@ -77,8 +78,9 @@ class SkipRev(Hook): pyfile.setCustomStatus("SkipRev", "skipped") if not hasattr(pyfile.plugin, "_setup"): + # Work-around: inject status checker inside the preprocessing routine of the plugin pyfile.plugin._setup = pyfile.plugin.setup - pyfile.plugin.setup = MethodType(_setup, pyfile.plugin) #: work-around: inject status checker inside the preprocessing routine of the plugin + pyfile.plugin.setup = MethodType(self._setup, pyfile.plugin) def downloadFailed(self, pyfile): @@ -101,7 +103,7 @@ class SkipRev(Hook): if revtokeep > -1 or pyfile.name.endswith(".rev"): pylink.setStatus("queued") else: - pylink.setCustomStatus("unskipped", "queued") + pylink.setCustomStatus(_("unskipped"), "queued") self.core.files.save() pylink.release() diff --git a/module/plugins/hooks/UnSkipOnFail.py b/module/plugins/hooks/UnSkipOnFail.py index 1becb937a..7a5ae8e09 100644 --- a/module/plugins/hooks/UnSkipOnFail.py +++ b/module/plugins/hooks/UnSkipOnFail.py @@ -43,7 +43,7 @@ class UnSkipOnFail(Hook): # the core.files-manager to save its data. pylink = _pyfile(link) - pylink.setCustomStatus("UnSkipOnFail", "queued") + pylink.setCustomStatus(_("unskipped"), "queued") self.core.files.save() pylink.release() diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index a0b044edb..45d666f45 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -46,13 +46,13 @@ class UpdateManager(Hook): SERVER_URL = "http://updatemanager.pyload.org" VERSION = re.compile(r'__version__.*=.*("|\')([\d.]+)') - MIN_INTERVAL = 3 * 60 * 60 #: 3h minimum check interval (value is in seconds) + MIN_CHECK_INTERVAL = 3 * 60 * 60 #: 3 hours def pluginConfigChanged(self, plugin, name, value): if name == "interval": interval = value * 60 * 60 - if self.MIN_INTERVAL <= interval != self.interval: + if self.MIN_CHECK_INTERVAL <= interval != self.interval: self.core.scheduler.removeJob(self.cb) self.interval = interval self.initPeriodical() @@ -67,8 +67,8 @@ class UpdateManager(Hook): def coreReady(self): - self.pluginConfigChanged(self.__name__, "interval", self.getConfig("interval")) - x = lambda: self.pluginConfigChanged(self.__name__, "reloadplugins", self.getConfig("reloadplugins")) + 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) @@ -78,7 +78,7 @@ class UpdateManager(Hook): def setup(self): self.cb2 = None - self.interval = self.MIN_INTERVAL + self.interval = self.MIN_CHECK_INTERVAL self.updating = False self.info = {'pyload': False, 'version': None, 'plugins': False} self.mtimes = {} #: store modification time for each plugin @@ -122,7 +122,7 @@ class UpdateManager(Hook): def periodical(self): - if not self.info['pyload'] and not (self.getConfig("nodebugupdate") and self.core.debug): + if not self.info['pyload'] and not (self.getConfig('nodebugupdate') and self.core.debug): self.updateThread() @@ -138,9 +138,9 @@ class UpdateManager(Hook): def updateThread(self): self.updating = True - status = self.update(onlyplugin=self.getConfig("mode") == "plugins only") + status = self.update(onlyplugin=self.getConfig('mode') == "plugins only") - if status is 2 and self.getConfig("autorestart"): + if status is 2 and self.getConfig('autorestart'): self.core.api.restart() else: self.updating = False diff --git a/module/plugins/hooks/WindowsPhoneNotify.py b/module/plugins/hooks/WindowsPhoneNotify.py index 010198bf1..a1068ead5 100644 --- a/module/plugins/hooks/WindowsPhoneNotify.py +++ b/module/plugins/hooks/WindowsPhoneNotify.py @@ -41,19 +41,19 @@ class WindowsPhoneNotify(Hook): def newCaptchaTask(self, task): - if not self.getConfig("notifycaptcha"): + if not self.getConfig('notifycaptcha'): return self.notify(_("Captcha"), _("New request waiting user input")) def packageFinished(self, pypack): - if self.getConfig("notifypackage"): + if self.getConfig('notifypackage'): self.notify(_("Package finished"), pypack.name) def allDownloadsProcessed(self): - if not self.getConfig("notifyprocessed"): + if not self.getConfig('notifyprocessed'): return if any(True for pdata in self.core.api.getQueue() if pdata.linksdone < pdata.linkstotal): @@ -69,14 +69,17 @@ class WindowsPhoneNotify(Hook): @Expose - def notify(self, event, msg=""): - id = self.getConfig("id") - url = self.getConfig("url") + def notify(self, + event, + msg="", + key=(self.getConfig('id'), self.getConfig('url'))): + + id, url = key if not id or not url: return - if self.core.isClientConnected() and not self.getConfig("ignoreclient"): + if self.core.isClientConnected() and not self.getConfig('ignoreclient'): return elapsed_time = time.time() - self.last_notify diff --git a/module/plugins/hooks/XFileSharingPro.py b/module/plugins/hooks/XFileSharingPro.py index 495140652..d9552051e 100644 --- a/module/plugins/hooks/XFileSharingPro.py +++ b/module/plugins/hooks/XFileSharingPro.py @@ -8,7 +8,7 @@ from module.plugins.Hook import Hook class XFileSharingPro(Hook): __name__ = "XFileSharingPro" __type__ = "hook" - __version__ = "0.32" + __version__ = "0.33" __config__ = [("activated" , "bool", "Activated" , True ), ("use_hoster_list" , "bool", "Load listed hosters only" , False), @@ -23,15 +23,15 @@ class XFileSharingPro(Hook): # event_list = ["pluginConfigChanged"] - regexp = {'hoster' : (r'https?://(?:www\.)?(?P<DOMAIN>[\w.^_]+(?:\.[a-zA-Z]{2,})(?:\:\d+)?)/(?:embed-)?\w{12}(?:\W|$)', + regexp = {'hoster' : (r'https?://(?:www\.)?(?P<DOMAIN>[\w\-.^_]{3,63}(?:\.[a-zA-Z]{2,})(?:\:\d+)?)/(?:embed-)?\w{12}(?:\W|$)', r'https?://(?:[^/]+\.)?(?P<DOMAIN>%s)/(?:embed-)?\w+'), - 'crypter': (r'https?://(?:www\.)?(?P<DOMAIN>[\w.^_]+(?:\.[a-zA-Z]{2,})(?:\:\d+)?)/(?:user|folder)s?/\w+', + 'crypter': (r'https?://(?:www\.)?(?P<DOMAIN>[\w\-.^_]{3,63}(?:\.[a-zA-Z]{2,})(?:\:\d+)?)/(?:user|folder)s?/\w+', r'https?://(?:[^/]+\.)?(?P<DOMAIN>%s)/(?:user|folder)s?/\w+')} HOSTER_BUILTIN = [#WORKING HOSTERS: - "backin.net", "eyesfile.ca", "file4safe.com", "fileband.com", "filedwon.com", - "fileparadox.in", "filevice.com", "hostingbulk.com", "junkyvideo.com", "linestorage.com", "ravishare.com", - "ryushare.com", "salefiles.com", "sendmyway.com", "sharesix.com", "thefile.me", "verzend.be", "xvidstage.com", + "backin.net", "eyesfile.ca", "file4safe.com", "fileband.com", "filedwon.com", "fileparadox.in", + "filevice.com", "hostingbulk.com", "junkyvideo.com", "linestorage.com", "ravishare.com", "ryushare.com", + "salefiles.com", "sendmyway.com", "sharesix.com", "thefile.me", "verzend.be", "xvidstage.com", #NOT TESTED: "101shared.com", "4upfiles.com", "filemaze.ws", "filenuke.com", "linkzhost.com", "mightyupload.com", "rockdizfile.com", "sharebeast.com", "sharerepo.com", "shareswift.com", "uploadbaz.com", "uploadc.com", @@ -126,7 +126,7 @@ class XFileSharingPro(Hook): # def downloadFailed(self, pyfile): # if pyfile.pluginname == "BasePlugin" \ # and pyfile.hasStatus("failed") \ - # and not self.getConfig("use_hoster_list") \ + # and not self.getConfig('use_hoster_list') \ # and self.unloadHoster("BasePlugin"): # self.logDebug("Unloaded XFileSharingPro from BasePlugin") # pyfile.setStatus("queued") diff --git a/module/plugins/hooks/XMPPInterface.py b/module/plugins/hooks/XMPPInterface.py index b8e9fc1ad..b61428392 100644 --- a/module/plugins/hooks/XMPPInterface.py +++ b/module/plugins/hooks/XMPPInterface.py @@ -33,14 +33,14 @@ class XMPPInterface(IRCInterface, JabberClient): def __init__(self, core, manager): IRCInterface.__init__(self, core, manager) - self.jid = JID(self.getConfig("jid")) - password = self.getConfig("pw") + self.jid = JID(self.getConfig('jid')) + password = self.getConfig('pw') # if bare JID is provided add a resource -- it is required if not self.jid.resource: self.jid = JID(self.jid.node, self.jid.domain, "pyLoad") - if self.getConfig("tls"): + if self.getConfig('tls'): tls_settings = streamtls.TLSSettings(require=True, verify_peer=False) auth = ("sasl:PLAIN", "sasl:DIGEST-MD5") else: @@ -67,7 +67,7 @@ class XMPPInterface(IRCInterface, JabberClient): def packageFinished(self, pypack): try: - if self.getConfig("info_pack"): + if self.getConfig('info_pack'): self.announce(_("Package finished: %s") % pypack.name) except Exception: pass @@ -75,7 +75,7 @@ class XMPPInterface(IRCInterface, JabberClient): def downloadFinished(self, pyfile): try: - if self.getConfig("info_file"): + if self.getConfig('info_file'): self.announce( _("Download finished: %(name)s @ %(plugin)s") % {"name": pyfile.name, "plugin": pyfile.pluginname}) except Exception: @@ -139,7 +139,7 @@ class XMPPInterface(IRCInterface, JabberClient): to_name = to_jid.as_utf8() from_name = from_jid.as_utf8() - names = self.getConfig("owners").split(";") + names = self.getConfig('owners').split(";") if to_name in names or to_jid.node + "@" + to_jid.domain in names: messages = [] @@ -182,7 +182,7 @@ class XMPPInterface(IRCInterface, JabberClient): def announce(self, message): """ send message to all owners""" - for user in self.getConfig("owners").split(";"): + for user in self.getConfig('owners').split(";"): self.logDebug("Send message to", user) to_jid = JID(user) -- cgit v1.2.3 From 331045a39c1d52aef16d51fa4ae1f52ed4f8dc36 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Tue, 10 Mar 2015 22:45:26 +0100 Subject: Tiny code cosmetics --- module/plugins/hooks/RestartFailed.py | 2 +- module/plugins/hooks/SkipRev.py | 6 +++--- module/plugins/hooks/UnSkipOnFail.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/RestartFailed.py b/module/plugins/hooks/RestartFailed.py index 7752b6a61..d0424bd1f 100644 --- a/module/plugins/hooks/RestartFailed.py +++ b/module/plugins/hooks/RestartFailed.py @@ -10,7 +10,7 @@ class RestartFailed(Hook): __config__ = [("interval", "int", "Check interval in minutes", 90)] - __description__ = """Periodically restart all failed downloads in queue""" + __description__ = """Restart all the failed downloads in queue""" __license__ = "GPLv3" __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py index 88ffb0103..dc45a2e6d 100644 --- a/module/plugins/hooks/SkipRev.py +++ b/module/plugins/hooks/SkipRev.py @@ -16,10 +16,10 @@ class SkipRev(Hook): __type__ = "hook" __version__ = "0.29" - __config__ = [("mode" , "Auto;Manual", "Choose rev files to skip for package", "Auto"), - ("revtokeep", "int" , "Number of rev files to keep" , 0 )] + __config__ = [("mode" , "Auto;Manual", "Choose recovery archives to skip" , "Auto"), + ("revtokeep", "int" , "Number of recovery archives to keep for package", 0 )] - __description__ = """Skip files ending with extension rev""" + __description__ = """Skip recovery archives (.rev)""" __license__ = "GPLv3" __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] diff --git a/module/plugins/hooks/UnSkipOnFail.py b/module/plugins/hooks/UnSkipOnFail.py index 7a5ae8e09..a2665663c 100644 --- a/module/plugins/hooks/UnSkipOnFail.py +++ b/module/plugins/hooks/UnSkipOnFail.py @@ -11,7 +11,7 @@ class UnSkipOnFail(Hook): __config__ = [("activated", "bool", "Activated", True)] - __description__ = """Queue skipped duplicates when download fails""" + __description__ = """Restart skipped duplicates when download fails""" __license__ = "GPLv3" __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] -- cgit v1.2.3 From 864d3e2a1d6720f7db9c312a733d0fc0f906afb6 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Fri, 13 Mar 2015 21:04:17 +0100 Subject: [UpdateManager] Fix https://github.com/pyload/pyload/issues/1225 --- module/plugins/hooks/UpdateManager.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index 45d666f45..c435d38b2 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -28,7 +28,7 @@ def exists(path): class UpdateManager(Hook): __name__ = "UpdateManager" __type__ = "hook" - __version__ = "0.44" + __version__ = "0.45" __config__ = [("activated" , "bool" , "Activated" , True ), ("mode" , "pyLoad + plugins;plugins only", "Check updates for" , "pyLoad + plugins"), @@ -205,7 +205,7 @@ class UpdateManager(Hook): # Protect UpdateManager from self-removing try: blacklisted.remove(("hook", "UpdateManager")) - except Exception: + except ValueError: pass for t, n in blacklisted: @@ -314,7 +314,7 @@ class UpdateManager(Hook): try: os.remove(filename) - except IOError, e: + except OSError, e: self.logError(_("Error removing: %s") % filename, e) else: -- cgit v1.2.3 From 0bce7503dda26b26a34549207eeab3b6bc4cb0dc Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Sat, 14 Mar 2015 10:32:16 +0100 Subject: [HotFolder] Missing exception --- module/plugins/hooks/HotFolder.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/HotFolder.py b/module/plugins/hooks/HotFolder.py index a046e55e7..60ddf1621 100644 --- a/module/plugins/hooks/HotFolder.py +++ b/module/plugins/hooks/HotFolder.py @@ -14,7 +14,7 @@ from module.utils import fs_encode, save_join class HotFolder(Hook): __name__ = "HotFolder" __type__ = "hook" - __version__ = "0.13" + __version__ = "0.14" __config__ = [("folder" , "str" , "Folder to observe" , "container"), ("watch_file", "bool", "Observe link file" , False ), @@ -66,5 +66,5 @@ class HotFolder(Hook): self.logInfo(_("Added %s from HotFolder") % f) self.core.api.addPackage(f, [newpath], 1) - except IOError, e: + except (IOError, OSError), e: self.logError(e) -- cgit v1.2.3 From e65d19ee3a1e435bf2896ed829e5581eeef92dd2 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Sat, 14 Mar 2015 11:07:54 +0100 Subject: Import cleanup for datetime and time modules --- module/plugins/hooks/Captcha9Kw.py | 10 +++++----- module/plugins/hooks/CaptchaBrotherhood.py | 4 ++-- module/plugins/hooks/DeathByCaptcha.py | 4 ++-- module/plugins/hooks/DownloadScheduler.py | 5 ++--- module/plugins/hooks/IRCInterface.py | 3 +-- module/plugins/hooks/MultiHome.py | 4 ++-- 6 files changed, 14 insertions(+), 16 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/Captcha9Kw.py b/module/plugins/hooks/Captcha9Kw.py index 6d42416ff..825db510b 100644 --- a/module/plugins/hooks/Captcha9Kw.py +++ b/module/plugins/hooks/Captcha9Kw.py @@ -3,9 +3,9 @@ from __future__ import with_statement import re +import time from base64 import b64encode -from time import sleep from module.network.HTTPRequest import BadHeader from module.network.RequestFactory import getURL @@ -134,7 +134,7 @@ class Captcha9Kw(Hook): try: res = getURL(self.API_URL, post=post_data) except BadHeader, e: - sleep(3) + time.sleep(3) else: if res and res.isdigit(): break @@ -156,7 +156,7 @@ class Captcha9Kw(Hook): 'action': "usercaptchacorrectdata"}) if not result or result == "NO DATA": - sleep(5) + time.sleep(5) else: break else: @@ -193,7 +193,7 @@ class Captcha9Kw(Hook): if queue < re.search(r'queue=(\d+)', servercheck).group(1): break - sleep(10) + time.sleep(10) else: self.fail(_("Too many captchas in queue")) @@ -244,7 +244,7 @@ class Captcha9Kw(Hook): if res == "OK": break - sleep(5) + time.sleep(5) else: self.logDebug("Could not send %s request: %s" % (type, res)) diff --git a/module/plugins/hooks/CaptchaBrotherhood.py b/module/plugins/hooks/CaptchaBrotherhood.py index 5350b4f7d..161f2805b 100644 --- a/module/plugins/hooks/CaptchaBrotherhood.py +++ b/module/plugins/hooks/CaptchaBrotherhood.py @@ -4,13 +4,13 @@ from __future__ import with_statement import StringIO import pycurl +import time try: from PIL import Image except ImportError: import Image -from time import sleep from urllib import urlencode from module.network.RequestFactory import getURL, getRequest @@ -117,7 +117,7 @@ class CaptchaBrotherhood(Hook): ticket = res[3:] for _i in xrange(15): - sleep(5) + time.sleep(5) res = self.api_response("askCaptchaResult", ticket) if res.startswith("OK-answered"): return ticket, res[12:] diff --git a/module/plugins/hooks/DeathByCaptcha.py b/module/plugins/hooks/DeathByCaptcha.py index 4eefb2bff..e408dcab7 100644 --- a/module/plugins/hooks/DeathByCaptcha.py +++ b/module/plugins/hooks/DeathByCaptcha.py @@ -3,10 +3,10 @@ from __future__ import with_statement import re +import time from base64 import b64encode from pycurl import FORM_FILE, HTTPHEADER -from time import sleep from module.common.json_layer import json_loads from module.network.HTTPRequest import BadHeader @@ -152,7 +152,7 @@ class DeathByCaptcha(Hook): ticket = res['captcha'] for _i in xrange(24): - sleep(5) + time.sleep(5) res = self.api_response("captcha/%d" % ticket, False) if res['text'] and res['is_correct']: break diff --git a/module/plugins/hooks/DownloadScheduler.py b/module/plugins/hooks/DownloadScheduler.py index 3b7ae524c..f24faa684 100644 --- a/module/plugins/hooks/DownloadScheduler.py +++ b/module/plugins/hooks/DownloadScheduler.py @@ -1,8 +1,7 @@ # -*- coding: utf-8 -*- import re - -from time import localtime +import time from module.plugins.Hook import Hook @@ -45,7 +44,7 @@ class DownloadScheduler(Hook): self.logError(_("Invalid schedule")) return - t0 = localtime() + t0 = time.localtime() now = (t0.tm_hour, t0.tm_min, t0.tm_sec, "X") schedule = sorted([(int(x[0]), int(x[1]), 0, int(x[2])) for x in schedule] + [now]) diff --git a/module/plugins/hooks/IRCInterface.py b/module/plugins/hooks/IRCInterface.py index 1c90c0e2f..7032c6592 100644 --- a/module/plugins/hooks/IRCInterface.py +++ b/module/plugins/hooks/IRCInterface.py @@ -8,7 +8,6 @@ import time from pycurl import FORM_FILE from select import select from threading import Thread -from time import sleep from traceback import print_exc from module.Api import PackageDoesNotExists, FileDoesNotExists @@ -116,7 +115,7 @@ class IRCInterface(Thread, Hook): def main_loop(self): readbuffer = "" while True: - sleep(1) + time.sleep(1) fdset = select([self.sock], [], [], 0) if self.sock not in fdset[0]: continue diff --git a/module/plugins/hooks/MultiHome.py b/module/plugins/hooks/MultiHome.py index 9093c8459..7ea3378ec 100644 --- a/module/plugins/hooks/MultiHome.py +++ b/module/plugins/hooks/MultiHome.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -from time import time +import time from module.plugins.Hook import Hook @@ -80,7 +80,7 @@ class Interface(object): def useFor(self, pluginName, account): - self.history[(pluginName, account)] = time() + self.history[(pluginName, account)] = time.time() def __repr__(self): -- cgit v1.2.3 From d070742d8e4aebe59797a1ea86b51f9eb25915b4 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Wed, 18 Mar 2015 13:31:58 +0100 Subject: [AndroidPhoneNotify][WindowsPhoneNotify] New notifications --- module/plugins/hooks/AndroidPhoneNotify.py | 25 ++++++++++++++++++++++--- module/plugins/hooks/WindowsPhoneNotify.py | 25 ++++++++++++++++++++++--- 2 files changed, 44 insertions(+), 6 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/AndroidPhoneNotify.py b/module/plugins/hooks/AndroidPhoneNotify.py index 180ad0d78..55ba3e73d 100644 --- a/module/plugins/hooks/AndroidPhoneNotify.py +++ b/module/plugins/hooks/AndroidPhoneNotify.py @@ -9,12 +9,14 @@ from module.plugins.Hook import Hook, Expose class AndroidPhoneNotify(Hook): __name__ = "AndroidPhoneNotify" __type__ = "hook" - __version__ = "0.06" + __version__ = "0.07" __config__ = [("apikey" , "str" , "API key" , "" ), ("notifycaptcha" , "bool", "Notify captcha request" , True ), ("notifypackage" , "bool", "Notify package finished" , True ), - ("notifyprocessed", "bool", "Notify status of processed packages" , True ), + ("notifyprocessed", "bool", "Notify packages processed" , True ), + ("notifyupdate" , "bool", "Notify plugin updates" , True ), + ("notifyexit" , "bool", "Notify pyLoad shutdown" , True ), ("sendtimewait" , "int" , "Timewait in seconds between notifications", 5 ), ("sendpermin" , "int" , "Max notifications per minute" , 12 ), ("ignoreclient" , "bool", "Send notifications if client is connected", False)] @@ -25,7 +27,7 @@ class AndroidPhoneNotify(Hook): ("Walter Purcaro", "vuolter@gmail.com" )] - event_list = ["allDownloadsProcessed"] + event_list = ["allDownloadsProcessed", "plugin_updated"] #@TODO: Remove in 0.4.10 @@ -39,6 +41,23 @@ class AndroidPhoneNotify(Hook): self.notifications = 0 + def plugin_updated(self, type_plugins): + if not self.getConfig('notifyupdate'): + return + + self.notify(_("Plugins updated"), str(type_plugins)) + + + def coreExiting(self): + if not self.getConfig('notifyexit'): + return + + if self.core.do_restart: + self.notify(_("Restarting pyLoad")) + else: + self.notify(_("Exiting pyLoad")) + + def newCaptchaTask(self, task): if not self.getConfig('notifycaptcha'): return diff --git a/module/plugins/hooks/WindowsPhoneNotify.py b/module/plugins/hooks/WindowsPhoneNotify.py index a1068ead5..d8215f9fe 100644 --- a/module/plugins/hooks/WindowsPhoneNotify.py +++ b/module/plugins/hooks/WindowsPhoneNotify.py @@ -9,13 +9,15 @@ from module.plugins.Hook import Hook, Expose class WindowsPhoneNotify(Hook): __name__ = "WindowsPhoneNotify" __type__ = "hook" - __version__ = "0.08" + __version__ = "0.09" __config__ = [("id" , "str" , "Push ID" , "" ), ("url" , "str" , "Push url" , "" ), ("notifycaptcha" , "bool", "Notify captcha request" , True ), ("notifypackage" , "bool", "Notify package finished" , True ), - ("notifyprocessed", "bool", "Notify status of processed packages" , True ), + ("notifyprocessed", "bool", "Notify packages processed" , True ), + ("notifyupdate" , "bool", "Notify plugin updates" , True ), + ("notifyexit" , "bool", "Notify pyLoad shutdown" , True ), ("sendtimewait" , "int" , "Timewait in seconds between notifications", 5 ), ("sendpermin" , "int" , "Max notifications per minute" , 12 ), ("ignoreclient" , "bool", "Send notifications if client is connected", False)] @@ -26,7 +28,7 @@ class WindowsPhoneNotify(Hook): ("Walter Purcaro", "vuolter@gmail.com" )] - event_list = ["allDownloadsProcessed"] + event_list = ["allDownloadsProcessed", "plugin_updated"] #@TODO: Remove in 0.4.10 @@ -40,6 +42,23 @@ class WindowsPhoneNotify(Hook): self.notifications = 0 + def plugin_updated(self, type_plugins): + if not self.getConfig('notifyupdate'): + return + + self.notify(_("Plugins updated"), str(type_plugins)) + + + def coreExiting(self): + if not self.getConfig('notifyexit'): + return + + if self.core.do_restart: + self.notify(_("Restarting pyLoad")) + else: + self.notify(_("Exiting pyLoad")) + + def newCaptchaTask(self, task): if not self.getConfig('notifycaptcha'): return -- cgit v1.2.3 From 80a5bc01bd854ba0ba80dccd7f1ca8f488be9112 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Wed, 18 Mar 2015 13:34:09 +0100 Subject: [UpdateManager] Dispatch Event on plugins update --- module/plugins/hooks/UpdateManager.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index c435d38b2..27d976f17 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -28,7 +28,7 @@ def exists(path): class UpdateManager(Hook): __name__ = "UpdateManager" __type__ = "hook" - __version__ = "0.45" + __version__ = "0.46" __config__ = [("activated" , "bool" , "Activated" , True ), ("mode" , "pyLoad + plugins;plugins only", "Check updates for" , "pyLoad + plugins"), @@ -276,6 +276,8 @@ class UpdateManager(Hook): self.logInfo(_("*** Plugins have been updated, but need a pyLoad restart to be reloaded ***")) self.info['plugins'] = True exitcode = 2 + + self.manager.dispatchEvent("plugin_updated", updated) else: self.logInfo(_("No plugin updates available")) -- cgit v1.2.3 From 2bc144adb6bc2759b635e09687b27bf96074827f Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Wed, 18 Mar 2015 13:39:07 +0100 Subject: Spare code cosmetics --- module/plugins/hooks/AntiVirus.py | 4 ++++ module/plugins/hooks/Checksum.py | 3 +++ module/plugins/hooks/ClickAndLoad.py | 4 ++++ module/plugins/hooks/DeleteFinished.py | 5 +++-- module/plugins/hooks/DownloadScheduler.py | 3 ++- module/plugins/hooks/HotFolder.py | 1 + module/plugins/hooks/JustPremium.py | 9 +++++++++ module/plugins/hooks/MergeFiles.py | 3 +-- module/plugins/hooks/MultiHome.py | 5 ++++- module/plugins/hooks/RestartFailed.py | 1 + module/plugins/hooks/SkipRev.py | 4 ++++ module/plugins/hooks/UnSkipOnFail.py | 3 +++ module/plugins/hooks/XFileSharingPro.py | 20 ++++++++++++-------- 13 files changed, 51 insertions(+), 14 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/AntiVirus.py b/module/plugins/hooks/AntiVirus.py index b8a659f99..ffed86836 100644 --- a/module/plugins/hooks/AntiVirus.py +++ b/module/plugins/hooks/AntiVirus.py @@ -30,6 +30,10 @@ class AntiVirus(Hook): pass + def setup(self): + self.info = {} #@TODO: Remove in 0.4.10 + + @Expose @threaded def scan(self, pyfile, thread): diff --git a/module/plugins/hooks/Checksum.py b/module/plugins/hooks/Checksum.py index 9474f6968..42a4ca236 100644 --- a/module/plugins/hooks/Checksum.py +++ b/module/plugins/hooks/Checksum.py @@ -75,9 +75,12 @@ class Checksum(Hook): def setup(self): + self.info = {} #@TODO: Remove in 0.4.10 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"] diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 731c8bd7e..812f969f9 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -41,6 +41,10 @@ class ClickAndLoad(Hook): pass + def setup(self): + self.info = {} #@TODO: Remove in 0.4.10 + + def coreReady(self): if not self.config['webinterface']['activated']: return diff --git a/module/plugins/hooks/DeleteFinished.py b/module/plugins/hooks/DeleteFinished.py index 5d2b78d50..e2ad12adb 100644 --- a/module/plugins/hooks/DeleteFinished.py +++ b/module/plugins/hooks/DeleteFinished.py @@ -44,7 +44,7 @@ class DeleteFinished(Hook): def coreReady(self): - self.info = {'sleep': True} + self.info['sleep'] = True interval = self.getConfig('interval') self.pluginConfigChanged(self.__name__, 'interval', interval) self.addEvent('packageFinished', self.wakeup) @@ -75,5 +75,6 @@ class DeleteFinished(Hook): def setup(self): - self.m = self.manager + self.info = {} #@TODO: Remove in 0.4.10 + self.m = self.manager self.removeEvent = self.m.removeEvent diff --git a/module/plugins/hooks/DownloadScheduler.py b/module/plugins/hooks/DownloadScheduler.py index f24faa684..5f9388b57 100644 --- a/module/plugins/hooks/DownloadScheduler.py +++ b/module/plugins/hooks/DownloadScheduler.py @@ -27,7 +27,8 @@ class DownloadScheduler(Hook): def setup(self): - self.cb = None # callback to scheduler job; will be by removed hookmanager when hook unloaded + self.info = {} #@TODO: Remove in 0.4.10 + self.cb = None # callback to scheduler job; will be by removed hookmanager when hook unloaded def coreReady(self): diff --git a/module/plugins/hooks/HotFolder.py b/module/plugins/hooks/HotFolder.py index 60ddf1621..f771cf232 100644 --- a/module/plugins/hooks/HotFolder.py +++ b/module/plugins/hooks/HotFolder.py @@ -27,6 +27,7 @@ class HotFolder(Hook): def setup(self): + self.info = {} #@TODO: Remove in 0.4.10 self.interval = 30 diff --git a/module/plugins/hooks/JustPremium.py b/module/plugins/hooks/JustPremium.py index 3064743e2..b82af3e78 100644 --- a/module/plugins/hooks/JustPremium.py +++ b/module/plugins/hooks/JustPremium.py @@ -23,6 +23,15 @@ class JustPremium(Hook): event_list = ["linksAdded"] + #@TODO: Remove in 0.4.10 + def initPeriodical(self): + pass + + + def setup(self): + self.info = {} #@TODO: Remove in 0.4.10 + + def linksAdded(self, links, pid): hosterdict = self.core.pluginManager.hosterPlugins linkdict = self.core.api.checkURLs(links) diff --git a/module/plugins/hooks/MergeFiles.py b/module/plugins/hooks/MergeFiles.py index 9f1348485..74bcbe3c1 100644 --- a/module/plugins/hooks/MergeFiles.py +++ b/module/plugins/hooks/MergeFiles.py @@ -32,8 +32,7 @@ class MergeFiles(Hook): def setup(self): - # nothing to do - pass + self.info = {} #@TODO: Remove in 0.4.10 @threaded diff --git a/module/plugins/hooks/MultiHome.py b/module/plugins/hooks/MultiHome.py index 7ea3378ec..94c671340 100644 --- a/module/plugins/hooks/MultiHome.py +++ b/module/plugins/hooks/MultiHome.py @@ -23,9 +23,12 @@ class MultiHome(Hook): def setup(self): - self.register = {} + self.info = {} #@TODO: Remove in 0.4.10 + self.register = {} self.interfaces = [] + self.parseInterfaces(self.getConfig('interfaces').split(";")) + if not self.interfaces: self.parseInterfaces([self.config['download']['interface']]) self.setConfig("interfaces", self.toConfig()) diff --git a/module/plugins/hooks/RestartFailed.py b/module/plugins/hooks/RestartFailed.py index d0424bd1f..6eef90ffe 100644 --- a/module/plugins/hooks/RestartFailed.py +++ b/module/plugins/hooks/RestartFailed.py @@ -37,6 +37,7 @@ class RestartFailed(Hook): def setup(self): + self.info = {} #@TODO: Remove in 0.4.10 self.interval = self.MIN_CHECK_INTERVAL diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py index dc45a2e6d..9109d4f80 100644 --- a/module/plugins/hooks/SkipRev.py +++ b/module/plugins/hooks/SkipRev.py @@ -29,6 +29,10 @@ class SkipRev(Hook): pass + def setup(self): + self.info = {} #@TODO: Remove in 0.4.10 + + @staticmethod def _setup(self): self.pyfile.plugin._setup() diff --git a/module/plugins/hooks/UnSkipOnFail.py b/module/plugins/hooks/UnSkipOnFail.py index a2665663c..f1f2288fe 100644 --- a/module/plugins/hooks/UnSkipOnFail.py +++ b/module/plugins/hooks/UnSkipOnFail.py @@ -20,6 +20,9 @@ class UnSkipOnFail(Hook): def initPeriodical(self): pass + def setup(self): + self.info = {} #@TODO: Remove in 0.4.10 + def downloadFailed(self, pyfile): #: Check if pyfile is still "failed", diff --git a/module/plugins/hooks/XFileSharingPro.py b/module/plugins/hooks/XFileSharingPro.py index d9552051e..69a49fba0 100644 --- a/module/plugins/hooks/XFileSharingPro.py +++ b/module/plugins/hooks/XFileSharingPro.py @@ -8,7 +8,7 @@ from module.plugins.Hook import Hook class XFileSharingPro(Hook): __name__ = "XFileSharingPro" __type__ = "hook" - __version__ = "0.33" + __version__ = "0.34" __config__ = [("activated" , "bool", "Activated" , True ), ("use_hoster_list" , "bool", "Load listed hosters only" , False), @@ -22,11 +22,11 @@ class XFileSharingPro(Hook): __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - # event_list = ["pluginConfigChanged"] - regexp = {'hoster' : (r'https?://(?:www\.)?(?P<DOMAIN>[\w\-.^_]{3,63}(?:\.[a-zA-Z]{2,})(?:\:\d+)?)/(?:embed-)?\w{12}(?:\W|$)', - r'https?://(?:[^/]+\.)?(?P<DOMAIN>%s)/(?:embed-)?\w+'), - 'crypter': (r'https?://(?:www\.)?(?P<DOMAIN>[\w\-.^_]{3,63}(?:\.[a-zA-Z]{2,})(?:\:\d+)?)/(?:user|folder)s?/\w+', - r'https?://(?:[^/]+\.)?(?P<DOMAIN>%s)/(?:user|folder)s?/\w+')} + event_list = ["pluginConfigChanged"] + regexp = {'hoster' : (r'https?://(?:www\.)?(?P<DOMAIN>[\w\-.^_]{3,63}(?:\.[a-zA-Z]{2,})(?:\:\d+)?)/(?:embed-)?\w{12}(?:\W|$)', + r'https?://(?:[^/]+\.)?(?P<DOMAIN>%s)/(?:embed-)?\w+'), + 'crypter': (r'https?://(?:www\.)?(?P<DOMAIN>[\w\-.^_]{3,63}(?:\.[a-zA-Z]{2,})(?:\:\d+)?)/(?:user|folder)s?/\w+', + r'https?://(?:[^/]+\.)?(?P<DOMAIN>%s)/(?:user|folder)s?/\w+')} HOSTER_BUILTIN = [#WORKING HOSTERS: "backin.net", "eyesfile.ca", "file4safe.com", "fileband.com", "filedwon.com", "fileparadox.in", @@ -41,8 +41,8 @@ class XFileSharingPro(Hook): CRYPTER_BUILTIN = ["junocloud.me", "rapidfileshare.net"] - # def pluginConfigChanged(self.__name__, plugin, name, value): - # self.loadPattern() + def pluginConfigChanged(self.__name__, plugin, name, value): + self.loadPattern() #@TODO: Remove in 0.4.10 @@ -50,6 +50,10 @@ class XFileSharingPro(Hook): pass + def setup(self): + self.info = {} #@TODO: Remove in 0.4.10 + + def coreReady(self): self.loadPattern() -- cgit v1.2.3 From a54c4268e402a3a1509c33d0b2de6f4336583416 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Wed, 18 Mar 2015 15:39:11 +0100 Subject: [ExternalScripts] Fix https://github.com/pyload/pyload/issues/1233 --- module/plugins/hooks/ExternalScripts.py | 132 +++++++++++++++++++++----------- 1 file changed, 86 insertions(+), 46 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index d17e4740c..435ab618c 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -10,7 +10,7 @@ from module.utils import fs_encode, save_join class ExternalScripts(Hook): __name__ = "ExternalScripts" __type__ = "hook" - __version__ = "0.32" + __version__ = "0.35" __config__ = [("activated", "bool", "Activated" , True ), ("waitend" , "bool", "Wait script ending", False)] @@ -23,8 +23,10 @@ class ExternalScripts(Hook): ("Walter Purcaro", "vuolter@gmail.com")] - event_list = ["archive_extracted", "package_extracted", "all_archives_extracted", "all_archives_processed", - "allDownloadsFinished", "allDownloadsProcessed"] + event_list = ["archive_extract_failed", "archive_extracted" , + "package_extract_failed", "package_extracted" , + "all_archives_extracted", "all_archives_processed", + "allDownloadsFinished" , "allDownloadsProcessed" ] #@TODO: Remove in 0.4.10 @@ -33,14 +35,15 @@ class ExternalScripts(Hook): def setup(self): + self.info = {} #@TODO: Remove in 0.4.10 self.scripts = {} - folders = ["download_preparing", "download_finished", "all_downloads_finished", "all_downloads_processed", - "before_reconnect", "after_reconnect", - "package_finished", "package_extracted", - "archive_extracted", "all_archives_extracted", "all_archives_processed", - # deprecated folders - "unrar_finished", "all_dls_finished", "all_dls_processed"] + folders = ["before_reconnect", "after_reconnect", + "download_preparing", "download_failed", "download_finished", + "archive_extract_failed", "archive_extracted", + "package_finished", "package_extract_failed", "package_extracted", + "all_downloads_processed", "all_downloads_finished", #@TODO: Invert `all_downloads_processed`, `all_downloads_finished` order in 0.4.10 + "all_archives_extracted", "all_archives_processed"] for folder in folders: self.scripts[folder] = [] @@ -49,7 +52,7 @@ class ExternalScripts(Hook): for script_type, names in self.scripts.iteritems(): if names: - self.logInfo(_("Installed scripts for ") + script_type, ", ".join(map(os.path.basename, names))) + self.logInfo(_("Installed scripts for: ") + script_type, ", ".join(map(os.path.basename, names))) def initPluginType(self, name, dir): @@ -57,12 +60,12 @@ class ExternalScripts(Hook): try: os.makedirs(dir) - except IOError, e: + except OSError, e: self.logDebug(e) return for filename in os.listdir(dir): - file = os.path.join(dir, filename) + file = save_join(dir, filename) if not os.path.isfile(file): continue @@ -78,76 +81,113 @@ class ExternalScripts(Hook): def callScript(self, script, *args): try: - cmd = [script] + [(str(x) if not isinstance(x, basestring) else x).encode('utf-8') for x in args] + cmd_args = [fs_encode(str(x) if not isinstance(x, basestring) else x) for x in args] + cmd = [script] + cmd_args - self.logDebug("Executing", os.path.abspath(script), " ".join(cmd)) + self.logDebug("Executing: %s" % os.path.abspath(script), "Args: " + ' '.join(cmd_args)) p = subprocess.Popen(cmd, bufsize=-1) #@NOTE: output goes to pyload if self.getConfig('waitend'): p.communicate() except Exception, e: - self.logError(_("Error in %(script)s: %(error)s") % {"script": os.path.basename(script), "error": e}) + try: + self.logError(_("Runtime error: %s") % os.path.abspath(script), e) + except Exception: + self.logError(_("Runtime error: %s") % os.path.abspath(script), _("Unknown error")) + + def beforeReconnecting(self, ip): + for script in self.scripts['before_reconnect']: + self.callScript(script, ip) + + + def afterReconnecting(self, ip): + for script in self.scripts['after_reconnect']: + self.callScript(script, ip) def downloadPreparing(self, pyfile): for script in self.scripts['download_preparing']: - self.callScript(script, pyfile.pluginname, pyfile.url, pyfile.id) + self.callScript(script, pyfile.id, pyfile.name, pyfile.pluginname, pyfile.url, None) + + + def downloadFailed(self, pyfile): + if self.config['general']['folder_per_package']: + download_folder = save_join(self.config['general']['download_folder'], pyfile.package().folder) + else: + download_folder = self.config['general']['download_folder'] + + for script in self.scripts['download_failed']: + file = save_join(download_folder, pyfile.name) + self.callScript(script, pyfile.id, pyfile.name, pyfile.pluginname, pyfile.url, file) def downloadFinished(self, pyfile): - download_folder = self.config['general']['download_folder'] + if self.config['general']['folder_per_package']: + download_folder = save_join(self.config['general']['download_folder'], pyfile.package().folder) + else: + download_folder = self.config['general']['download_folder'] + for script in self.scripts['download_finished']: - file = save_join(download_folder, pyfile.package().folder, pyfile.name) - self.callScript(script, pyfile.pluginname, pyfile.url, pyfile.name, file, pyfile.id) + file = save_join(download_folder, pyfile.name) + self.callScript(script, pyfile.id, pyfile.name, pyfile.pluginname, pyfile.url, file) - def packageFinished(self, pypack): - download_folder = self.config['general']['download_folder'] - for script in self.scripts['package_finished']: - folder = save_join(download_folder, pypack.folder) - self.callScript(script, pypack.name, folder, pypack.password, pypack.id) + def archive_extract_failed(self, pyfile, archive): + for script in self.scripts['archive_extract_failed']: + self.callScript(script, pyfile.id, pyfile.name, archive.out, archive.filename, archive.files) - def beforeReconnecting(self, ip): - for script in self.scripts['before_reconnect']: - self.callScript(script, ip) + def archive_extracted(self, pyfile, archive): + for script in self.scripts['archive_extracted']: + self.callScript(script, pyfile.id, pyfile.name, archive.out, archive.filename, archive.files) - def afterReconnecting(self, ip): - for script in self.scripts['after_reconnect']: - self.callScript(script, ip) + def packageFinished(self, pypack): + if self.config['general']['folder_per_package']: + download_folder = save_join(self.config['general']['download_folder'], pypack.folder) + else: + download_folder = self.config['general']['download_folder'] + for script in self.scripts['package_finished']: + self.callScript(script, pypack.id, pypack.name, download_folder) - def archive_extracted(self, pyfile, folder, filename, files): - for script in self.scripts['archive_extracted']: - self.callScript(script, folder, filename, files) - for script in self.scripts['unrar_finished']: #: deprecated - self.callScript(script, folder, filename) + + def package_extract_failed(self, pypack): + if self.config['general']['folder_per_package']: + download_folder = save_join(self.config['general']['download_folder'], pypack.folder) + else: + download_folder = self.config['general']['download_folder'] + + for script in self.scripts['package_extract_failed']: + self.callScript(script, pypack.id, pypack.name, download_folder) def package_extracted(self, pypack): - download_folder = self.config['general']['download_folder'] + if self.config['general']['folder_per_package']: + download_folder = save_join(self.config['general']['download_folder'], pypack.folder) + else: + download_folder = self.config['general']['download_folder'] + for script in self.scripts['package_extracted']: - folder = save_join(download_folder, pypack.folder) - self.callScript(script, pypack.name, folder, pypack.password, pypack.id) + self.callScript(script, pypack.id, pypack.name, download_folder) - def all_archives_extracted(self): - for script in self.scripts['all_archives_extracted']: + def allDownloadsFinished(self): + for script in self.scripts['all_downloads_finished']: self.callScript(script) - def all_archives_processed(self): - for script in self.scripts['all_archives_processed']: + def allDownloadsProcessed(self): + for script in self.scripts['all_downloads_processed']: self.callScript(script) - def allDownloadsFinished(self): - for script in self.scripts['all_downloads_finished'] + self.scripts['all_dls_finished']: + def all_archives_extracted(self): + for script in self.scripts['all_archives_extracted']: self.callScript(script) - def allDownloadsProcessed(self): - for script in self.scripts['all_downloads_processed'] + self.scripts['all_dls_processed']: + def all_archives_processed(self): + for script in self.scripts['all_archives_processed']: self.callScript(script) -- cgit v1.2.3 From 93bfee64320aa39c06254975bc79f4796e6a7973 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Wed, 18 Mar 2015 15:44:55 +0100 Subject: [XFileSharingPro] Fix typo --- module/plugins/hooks/XFileSharingPro.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/XFileSharingPro.py b/module/plugins/hooks/XFileSharingPro.py index 69a49fba0..54b1e27e6 100644 --- a/module/plugins/hooks/XFileSharingPro.py +++ b/module/plugins/hooks/XFileSharingPro.py @@ -8,7 +8,7 @@ from module.plugins.Hook import Hook class XFileSharingPro(Hook): __name__ = "XFileSharingPro" __type__ = "hook" - __version__ = "0.34" + __version__ = "0.35" __config__ = [("activated" , "bool", "Activated" , True ), ("use_hoster_list" , "bool", "Load listed hosters only" , False), @@ -41,7 +41,7 @@ class XFileSharingPro(Hook): CRYPTER_BUILTIN = ["junocloud.me", "rapidfileshare.net"] - def pluginConfigChanged(self.__name__, plugin, name, value): + def pluginConfigChanged(self, plugin, name, value): self.loadPattern() -- cgit v1.2.3 From 753b3c9daee9926c84d4053864af2079fcfc8557 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Wed, 18 Mar 2015 16:01:23 +0100 Subject: Spare code cosmetics (2) --- module/plugins/hooks/DeleteFinished.py | 8 ++++---- module/plugins/hooks/RestartFailed.py | 18 +++++++++--------- module/plugins/hooks/UpdateManager.py | 30 +++++++++++++++--------------- module/plugins/hooks/XFileSharingPro.py | 8 ++++---- 4 files changed, 32 insertions(+), 32 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/DeleteFinished.py b/module/plugins/hooks/DeleteFinished.py index e2ad12adb..3dff9c7bd 100644 --- a/module/plugins/hooks/DeleteFinished.py +++ b/module/plugins/hooks/DeleteFinished.py @@ -33,10 +33,10 @@ class DeleteFinished(Hook): self.addEvent('packageFinished', self.wakeup) - def pluginConfigChanged(self, plugin, name, value): - if name == "interval" and value != self.interval: - self.interval = value * 3600 - self.initPeriodical() + # def pluginConfigChanged(self, plugin, name, value): + # if name == "interval" and value != self.interval: + # self.interval = value * 3600 + # self.initPeriodical() def unload(self): diff --git a/module/plugins/hooks/RestartFailed.py b/module/plugins/hooks/RestartFailed.py index 6eef90ffe..c861e9c41 100644 --- a/module/plugins/hooks/RestartFailed.py +++ b/module/plugins/hooks/RestartFailed.py @@ -20,15 +20,15 @@ class RestartFailed(Hook): MIN_CHECK_INTERVAL = 15 * 60 #: 15 minutes - def pluginConfigChanged(self, plugin, name, value): - if name == "interval": - interval = value * 60 - if self.MIN_CHECK_INTERVAL <= interval != self.interval: - self.core.scheduler.removeJob(self.cb) - self.interval = interval - self.initPeriodical() - else: - self.logDebug("Invalid interval value, kept current") + # def pluginConfigChanged(self, plugin, name, value): + # if name == "interval": + # interval = value * 60 + # if self.MIN_CHECK_INTERVAL <= interval != self.interval: + # self.core.scheduler.removeJob(self.cb) + # self.interval = interval + # self.initPeriodical() + # else: + # self.logDebug("Invalid interval value, kept current") def periodical(self): diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index 27d976f17..7270bc34f 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -49,21 +49,21 @@ class UpdateManager(Hook): MIN_CHECK_INTERVAL = 3 * 60 * 60 #: 3 hours - def pluginConfigChanged(self, plugin, name, value): - if name == "interval": - interval = value * 60 * 60 - if self.MIN_CHECK_INTERVAL <= interval != self.interval: - self.core.scheduler.removeJob(self.cb) - self.interval = interval - self.initPeriodical() - else: - self.logDebug("Invalid interval value, kept current") - - elif name == "reloadplugins": - if self.cb2: - self.core.scheduler.removeJob(self.cb2) - if value is True and self.core.debug: - self.periodical2() + # def pluginConfigChanged(self, plugin, name, value): + # if name == "interval": + # interval = value * 60 * 60 + # if self.MIN_CHECK_INTERVAL <= interval != self.interval: + # self.core.scheduler.removeJob(self.cb) + # self.interval = interval + # self.initPeriodical() + # else: + # self.logDebug("Invalid interval value, kept current") + + # elif name == "reloadplugins": + # if self.cb2: + # self.core.scheduler.removeJob(self.cb2) + # if value is True and self.core.debug: + # self.periodical2() def coreReady(self): diff --git a/module/plugins/hooks/XFileSharingPro.py b/module/plugins/hooks/XFileSharingPro.py index 54b1e27e6..b7b5eed73 100644 --- a/module/plugins/hooks/XFileSharingPro.py +++ b/module/plugins/hooks/XFileSharingPro.py @@ -8,7 +8,7 @@ from module.plugins.Hook import Hook class XFileSharingPro(Hook): __name__ = "XFileSharingPro" __type__ = "hook" - __version__ = "0.35" + __version__ = "0.36" __config__ = [("activated" , "bool", "Activated" , True ), ("use_hoster_list" , "bool", "Load listed hosters only" , False), @@ -22,7 +22,7 @@ class XFileSharingPro(Hook): __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - event_list = ["pluginConfigChanged"] + # event_list = ["pluginConfigChanged"] regexp = {'hoster' : (r'https?://(?:www\.)?(?P<DOMAIN>[\w\-.^_]{3,63}(?:\.[a-zA-Z]{2,})(?:\:\d+)?)/(?:embed-)?\w{12}(?:\W|$)', r'https?://(?:[^/]+\.)?(?P<DOMAIN>%s)/(?:embed-)?\w+'), 'crypter': (r'https?://(?:www\.)?(?P<DOMAIN>[\w\-.^_]{3,63}(?:\.[a-zA-Z]{2,})(?:\:\d+)?)/(?:user|folder)s?/\w+', @@ -41,8 +41,8 @@ class XFileSharingPro(Hook): CRYPTER_BUILTIN = ["junocloud.me", "rapidfileshare.net"] - def pluginConfigChanged(self, plugin, name, value): - self.loadPattern() + # def pluginConfigChanged(self, plugin, name, value): + # self.loadPattern() #@TODO: Remove in 0.4.10 -- cgit v1.2.3 From 990c1d9dd74b11b7110b2c66afb48704b5d5901f Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Wed, 18 Mar 2015 16:13:45 +0100 Subject: [ClickAndLoad] Fix freeze after a pyLoad restart --- module/plugins/hooks/ClickAndLoad.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 812f969f9..257f58584 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -24,7 +24,7 @@ def forward(source, destination): class ClickAndLoad(Hook): __name__ = "ClickAndLoad" __type__ = "hook" - __version__ = "0.40" + __version__ = "0.41" __config__ = [("activated", "bool", "Activated" , True), ("port" , "int" , "Port" , 9666), @@ -58,6 +58,8 @@ class ClickAndLoad(Hook): @threaded def proxy(self, ip, webport, cnlport): + time.sleep(10) #@TODO: Implement addon delay on start in 0.4.10 + self.logInfo(_("Proxy listening on %s:%s") % (ip or "0.0.0.0", cnlport)) self._server(ip, webport, cnlport) -- cgit v1.2.3 From 6db62380b80a144aca18335d50c724e9915d8038 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Wed, 18 Mar 2015 22:20:17 +0100 Subject: Hooks cleanup --- module/plugins/hooks/AlldebridCom.py | 2 -- module/plugins/hooks/DebridItaliaCom.py | 2 -- module/plugins/hooks/EasybytezCom.py | 2 -- module/plugins/hooks/FastixRu.py | 2 -- module/plugins/hooks/FreeWayMe.py | 2 -- module/plugins/hooks/LinksnappyCom.py | 2 -- module/plugins/hooks/MegaDebridEu.py | 2 -- module/plugins/hooks/MultishareCz.py | 2 -- module/plugins/hooks/MyfastfileCom.py | 2 -- module/plugins/hooks/NoPremiumPl.py | 2 -- module/plugins/hooks/OverLoadMe.py | 2 -- module/plugins/hooks/PremiumTo.py | 2 -- module/plugins/hooks/PremiumizeMe.py | 2 -- module/plugins/hooks/RPNetBiz.py | 2 -- module/plugins/hooks/RapideoPl.py | 2 -- module/plugins/hooks/RealdebridCom.py | 2 -- module/plugins/hooks/RehostTo.py | 2 -- module/plugins/hooks/SimplyPremiumCom.py | 2 -- module/plugins/hooks/SimplydebridCom.py | 2 -- module/plugins/hooks/SmoozedCom.py | 2 -- module/plugins/hooks/UnrestrictLi.py | 2 -- module/plugins/hooks/ZeveraCom.py | 2 -- 22 files changed, 44 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/AlldebridCom.py b/module/plugins/hooks/AlldebridCom.py index 517adcb68..34f44c91d 100644 --- a/module/plugins/hooks/AlldebridCom.py +++ b/module/plugins/hooks/AlldebridCom.py @@ -11,8 +11,6 @@ class AlldebridCom(MultiHook): __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("retry" , "int" , "Number of retries before revert" , 10 ), - ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), ("reload" , "bool" , "Reload plugin list" , True ), ("reloadinterval", "int" , "Reload interval in hours" , 12 ), ("ssl" , "bool" , "Use HTTPS" , True )] diff --git a/module/plugins/hooks/DebridItaliaCom.py b/module/plugins/hooks/DebridItaliaCom.py index 399f6462f..a970ae195 100644 --- a/module/plugins/hooks/DebridItaliaCom.py +++ b/module/plugins/hooks/DebridItaliaCom.py @@ -13,8 +13,6 @@ class DebridItaliaCom(MultiHook): __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("retry" , "int" , "Number of retries before revert" , 10 ), - ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), ("reload" , "bool" , "Reload plugin list" , True ), ("reloadinterval", "int" , "Reload interval in hours" , 12 )] diff --git a/module/plugins/hooks/EasybytezCom.py b/module/plugins/hooks/EasybytezCom.py index 85c616054..04da21ee2 100644 --- a/module/plugins/hooks/EasybytezCom.py +++ b/module/plugins/hooks/EasybytezCom.py @@ -13,8 +13,6 @@ class EasybytezCom(MultiHook): __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("retry" , "int" , "Number of retries before revert" , 10 ), - ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), ("reload" , "bool" , "Reload plugin list" , True ), ("reloadinterval", "int" , "Reload interval in hours" , 12 )] diff --git a/module/plugins/hooks/FastixRu.py b/module/plugins/hooks/FastixRu.py index 6373da8d9..9e74587ac 100644 --- a/module/plugins/hooks/FastixRu.py +++ b/module/plugins/hooks/FastixRu.py @@ -12,8 +12,6 @@ class FastixRu(MultiHook): __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("retry" , "int" , "Number of retries before revert" , 10 ), - ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), ("reload" , "bool" , "Reload plugin list" , True ), ("reloadinterval", "int" , "Reload interval in hours" , 12 )] diff --git a/module/plugins/hooks/FreeWayMe.py b/module/plugins/hooks/FreeWayMe.py index 4e79783bb..31ef8201f 100644 --- a/module/plugins/hooks/FreeWayMe.py +++ b/module/plugins/hooks/FreeWayMe.py @@ -11,8 +11,6 @@ class FreeWayMe(MultiHook): __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("retry" , "int" , "Number of retries before revert" , 10 ), - ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), ("reload" , "bool" , "Reload plugin list" , True ), ("reloadinterval", "int" , "Reload interval in hours" , 12 )] diff --git a/module/plugins/hooks/LinksnappyCom.py b/module/plugins/hooks/LinksnappyCom.py index 5eb0c7f6d..a5b77b93f 100644 --- a/module/plugins/hooks/LinksnappyCom.py +++ b/module/plugins/hooks/LinksnappyCom.py @@ -12,8 +12,6 @@ class LinksnappyCom(MultiHook): __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("retry" , "int" , "Number of retries before revert" , 10 ), - ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), ("reload" , "bool" , "Reload plugin list" , True ), ("reloadinterval", "int" , "Reload interval in hours" , 12 )] diff --git a/module/plugins/hooks/MegaDebridEu.py b/module/plugins/hooks/MegaDebridEu.py index f67fa7ac0..b32656019 100644 --- a/module/plugins/hooks/MegaDebridEu.py +++ b/module/plugins/hooks/MegaDebridEu.py @@ -12,8 +12,6 @@ class MegaDebridEu(MultiHook): __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("retry" , "int" , "Number of retries before revert" , 10 ), - ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), ("reload" , "bool" , "Reload plugin list" , True ), ("reloadinterval", "int" , "Reload interval in hours" , 12 )] diff --git a/module/plugins/hooks/MultishareCz.py b/module/plugins/hooks/MultishareCz.py index d02f4f8e3..e696d3fef 100644 --- a/module/plugins/hooks/MultishareCz.py +++ b/module/plugins/hooks/MultishareCz.py @@ -13,8 +13,6 @@ class MultishareCz(MultiHook): __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("retry" , "int" , "Number of retries before revert" , 10 ), - ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), ("reload" , "bool" , "Reload plugin list" , True ), ("reloadinterval", "int" , "Reload interval in hours" , 12 )] diff --git a/module/plugins/hooks/MyfastfileCom.py b/module/plugins/hooks/MyfastfileCom.py index 86408cb6d..1e7a6421d 100644 --- a/module/plugins/hooks/MyfastfileCom.py +++ b/module/plugins/hooks/MyfastfileCom.py @@ -12,8 +12,6 @@ class MyfastfileCom(MultiHook): __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("retry" , "int" , "Number of retries before revert" , 10 ), - ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), ("reload" , "bool" , "Reload plugin list" , True ), ("reloadinterval", "int" , "Reload interval in hours" , 12 )] diff --git a/module/plugins/hooks/NoPremiumPl.py b/module/plugins/hooks/NoPremiumPl.py index 1727bec70..77ee83cb1 100644 --- a/module/plugins/hooks/NoPremiumPl.py +++ b/module/plugins/hooks/NoPremiumPl.py @@ -12,8 +12,6 @@ class NoPremiumPl(MultiHook): __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("retry" , "int" , "Number of retries before revert" , 10 ), - ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), ("reload" , "bool" , "Reload plugin list" , True ), ("reloadinterval", "int" , "Reload interval in hours" , 12 )] diff --git a/module/plugins/hooks/OverLoadMe.py b/module/plugins/hooks/OverLoadMe.py index 5e1040da7..7b9a1f414 100644 --- a/module/plugins/hooks/OverLoadMe.py +++ b/module/plugins/hooks/OverLoadMe.py @@ -11,8 +11,6 @@ class OverLoadMe(MultiHook): __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("retry" , "int" , "Number of retries before revert" , 10 ), - ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), ("reload" , "bool" , "Reload plugin list" , True ), ("reloadinterval", "int" , "Reload interval in hours" , 12 ), ("ssl" , "bool" , "Use HTTPS" , True )] diff --git a/module/plugins/hooks/PremiumTo.py b/module/plugins/hooks/PremiumTo.py index 250125016..f5636cb72 100644 --- a/module/plugins/hooks/PremiumTo.py +++ b/module/plugins/hooks/PremiumTo.py @@ -11,8 +11,6 @@ class PremiumTo(MultiHook): __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("retry" , "int" , "Number of retries before revert" , 10 ), - ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), ("reload" , "bool" , "Reload plugin list" , True ), ("reloadinterval", "int" , "Reload interval in hours" , 12 )] diff --git a/module/plugins/hooks/PremiumizeMe.py b/module/plugins/hooks/PremiumizeMe.py index 293fcf339..266c62549 100644 --- a/module/plugins/hooks/PremiumizeMe.py +++ b/module/plugins/hooks/PremiumizeMe.py @@ -12,8 +12,6 @@ class PremiumizeMe(MultiHook): __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("retry" , "int" , "Number of retries before revert" , 10 ), - ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), ("reload" , "bool" , "Reload plugin list" , True ), ("reloadinterval", "int" , "Reload interval in hours" , 12 )] diff --git a/module/plugins/hooks/RPNetBiz.py b/module/plugins/hooks/RPNetBiz.py index 0768bd6cd..a24697265 100644 --- a/module/plugins/hooks/RPNetBiz.py +++ b/module/plugins/hooks/RPNetBiz.py @@ -12,8 +12,6 @@ class RPNetBiz(MultiHook): __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("retry" , "int" , "Number of retries before revert" , 10 ), - ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), ("reload" , "bool" , "Reload plugin list" , True ), ("reloadinterval", "int" , "Reload interval in hours" , 12 )] diff --git a/module/plugins/hooks/RapideoPl.py b/module/plugins/hooks/RapideoPl.py index b605eca17..70d499de5 100644 --- a/module/plugins/hooks/RapideoPl.py +++ b/module/plugins/hooks/RapideoPl.py @@ -12,8 +12,6 @@ class RapideoPl(MultiHook): __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("retry" , "int" , "Number of retries before revert" , 10 ), - ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), ("reload" , "bool" , "Reload plugin list" , True ), ("reloadinterval", "int" , "Reload interval in hours" , 12 )] diff --git a/module/plugins/hooks/RealdebridCom.py b/module/plugins/hooks/RealdebridCom.py index c97bc257c..4260940d0 100644 --- a/module/plugins/hooks/RealdebridCom.py +++ b/module/plugins/hooks/RealdebridCom.py @@ -11,8 +11,6 @@ class RealdebridCom(MultiHook): __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("retry" , "int" , "Number of retries before revert" , 10 ), - ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), ("reload" , "bool" , "Reload plugin list" , True ), ("reloadinterval", "int" , "Reload interval in hours" , 12 ), ("ssl" , "bool" , "Use HTTPS" , True )] diff --git a/module/plugins/hooks/RehostTo.py b/module/plugins/hooks/RehostTo.py index 845601c3f..1e608f87a 100644 --- a/module/plugins/hooks/RehostTo.py +++ b/module/plugins/hooks/RehostTo.py @@ -11,8 +11,6 @@ class RehostTo(MultiHook): __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("retry" , "int" , "Number of retries before revert" , 10 ), - ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), ("reload" , "bool" , "Reload plugin list" , True ), ("reloadinterval", "int" , "Reload interval in hours" , 12 )] diff --git a/module/plugins/hooks/SimplyPremiumCom.py b/module/plugins/hooks/SimplyPremiumCom.py index 843a3aa82..a5173dbfa 100644 --- a/module/plugins/hooks/SimplyPremiumCom.py +++ b/module/plugins/hooks/SimplyPremiumCom.py @@ -12,8 +12,6 @@ class SimplyPremiumCom(MultiHook): __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("retry" , "int" , "Number of retries before revert" , 10 ), - ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), ("reload" , "bool" , "Reload plugin list" , True ), ("reloadinterval", "int" , "Reload interval in hours" , 12 )] diff --git a/module/plugins/hooks/SimplydebridCom.py b/module/plugins/hooks/SimplydebridCom.py index 4d27f5ae4..a37a6eb7f 100644 --- a/module/plugins/hooks/SimplydebridCom.py +++ b/module/plugins/hooks/SimplydebridCom.py @@ -11,8 +11,6 @@ class SimplydebridCom(MultiHook): __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("retry" , "int" , "Number of retries before revert" , 10 ), - ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), ("reload" , "bool" , "Reload plugin list" , True ), ("reloadinterval", "int" , "Reload interval in hours" , 12 )] diff --git a/module/plugins/hooks/SmoozedCom.py b/module/plugins/hooks/SmoozedCom.py index 9ba2daac9..cd9b2fa6e 100644 --- a/module/plugins/hooks/SmoozedCom.py +++ b/module/plugins/hooks/SmoozedCom.py @@ -11,8 +11,6 @@ class SmoozedCom(MultiHook): __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("retry" , "int" , "Number of retries before revert" , 10 ), - ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), ("reload" , "bool" , "Reload plugin list" , True ), ("reloadinterval", "int" , "Reload interval in hours" , 12 )] diff --git a/module/plugins/hooks/UnrestrictLi.py b/module/plugins/hooks/UnrestrictLi.py index cb5abb26e..58f31f2aa 100644 --- a/module/plugins/hooks/UnrestrictLi.py +++ b/module/plugins/hooks/UnrestrictLi.py @@ -12,8 +12,6 @@ class UnrestrictLi(MultiHook): __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("retry" , "int" , "Number of retries before revert" , 10 ), - ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), ("reload" , "bool" , "Reload plugin list" , True ), ("reloadinterval", "int" , "Reload interval in hours" , 12 ), ("history" , "bool" , "Delete History" , False)] diff --git a/module/plugins/hooks/ZeveraCom.py b/module/plugins/hooks/ZeveraCom.py index 33c49d8be..7fcfb18da 100644 --- a/module/plugins/hooks/ZeveraCom.py +++ b/module/plugins/hooks/ZeveraCom.py @@ -11,8 +11,6 @@ class ZeveraCom(MultiHook): __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("retry" , "int" , "Number of retries before revert" , 10 ), - ("retryinterval" , "int" , "Retry interval in minutes" , 1 ), ("reload" , "bool" , "Reload plugin list" , True ), ("reloadinterval", "int" , "Reload interval in hours" , 12 )] -- cgit v1.2.3 From 241d6fcca23656cf9690df455a0b7f9a44b472dd Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Fri, 20 Mar 2015 01:37:20 +0100 Subject: [ExtractArchive] Update dispatchEvent --- module/plugins/hooks/ExternalScripts.py | 1 + module/plugins/hooks/ExtractArchive.py | 132 ++++++++++++++++---------------- 2 files changed, 68 insertions(+), 65 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index 435ab618c..16049ae9b 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -96,6 +96,7 @@ class ExternalScripts(Hook): except Exception: self.logError(_("Runtime error: %s") % os.path.abspath(script), _("Unknown error")) + def beforeReconnecting(self, ip): for script in self.scripts['before_reconnect']: self.callScript(script, ip) diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index edf25b8c7..0c163078c 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -12,8 +12,7 @@ from traceback import print_exc # http://bugs.python.org/issue6122 , http://bugs.python.org/issue1236 , http://bugs.python.org/issue1731717 if sys.version_info < (2, 7) and os.name != "nt": import errno - - from subprocess import Popen + import subprocess def _eintr_retry_call(func, *args): while True: @@ -44,13 +43,13 @@ if sys.version_info < (2, 7) and os.name != "nt": self._handle_exitstatus(sts) return self.returncode - Popen.wait = wait + subprocess.Popen.wait = wait if os.name != "nt": from grp import getgrnam from pwd import getpwnam -from module.plugins.Hook import Hook, threaded, Expose +from module.plugins.Hook import Hook, Expose, threaded from module.plugins.internal.Extractor import ArchiveError, CRCError, PasswordError from module.plugins.internal.SimpleHoster import replace_patterns from module.utils import fs_encode, save_join, uniqify @@ -104,28 +103,27 @@ class ArchiveQueue(object): return self.set(queue) - class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.33" - - __config__ = [("activated" , "bool" , "Activated" , True ), - ("fullpath" , "bool" , "Extract with full paths" , True ), - ("overwrite" , "bool" , "Overwrite files" , False ), - ("keepbroken" , "bool" , "Try to extract broken archives" , False ), - ("repair" , "bool" , "Repair broken archives (rar required)" , False ), - ("test" , "bool" , "Test archive before extracting" , False ), - ("usepasswordfile", "bool" , "Use password file" , True ), - ("passwordfile" , "file" , "Password file" , "archive_password.txt" ), - ("delete" , "bool" , "Delete archive when successfully extracted", False ), - ("subfolder" , "bool" , "Create subfolder for each package" , False ), - ("destination" , "folder", "Extract files to folder" , "" ), - ("extensions" , "str" , "Extract the following extensions" , "7z,bz2,bzip2,gz,gzip,lha,lzh,lzma,rar,tar,taz,tbz,tbz2,tgz,xar,xz,z,zip"), - ("excludefiles" , "str" , "Don't extract the following files" , "*.nfo,*.DS_Store,index.dat,thumb.db" ), - ("recursive" , "bool" , "Extract archives in archives" , True ), - ("waitall" , "bool" , "Wait for all downloads to be finished" , False ), - ("renice" , "int" , "CPU priority" , 0 )] + __version__ = "1.34" + + __config__ = [("activated" , "bool" , "Activated" , True ), + ("fullpath" , "bool" , "Extract with full paths" , True ), + ("overwrite" , "bool" , "Overwrite files" , False ), + ("keepbroken" , "bool" , "Try to extract broken archives" , False ), + ("repair" , "bool" , "Repair broken archives (RAR required)" , False ), + ("test" , "bool" , "Test archive before extracting" , False ), + ("usepasswordfile", "bool" , "Use password file" , True ), + ("passwordfile" , "file" , "Password file" , "archive_password.txt" ), + ("delete" , "bool" , "Delete archive after extraction" , False ), + ("subfolder" , "bool" , "Create subfolder for each package" , False ), + ("destination" , "folder", "Extract files to folder" , "" ), + ("extensions" , "str" , "Extract archives ending with extension", "7z,bz2,bzip2,gz,gzip,lha,lzh,lzma,rar,tar,taz,tbz,tbz2,tgz,xar,xz,z,zip"), + ("excludefiles" , "str" , "Don't extract the following files" , "*.nfo,*.DS_Store,index.dat,thumb.db" ), + ("recursive" , "bool" , "Extract archives in archives" , True ), + ("waitall" , "bool" , "Run after all downloads was processed" , False ), + ("renice" , "int" , "CPU priority" , 0 )] __description__ = """Extract different kind of archives""" __license__ = "GPLv3" @@ -139,6 +137,8 @@ class ExtractArchive(Hook): def setup(self): + self.info = {} #@TODO: Remove in 0.4.10 + self.queue = ArchiveQueue(self, "Queue") self.failed = ArchiveQueue(self, "Failed") @@ -158,7 +158,7 @@ class ExtractArchive(Hook): if klass.isUsable(): self.extractors.append(klass) if klass.REPAIR: - self.repair = self.getConfig("repair") + self.repair = self.getConfig('repair') except OSError, e: if e.errno == 2: @@ -181,10 +181,10 @@ class ExtractArchive(Hook): @threaded - def extractQueued(self,thread): + def extractQueued(self, thread): packages = self.queue.get() while packages: - if self.lastPackage: # called from allDownloadsProcessed + if self.lastPackage: #: called from allDownloadsProcessed self.lastPackage = False if self.extract(packages, thread): #@NOTE: check only if all gone fine, no failed reporting for now self.manager.dispatchEvent("all_archives_extracted") @@ -193,7 +193,7 @@ class ExtractArchive(Hook): if self.extract(packages, thread): #@NOTE: check only if all gone fine, no failed reporting for now pass - packages = self.queue.get() # check for packages added during extraction + packages = self.queue.get() #: check for packages added during extraction @Expose @@ -201,7 +201,7 @@ class ExtractArchive(Hook): """ Extract packages with given id""" for id in ids: self.queue.add(id) - if not self.getConfig("waitall") and not self.extracting: + if not self.getConfig('waitall') and not self.extracting: self.extractQueued() @@ -211,7 +211,7 @@ class ExtractArchive(Hook): def packageFinished(self, pypack): self.queue.add(pypack.id) - if not self.getConfig("waitall") and not self.extracting: + if not self.getConfig('waitall') and not self.extracting: self.extractQueued() @@ -221,7 +221,8 @@ class ExtractArchive(Hook): self.extractQueued() - def extract(self, ids, thread=None): + @Expose + def extract(self, ids, thread=None): #@TODO: Use pypack, not pid to improve method usability if not ids: return False @@ -233,17 +234,17 @@ class ExtractArchive(Hook): toList = lambda string: string.replace(' ', '').replace(',', '|').replace(';', '|').split('|') - destination = self.getConfig("destination") - subfolder = self.getConfig("subfolder") - fullpath = self.getConfig("fullpath") - overwrite = self.getConfig("overwrite") - renice = self.getConfig("renice") - recursive = self.getConfig("recursive") - delete = self.getConfig("delete") - keepbroken = self.getConfig("keepbroken") + destination = self.getConfig('destination') + subfolder = self.getConfig('subfolder') + fullpath = self.getConfig('fullpath') + overwrite = self.getConfig('overwrite') + renice = self.getConfig('renice') + recursive = self.getConfig('recursive') + delete = self.getConfig('delete') + keepbroken = self.getConfig('keepbroken') - extensions = [x.lstrip('.').lower() for x in toList(self.getConfig("extensions"))] - excludefiles = toList(self.getConfig("excludefiles")) + extensions = [x.lstrip('.').lower() for x in toList(self.getConfig('extensions'))] + excludefiles = toList(self.getConfig('excludefiles')) if extensions: self.logDebug("Use for extensions: %s" % "|.".join(extensions)) @@ -254,7 +255,7 @@ class ExtractArchive(Hook): # dl folder dl = self.config['general']['download_folder'] - #iterate packages -> extractors -> targets + # iterate packages -> extractors -> targets for pid in ids: pypack = self.core.files.getPackage(pid) @@ -276,7 +277,7 @@ class ExtractArchive(Hook): matched = False success = True files_ids = dict((pylink['name'],((save_join(dl, pypack.folder, pylink['name'])), pylink['id'], out)) for pylink \ - in sorted(pypack.getChildren().itervalues(), key=lambda k: k['name'])).values() # remove duplicates + in sorted(pypack.getChildren().itervalues(), key=lambda k: k['name'])).values() #: remove duplicates # check as long there are unseen files while files_ids: @@ -301,6 +302,7 @@ class ExtractArchive(Hook): self.logInfo(name, _("Extract to: %s") % fout) try: + pyfile = self.core.files.getFile(fid) archive = Extractor(self, fname, fout, @@ -311,16 +313,22 @@ class ExtractArchive(Hook): delete, keepbroken, fid) + + thread.addActive(pyfile) archive.init() - new_files = self._extract(archive, fid, pypack.password, thread) + try: + new_files = self._extract(pyfile, archive, pypack.password) + + finally: + thread.finishFile(pyfile) except Exception, e: self.logError(name, e) success = False continue - files_ids.remove((fname, fid, fout)) # don't let other extractors spam log + files_ids.remove((fname, fid, fout)) #: don't let other extractors spam log self.logDebug("Extracted files: %s" % new_files) self.setPermissions(new_files) @@ -331,12 +339,11 @@ class ExtractArchive(Hook): continue if recursive and os.path.isfile(file): - new_files_ids.append((filename, fid, os.path.dirname(filename))) # append as new target + new_files_ids.append((filename, fid, os.path.dirname(filename))) #: append as new target - pyfile = self.core.files.getFile(fid) - self.manager.dispatchEvent("archive_extracted", pyfile, archive.out, archive.filename, new_files) + self.manager.dispatchEvent("archive_extracted", pyfile, archive) - files_ids = new_files_ids # also check extracted files + files_ids = new_files_ids #: also check extracted files if matched: if success: @@ -364,21 +371,19 @@ class ExtractArchive(Hook): return True if not failed else False - def _extract(self, archive, fid, password, thread): - pyfile = self.core.files.getFile(fid) + def _extract(self, pyfile, archive, password): name = os.path.basename(archive.filename) - thread.addActive(pyfile) pyfile.setStatus("processing") encrypted = False try: self.logDebug("Password: %s" % (password or "None provided")) - passwords = uniqify([password] + self.getPasswords(False)) if self.getConfig("usepasswordfile") else [password] + passwords = uniqify([password] + self.getPasswords(False)) if self.getConfig('usepasswordfile') else [password] for pw in passwords: try: - if self.getConfig("test") or self.repair: - pyfile.setCustomStatus(_("testing")) + if self.getConfig('test') or self.repair: + pyfile.setCustomStatus(_("archive testing")) if pw: self.logDebug("Testing with password: %s" % pw) pyfile.setProgress(0) @@ -402,12 +407,12 @@ class ExtractArchive(Hook): if self.repair: self.logWarning(name, _("Repairing...")) - pyfile.setCustomStatus(_("repairing")) + pyfile.setCustomStatus(_("archive repairing")) pyfile.setProgress(0) repaired = archive.repair() pyfile.setProgress(100) - if not repaired and not self.getConfig("keepbroken"): + if not repaired and not self.getConfig('keepbroken'): raise CRCError("Archive damaged") self.addPassword(pw) @@ -421,7 +426,7 @@ class ExtractArchive(Hook): pyfile.setCustomStatus(_("extracting")) pyfile.setProgress(0) - if not encrypted or not self.getConfig("usepasswordfile"): + if not encrypted or not self.getConfig('usepasswordfile'): self.logDebug("Extracting using password: %s" % (password or "None")) archive.extract(password) else: @@ -439,12 +444,12 @@ class ExtractArchive(Hook): raise PasswordError pyfile.setProgress(100) - pyfile.setCustomStatus(_("finalizing")) + pyfile.setStatus("processing") if self.core.debug: self.logDebug("Would delete: %s" % ", ".join(archive.getDeleteFiles())) - if self.getConfig("delete"): + if self.getConfig('delete'): files = archive.getDeleteFiles() self.logInfo(_("Deleting %s files") % len(files)) for f in files: @@ -473,10 +478,7 @@ class ExtractArchive(Hook): if self.core.debug: print_exc() - finally: - thread.finishFile(pyfile) - - self.manager.dispatchEvent("archive_extract_failed", pyfile) + self.manager.dispatchEvent("archive_extract_failed", pyfile, archive) raise Exception(_("Extract failed")) @@ -494,7 +496,7 @@ class ExtractArchive(Hook): try: passwords = [] - file = fs_encode(self.getConfig("passwordfile")) + file = fs_encode(self.getConfig('passwordfile')) with open(file) as f: for pw in f.read().splitlines(): passwords.append(pw) @@ -512,7 +514,7 @@ class ExtractArchive(Hook): try: self.passwords = uniqify([password] + self.passwords) - file = fs_encode(self.getConfig("passwordfile")) + file = fs_encode(self.getConfig('passwordfile')) with open(file, "wb") as f: for pw in self.passwords: f.write(pw + '\n') -- cgit v1.2.3 From 6fddff6b1c154ce1a34680bc22b6e39260f6a38c Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Fri, 20 Mar 2015 03:16:32 +0100 Subject: [ExternalScripts] New events support --- module/plugins/hooks/ExternalScripts.py | 39 ++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 6 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index 16049ae9b..dffa3649f 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -10,7 +10,7 @@ from module.utils import fs_encode, save_join class ExternalScripts(Hook): __name__ = "ExternalScripts" __type__ = "hook" - __version__ = "0.35" + __version__ = "0.36" __config__ = [("activated", "bool", "Activated" , True ), ("waitend" , "bool", "Wait script ending", False)] @@ -26,7 +26,8 @@ class ExternalScripts(Hook): event_list = ["archive_extract_failed", "archive_extracted" , "package_extract_failed", "package_extracted" , "all_archives_extracted", "all_archives_processed", - "allDownloadsFinished" , "allDownloadsProcessed" ] + "allDownloadsFinished" , "allDownloadsProcessed" , + "packageDeleted"] #@TODO: Remove in 0.4.10 @@ -35,13 +36,14 @@ class ExternalScripts(Hook): def setup(self): - self.info = {} #@TODO: Remove in 0.4.10 + self.info = {'oldip': None} self.scripts = {} - folders = ["before_reconnect", "after_reconnect", + folders = ["pyload_start", "pyload_restart", "pyload_shutdown", + "before_reconnect", "after_reconnect", "download_preparing", "download_failed", "download_finished", "archive_extract_failed", "archive_extracted", - "package_finished", "package_extract_failed", "package_extracted", + "package_finished", "package_deleted", "package_extract_failed", "package_extracted", "all_downloads_processed", "all_downloads_finished", #@TODO: Invert `all_downloads_processed`, `all_downloads_finished` order in 0.4.10 "all_archives_extracted", "all_archives_processed"] @@ -54,6 +56,8 @@ class ExternalScripts(Hook): if names: self.logInfo(_("Installed scripts for: ") + script_type, ", ".join(map(os.path.basename, names))) + self.pyload_start() + def initPluginType(self, name, dir): if not os.path.isdir(dir): @@ -97,14 +101,25 @@ class ExternalScripts(Hook): self.logError(_("Runtime error: %s") % os.path.abspath(script), _("Unknown error")) + def pyload_start(self): + for script in self.scripts['pyload_start']: + self.callScript(script) + + + def coreExiting(self): + for script in self.scripts['pyload_restart' if self.core.do_restart else 'pyload_shutdown']: + self.callScript(script) + + def beforeReconnecting(self, ip): for script in self.scripts['before_reconnect']: self.callScript(script, ip) + self.info['oldip'] = ip def afterReconnecting(self, ip): for script in self.scripts['after_reconnect']: - self.callScript(script, ip) + self.callScript(script, ip, self.info['oldip']) #@TODO: Use built-in oldip in 0.4.10 def downloadPreparing(self, pyfile): @@ -154,6 +169,18 @@ class ExternalScripts(Hook): self.callScript(script, pypack.id, pypack.name, download_folder) + def packageDeleted(self, pid): + pack = self.core.api.getPackageInfo(pid) + + if self.config['general']['folder_per_package']: + download_folder = save_join(self.config['general']['download_folder'], pack.folder) + else: + download_folder = self.config['general']['download_folder'] + + for script in self.scripts['package_deleted']: + self.callScript(script, pack.id, pack.name, download_folder) + + def package_extract_failed(self, pypack): if self.config['general']['folder_per_package']: download_folder = save_join(self.config['general']['download_folder'], pypack.folder) -- cgit v1.2.3 From c4b30b08857225e6a70aa3171b6663d84e78b22f Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Fri, 20 Mar 2015 11:22:16 +0100 Subject: [ExternalScripts] Rename pyload_shutdown to pyload_stop --- module/plugins/hooks/ExternalScripts.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index dffa3649f..8f6c405fd 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -10,7 +10,7 @@ from module.utils import fs_encode, save_join class ExternalScripts(Hook): __name__ = "ExternalScripts" __type__ = "hook" - __version__ = "0.36" + __version__ = "0.37" __config__ = [("activated", "bool", "Activated" , True ), ("waitend" , "bool", "Wait script ending", False)] @@ -39,7 +39,7 @@ class ExternalScripts(Hook): self.info = {'oldip': None} self.scripts = {} - folders = ["pyload_start", "pyload_restart", "pyload_shutdown", + folders = ["pyload_start", "pyload_restart", "pyload_stop", "before_reconnect", "after_reconnect", "download_preparing", "download_failed", "download_finished", "archive_extract_failed", "archive_extracted", @@ -107,7 +107,7 @@ class ExternalScripts(Hook): def coreExiting(self): - for script in self.scripts['pyload_restart' if self.core.do_restart else 'pyload_shutdown']: + for script in self.scripts['pyload_restart' if self.core.do_restart else 'pyload_stop']: self.callScript(script) -- cgit v1.2.3 From fb2d3d6b6a4b7be7fe0e771406e3acbf084d11f0 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Sat, 21 Mar 2015 17:13:45 +0100 Subject: [UpdateManager] Fix https://github.com/pyload/pyload/issues/1272 --- module/plugins/hooks/UpdateManager.py | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index 7270bc34f..ca94548ea 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -28,7 +28,7 @@ def exists(path): class UpdateManager(Hook): __name__ = "UpdateManager" __type__ = "hook" - __version__ = "0.46" + __version__ = "0.47" __config__ = [("activated" , "bool" , "Activated" , True ), ("mode" , "pyLoad + plugins;plugins only", "Check updates for" , "pyLoad + plugins"), @@ -44,26 +44,26 @@ class UpdateManager(Hook): # event_list = ["pluginConfigChanged"] - SERVER_URL = "http://updatemanager.pyload.org" - VERSION = re.compile(r'__version__.*=.*("|\')([\d.]+)') + SERVER_URL = "http://updatemanager.pyload.org" + VERSION = re.compile(r'__version__.*=.*("|\')([\d.]+)') MIN_CHECK_INTERVAL = 3 * 60 * 60 #: 3 hours - # def pluginConfigChanged(self, plugin, name, value): - # if name == "interval": - # interval = value * 60 * 60 - # if self.MIN_CHECK_INTERVAL <= interval != self.interval: + def pluginConfigChanged(self, plugin, name, value): + if name == "interval": + interval = value * 60 * 60 + if self.MIN_CHECK_INTERVAL <= interval != self.interval: # self.core.scheduler.removeJob(self.cb) - # self.interval = interval - # self.initPeriodical() - # else: - # self.logDebug("Invalid interval value, kept current") - - # elif name == "reloadplugins": - # if self.cb2: - # self.core.scheduler.removeJob(self.cb2) - # if value is True and self.core.debug: - # self.periodical2() + self.interval = interval + self.initPeriodical() + else: + self.logDebug("Invalid interval value, kept current") + + elif name == "reloadplugins": + if self.cb2: + self.core.scheduler.removeJob(self.cb2) + if value is True and self.core.debug: + self.periodical2() def coreReady(self): -- cgit v1.2.3 From b9219fa1859de12de010a07c4c92a9f0270042ac Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Sat, 21 Mar 2015 17:17:03 +0100 Subject: [DeleteFinished] Define MIN_CHECK_INTERVAL --- module/plugins/hooks/DeleteFinished.py | 38 ++++++++++++++++++---------------- module/plugins/hooks/RestartFailed.py | 5 +++-- 2 files changed, 23 insertions(+), 20 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/DeleteFinished.py b/module/plugins/hooks/DeleteFinished.py index 3dff9c7bd..75cb33e96 100644 --- a/module/plugins/hooks/DeleteFinished.py +++ b/module/plugins/hooks/DeleteFinished.py @@ -7,11 +7,11 @@ from module.plugins.Hook import Hook class DeleteFinished(Hook): __name__ = "DeleteFinished" __type__ = "hook" - __version__ = "1.11" + __version__ = "1.12" - __config__ = [('activated', 'bool', 'Activated', 'False'), - ('interval', 'int', 'Delete every (hours)', '72'), - ('deloffline', 'bool', 'Delete packages with offline links', 'False')] + __config__ = [("activated" , "bool", "Activated" , "False"), + ("interval" , "int" , "Delete every (hours)" , "72" ), + ("deloffline", "bool", "Delete packages with offline links", "False")] __description__ = """Automatically delete all finished packages from queue""" __license__ = "GPLv3" @@ -20,8 +20,15 @@ class DeleteFinished(Hook): # event_list = ["pluginConfigChanged"] + MIN_CHECK_INTERVAL = 1 * 60 * 60 #: 1 hour + ## overwritten methods ## + def setup(self): + self.info = {} #@TODO: Remove in 0.4.10 + self.interval = self.MIN_CHECK_INTERVAL + + def periodical(self): if not self.info['sleep']: deloffline = self.getConfig('deloffline') @@ -40,13 +47,14 @@ class DeleteFinished(Hook): def unload(self): - self.removeEvent('packageFinished', self.wakeup) + self.manager.removeEvent('packageFinished', self.wakeup) def coreReady(self): self.info['sleep'] = True - interval = self.getConfig('interval') - self.pluginConfigChanged(self.__name__, 'interval', interval) + # interval = self.getConfig('interval') + # self.pluginConfigChanged(self.__name__, 'interval', interval) + self.interval = max(self.MIN_CHECK_INTERVAL, self.getConfig('interval') * 60 * 60) self.addEvent('packageFinished', self.wakeup) @@ -58,23 +66,17 @@ class DeleteFinished(Hook): def wakeup(self, pypack): - self.removeEvent('packageFinished', self.wakeup) + self.manager.removeEvent('packageFinished', self.wakeup) self.info['sleep'] = False ## event managing ## def addEvent(self, event, func): """Adds an event listener for event name""" - if event in self.m.events: - if func in self.m.events[event]: + if event in self.manager.events: + if func in self.manager.events[event]: self.logDebug("Function already registered", func) else: - self.m.events[event].append(func) + self.manager.events[event].append(func) else: - self.m.events[event] = [func] - - - def setup(self): - self.info = {} #@TODO: Remove in 0.4.10 - self.m = self.manager - self.removeEvent = self.m.removeEvent + self.manager.events[event] = [func] diff --git a/module/plugins/hooks/RestartFailed.py b/module/plugins/hooks/RestartFailed.py index c861e9c41..cab986d9e 100644 --- a/module/plugins/hooks/RestartFailed.py +++ b/module/plugins/hooks/RestartFailed.py @@ -6,7 +6,7 @@ from module.plugins.Hook import Hook class RestartFailed(Hook): __name__ = "RestartFailed" __type__ = "hook" - __version__ = "1.57" + __version__ = "1.58" __config__ = [("interval", "int", "Check interval in minutes", 90)] @@ -42,4 +42,5 @@ class RestartFailed(Hook): def coreReady(self): - self.pluginConfigChanged(self.__name__, "interval", self.getConfig('interval')) + # self.pluginConfigChanged(self.__name__, "interval", self.getConfig('interval')) + self.interval = max(self.MIN_CHECK_INTERVAL, self.getConfig('interval') * 60) -- cgit v1.2.3 From 7bb9f21985abae3c15b6be9d6b7f7f8ba35405ba Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Sun, 22 Mar 2015 03:54:59 +0100 Subject: [UpdateManager] Fix https://github.com/pyload/pyload/issues/1274 --- module/plugins/hooks/UpdateManager.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index ca94548ea..7d8f44fef 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -28,7 +28,7 @@ def exists(path): class UpdateManager(Hook): __name__ = "UpdateManager" __type__ = "hook" - __version__ = "0.47" + __version__ = "0.48" __config__ = [("activated" , "bool" , "Activated" , True ), ("mode" , "pyLoad + plugins;plugins only", "Check updates for" , "pyLoad + plugins"), @@ -136,6 +136,7 @@ class UpdateManager(Hook): @threaded def updateThread(self): + self.core.api.pauseServer() self.updating = True status = self.update(onlyplugin=self.getConfig('mode') == "plugins only") @@ -144,6 +145,7 @@ class UpdateManager(Hook): self.core.api.restart() else: self.updating = False + self.core.api.unpauseServer() @Expose -- cgit v1.2.3 From 25d7ae217d675d51110da5225e3d5c52202e8e2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20H=C3=B6rnlein?= <jens.hoernlein@googlemail.com> Date: Sun, 22 Mar 2015 16:13:48 +0100 Subject: [AntiVirus] Typo & Remove Comment within Array --- module/plugins/hooks/AntiVirus.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/AntiVirus.py b/module/plugins/hooks/AntiVirus.py index ffed86836..6f88b982a 100644 --- a/module/plugins/hooks/AntiVirus.py +++ b/module/plugins/hooks/AntiVirus.py @@ -11,9 +11,10 @@ from module.utils import fs_encode, save_join class AntiVirus(Hook): __name__ = "AntiVirus" __type__ = "hook" - __version__ = "0.04" + __version__ = "0.05" - __config__ = [("action" , "Antivirus default;Delete;Quarantine", "Manage infected files" , "Antivirus default"), #@TODO: add trash option (use Send2Trash lib) + #@TODO: add trash option (use Send2Trash lib) + __config__ = [("action" , "Antivirus default;Delete;Quarantine", "Manage infected files" , "Antivirus default"), ("quardir" , "folder" , "Quarantine folder" , "" ), ("scanfailed", "bool" , "Scan incompleted files (failed downloads)", False ), ("cmdfile" , "file" , "Antivirus executable" , "" ), @@ -58,7 +59,7 @@ class AntiVirus(Hook): if err: self.logWarning(filename, err) - if not self.getConfig('ignore-err') + if not self.getConfig('ignore-err'): self.logDebug("Delete/Quarantine task is aborted") return -- cgit v1.2.3 From d0ef13775925f15811d2a6744d29190c313b3820 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20H=C3=B6rnlein?= <jens.hoernlein@googlemail.com> Date: Mon, 23 Mar 2015 00:32:56 +0100 Subject: [ExtractArchive] extract archive even if first part is not in package --- module/plugins/hooks/ExtractArchive.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 0c163078c..d9af2dd49 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -106,7 +106,7 @@ class ArchiveQueue(object): class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.34" + __version__ = "1.35" __config__ = [("activated" , "bool" , "Activated" , True ), ("fullpath" , "bool" , "Extract with full paths" , True ), @@ -328,7 +328,9 @@ class ExtractArchive(Hook): success = False continue - files_ids.remove((fname, fid, fout)) #: don't let other extractors spam log + # remove processed file and related multiparts from list + files_ids = [(fname, fid, fout) for fname, fid, fout in files_ids \ + if fname not in archive.getDeleteFiles()] self.logDebug("Extracted files: %s" % new_files) self.setPermissions(new_files) -- cgit v1.2.3 From 61457a4e1b1ef95edbd7e7d82d01ad44d4158bdf Mon Sep 17 00:00:00 2001 From: Kagenoshin <Kagenoshin@users.noreply.github.com> Date: Wed, 25 Mar 2015 10:51:46 +0100 Subject: New plugin: MegaRapidoNet --- module/plugins/hooks/MegaRapidoNet.py | 117 ++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 module/plugins/hooks/MegaRapidoNet.py (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/MegaRapidoNet.py b/module/plugins/hooks/MegaRapidoNet.py new file mode 100644 index 000000000..e59b94adf --- /dev/null +++ b/module/plugins/hooks/MegaRapidoNet.py @@ -0,0 +1,117 @@ +# -*- coding: utf-8 -*- +import re + +from module.network.RequestFactory import getURL +from module.plugins.internal.MultiHoster import MultiHoster + + +class MegaRapidoNet(MultiHoster): + __name__ = "MegaRapidoNet" + __version__ = "0.01" + __type__ = "hook" + __config__ = [("activated", "bool", "Activated", "False"), + ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), + ("hosterList", "str", "Hoster list (comma separated)", "")] + __description__ = """Megarapido.net hook plugin""" + __author_name__ = ("Kagenoshin") + __author_mail__ = ("kagenoshin@gmx.ch") + + HOSTER_PATTERN = re.compile(r'align\s*?=\s*?["\']*?left.*?<\s*?strong\s*?>([^<]*?)<', re.I) + + def getHoster(self): + hosters = { + '1fichier': [],#leave it there are so many possible addresses? + '1st-files': ['1st-files.com'], + '2shared': ['2shared.com'], + '4shared': ['4shared.com', '4shared-china.com'], + 'asfile': ['http://asfile.com/'], + 'bitshare': ['bitshare.com'], + 'brupload': ['brupload.net'], + 'crocko': ['crocko.com','easy-share.com'], + 'dailymotion': ['dailymotion.com'], + 'depfile': ['depfile.com'], + 'depositfiles': ['depositfiles.com', 'dfiles.eu'], + 'dizzcloud': ['dizzcloud.com'], + 'dl.dropbox': [], + 'extabit': ['extabit.com'], + 'extmatrix': ['extmatrix.com'], + 'facebook': [], + 'file4go': ['file4go.com'], + 'filecloud': ['filecloud.io','ifile.it','mihd.net'], + 'filefactory': ['filefactory.com'], + 'fileom': ['fileom.com'], + 'fileparadox': ['fileparadox.in'], + 'filepost': ['filepost.com', 'fp.io'], + 'filerio': ['filerio.in','filerio.com','filekeen.com'], + 'filesflash': ['filesflash.com'], + 'firedrive': ['firedrive.com', 'putlocker.com'], + 'flashx': [], + 'freakshare': ['freakshare.net', 'freakshare.com'], + 'gigasize': ['gigasize.com'], + 'hipfile': ['hipfile.com'], + 'junocloud': ['junocloud.me'], + 'letitbit': ['letitbit.net','shareflare.net'], + 'mediafire': ['mediafire.com'], + 'mega': ['mega.co.nz'], + 'megashares': ['megashares.com'], + 'metacafe': ['metacafe.com'], + 'netload': ['netload.in'], + 'oboom': ['oboom.com'], + 'rapidgator': ['rapidgator.net'], + 'rapidshare': ['rapidshare.com'], + 'rarefile': ['rarefile.net'], + 'ryushare': ['ryushare.com'], + 'sendspace': ['sendspace.com'], + 'turbobit': ['turbobit.net', 'unextfiles.com'], + 'uploadable': ['uploadable.ch'], + 'uploadbaz': ['uploadbaz.com'], + 'uploaded': ['uploaded.to', 'uploaded.net', 'ul.to'], + 'uploadhero': ['uploadhero.com'], + 'uploading': ['uploading.com'], + 'uptobox': ['uptobox.com'], + 'xvideos': ['xvideos.com'], + 'youtube': ['youtube.com'] + } + + #check if the list is still valid + #has to be added! self.check_for_new_or_removed_hosters(hosters) + + #build list + hoster_list = [] + + for item in hosters.itervalues(): + hoster_list.extend(item) + + return hoster_list + + def check_for_new_or_removed_hosters(self, hosters): + #get the old hosters + old_hosters = hosters.keys() + + #load the current hosters from vipleech4u.com + page = getURL('http://vipleech4u.com/hosts.php') + current_hosters = self.HOSTER_PATTERN.findall(page) + current_hosters = [x.lower() for x in current_hosters] + + #let's look for new hosters + new_hosters = [] + + for hoster in current_hosters: + if not hoster in old_hosters: + new_hosters.append(hoster) + + #let's look for removed hosters + removed_hosters = [] + + for hoster in old_hosters: + if not hoster in current_hosters: + removed_hosters.append(hoster) + + if new_hosters: + self.logDebug('The following new hosters were found on vipleech4u.com: %s' % str(new_hosters)) + + if removed_hosters: + self.logDebug('The following hosters were removed from vipleech4u.com: %s' % str(removed_hosters)) + + if not (new_hosters and removed_hosters): + self.logDebug('The hoster list is still valid.') -- cgit v1.2.3 From aaa8b74cbc8cab1ccd314c820b1fff5999bd2fd9 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Wed, 25 Mar 2015 12:08:31 +0100 Subject: [MegaRapidoNet] Cleanup --- module/plugins/hooks/MegaRapidoNet.py | 178 ++++++++++++++-------------------- 1 file changed, 71 insertions(+), 107 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/MegaRapidoNet.py b/module/plugins/hooks/MegaRapidoNet.py index e59b94adf..33c74ae6f 100644 --- a/module/plugins/hooks/MegaRapidoNet.py +++ b/module/plugins/hooks/MegaRapidoNet.py @@ -1,117 +1,81 @@ # -*- coding: utf-8 -*- -import re - -from module.network.RequestFactory import getURL -from module.plugins.internal.MultiHoster import MultiHoster - - -class MegaRapidoNet(MultiHoster): - __name__ = "MegaRapidoNet" - __version__ = "0.01" - __type__ = "hook" - __config__ = [("activated", "bool", "Activated", "False"), - ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), - ("hosterList", "str", "Hoster list (comma separated)", "")] - __description__ = """Megarapido.net hook plugin""" - __author_name__ = ("Kagenoshin") - __author_mail__ = ("kagenoshin@gmx.ch") - HOSTER_PATTERN = re.compile(r'align\s*?=\s*?["\']*?left.*?<\s*?strong\s*?>([^<]*?)<', re.I) - - def getHoster(self): - hosters = { - '1fichier': [],#leave it there are so many possible addresses? - '1st-files': ['1st-files.com'], - '2shared': ['2shared.com'], - '4shared': ['4shared.com', '4shared-china.com'], - 'asfile': ['http://asfile.com/'], - 'bitshare': ['bitshare.com'], - 'brupload': ['brupload.net'], - 'crocko': ['crocko.com','easy-share.com'], - 'dailymotion': ['dailymotion.com'], - 'depfile': ['depfile.com'], - 'depositfiles': ['depositfiles.com', 'dfiles.eu'], - 'dizzcloud': ['dizzcloud.com'], - 'dl.dropbox': [], - 'extabit': ['extabit.com'], - 'extmatrix': ['extmatrix.com'], - 'facebook': [], - 'file4go': ['file4go.com'], - 'filecloud': ['filecloud.io','ifile.it','mihd.net'], - 'filefactory': ['filefactory.com'], - 'fileom': ['fileom.com'], - 'fileparadox': ['fileparadox.in'], - 'filepost': ['filepost.com', 'fp.io'], - 'filerio': ['filerio.in','filerio.com','filekeen.com'], - 'filesflash': ['filesflash.com'], - 'firedrive': ['firedrive.com', 'putlocker.com'], - 'flashx': [], - 'freakshare': ['freakshare.net', 'freakshare.com'], - 'gigasize': ['gigasize.com'], - 'hipfile': ['hipfile.com'], - 'junocloud': ['junocloud.me'], - 'letitbit': ['letitbit.net','shareflare.net'], - 'mediafire': ['mediafire.com'], - 'mega': ['mega.co.nz'], - 'megashares': ['megashares.com'], - 'metacafe': ['metacafe.com'], - 'netload': ['netload.in'], - 'oboom': ['oboom.com'], - 'rapidgator': ['rapidgator.net'], - 'rapidshare': ['rapidshare.com'], - 'rarefile': ['rarefile.net'], - 'ryushare': ['ryushare.com'], - 'sendspace': ['sendspace.com'], - 'turbobit': ['turbobit.net', 'unextfiles.com'], - 'uploadable': ['uploadable.ch'], - 'uploadbaz': ['uploadbaz.com'], - 'uploaded': ['uploaded.to', 'uploaded.net', 'ul.to'], - 'uploadhero': ['uploadhero.com'], - 'uploading': ['uploading.com'], - 'uptobox': ['uptobox.com'], - 'xvideos': ['xvideos.com'], - 'youtube': ['youtube.com'] - } +import re - #check if the list is still valid - #has to be added! self.check_for_new_or_removed_hosters(hosters) +from module.plugins.internal.MultiHook import MultiHook + + +class MegaRapidoNet(MultiHook): + __name__ = "MegaRapidoNet" + __type__ = "hook" + __version__ = "0.02" + + __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)", "" ), + ("reload" , "bool" , "Reload plugin list" , True ), + ("reloadinterval", "int" , "Reload interval in hours" , 12 )] + + __description__ = """MegaRapido.net hook plugin""" + __license__ = "GPLv3" + __authors__ = [("Kagenoshin", "kagenoshin@gmx.ch")] + + + def getHosters(self): + hosters = {'1fichier': [],#leave it there are so many possible addresses? + '1st-files': ['1st-files.com'], + '2shared': ['2shared.com'], + '4shared': ['4shared.com', '4shared-china.com'], + 'asfile': ['http://asfile.com/'], + 'bitshare': ['bitshare.com'], + 'brupload': ['brupload.net'], + 'crocko': ['crocko.com','easy-share.com'], + 'dailymotion': ['dailymotion.com'], + 'depfile': ['depfile.com'], + 'depositfiles': ['depositfiles.com', 'dfiles.eu'], + 'dizzcloud': ['dizzcloud.com'], + 'dl.dropbox': [], + 'extabit': ['extabit.com'], + 'extmatrix': ['extmatrix.com'], + 'facebook': [], + 'file4go': ['file4go.com'], + 'filecloud': ['filecloud.io','ifile.it','mihd.net'], + 'filefactory': ['filefactory.com'], + 'fileom': ['fileom.com'], + 'fileparadox': ['fileparadox.in'], + 'filepost': ['filepost.com', 'fp.io'], + 'filerio': ['filerio.in','filerio.com','filekeen.com'], + 'filesflash': ['filesflash.com'], + 'firedrive': ['firedrive.com', 'putlocker.com'], + 'flashx': [], + 'freakshare': ['freakshare.net', 'freakshare.com'], + 'gigasize': ['gigasize.com'], + 'hipfile': ['hipfile.com'], + 'junocloud': ['junocloud.me'], + 'letitbit': ['letitbit.net','shareflare.net'], + 'mediafire': ['mediafire.com'], + 'mega': ['mega.co.nz'], + 'megashares': ['megashares.com'], + 'metacafe': ['metacafe.com'], + 'netload': ['netload.in'], + 'oboom': ['oboom.com'], + 'rapidgator': ['rapidgator.net'], + 'rapidshare': ['rapidshare.com'], + 'rarefile': ['rarefile.net'], + 'ryushare': ['ryushare.com'], + 'sendspace': ['sendspace.com'], + 'turbobit': ['turbobit.net', 'unextfiles.com'], + 'uploadable': ['uploadable.ch'], + 'uploadbaz': ['uploadbaz.com'], + 'uploaded': ['uploaded.to', 'uploaded.net', 'ul.to'], + 'uploadhero': ['uploadhero.com'], + 'uploading': ['uploading.com'], + 'uptobox': ['uptobox.com'], + 'xvideos': ['xvideos.com'], + 'youtube': ['youtube.com']} - #build list hoster_list = [] for item in hosters.itervalues(): hoster_list.extend(item) return hoster_list - - def check_for_new_or_removed_hosters(self, hosters): - #get the old hosters - old_hosters = hosters.keys() - - #load the current hosters from vipleech4u.com - page = getURL('http://vipleech4u.com/hosts.php') - current_hosters = self.HOSTER_PATTERN.findall(page) - current_hosters = [x.lower() for x in current_hosters] - - #let's look for new hosters - new_hosters = [] - - for hoster in current_hosters: - if not hoster in old_hosters: - new_hosters.append(hoster) - - #let's look for removed hosters - removed_hosters = [] - - for hoster in old_hosters: - if not hoster in current_hosters: - removed_hosters.append(hoster) - - if new_hosters: - self.logDebug('The following new hosters were found on vipleech4u.com: %s' % str(new_hosters)) - - if removed_hosters: - self.logDebug('The following hosters were removed from vipleech4u.com: %s' % str(removed_hosters)) - - if not (new_hosters and removed_hosters): - self.logDebug('The hoster list is still valid.') -- cgit v1.2.3 From ffb46ab200df55303836cc49e61b971b02e67ec8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20H=C3=B6rnlein?= <jens.hoernlein@googlemail.com> Date: Wed, 25 Mar 2015 18:39:54 +0100 Subject: [ExtractArchive] Send2Trash Integration --- module/plugins/hooks/ExtractArchive.py | 63 +++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 24 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index d9af2dd49..c0fe22545 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -106,24 +106,24 @@ class ArchiveQueue(object): class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.35" - - __config__ = [("activated" , "bool" , "Activated" , True ), - ("fullpath" , "bool" , "Extract with full paths" , True ), - ("overwrite" , "bool" , "Overwrite files" , False ), - ("keepbroken" , "bool" , "Try to extract broken archives" , False ), - ("repair" , "bool" , "Repair broken archives (RAR required)" , False ), - ("test" , "bool" , "Test archive before extracting" , False ), - ("usepasswordfile", "bool" , "Use password file" , True ), - ("passwordfile" , "file" , "Password file" , "archive_password.txt" ), - ("delete" , "bool" , "Delete archive after extraction" , False ), - ("subfolder" , "bool" , "Create subfolder for each package" , False ), - ("destination" , "folder", "Extract files to folder" , "" ), - ("extensions" , "str" , "Extract archives ending with extension", "7z,bz2,bzip2,gz,gzip,lha,lzh,lzma,rar,tar,taz,tbz,tbz2,tgz,xar,xz,z,zip"), - ("excludefiles" , "str" , "Don't extract the following files" , "*.nfo,*.DS_Store,index.dat,thumb.db" ), - ("recursive" , "bool" , "Extract archives in archives" , True ), - ("waitall" , "bool" , "Run after all downloads was processed" , False ), - ("renice" , "int" , "CPU priority" , 0 )] + __version__ = "1.36" + + __config__ = [("activated" , "bool" , "Activated" , True ), + ("fullpath" , "bool" , "Extract with full paths" , True ), + ("overwrite" , "bool" , "Overwrite files" , False ), + ("keepbroken" , "bool" , "Try to extract broken archives" , False ), + ("repair" , "bool" , "Repair broken archives (RAR required)" , False ), + ("test" , "bool" , "Test archive before extracting" , False ), + ("usepasswordfile", "bool" , "Use password file" , True ), + ("passwordfile" , "file" , "Password file" , "archive_password.txt" ), + ("delete" , "No;Permanent;Trash" , "Delete archive after extraction" , "No" ), + ("subfolder" , "bool" , "Create subfolder for each package" , False ), + ("destination" , "folder" , "Extract files to folder" , "" ), + ("extensions" , "str" , "Extract archives ending with extension", "7z,bz2,bzip2,gz,gzip,lha,lzh,lzma,rar,tar,taz,tbz,tbz2,tgz,xar,xz,z,zip"), + ("excludefiles" , "str" , "Don't extract the following files" , "*.nfo,*.DS_Store,index.dat,thumb.db" ), + ("recursive" , "bool" , "Extract archives in archives" , True ), + ("waitall" , "bool" , "Run after all downloads was processed" , False ), + ("renice" , "int" , "CPU priority" , 0 )] __description__ = """Extract different kind of archives""" __license__ = "GPLv3" @@ -148,6 +148,7 @@ class ExtractArchive(Hook): self.extractors = [] self.passwords = [] self.repair = False + self.trash = False def coreReady(self): @@ -448,15 +449,29 @@ class ExtractArchive(Hook): pyfile.setProgress(100) pyfile.setStatus("processing") + delfiles = archive.getDeleteFiles() if self.core.debug: - self.logDebug("Would delete: %s" % ", ".join(archive.getDeleteFiles())) + self.logDebug("Would delete: %s" % ", ".join(delfiles)) - if self.getConfig('delete'): - files = archive.getDeleteFiles() - self.logInfo(_("Deleting %s files") % len(files)) - for f in files: + if self.getConfig('delete') != 'No': + try: + from send2trash import send2trash + if self.getConfig('delete') == "Trash": + self.trash = True + self.logInfo(_("Sending %s files to trash") % len(delfiles)) + except ImportError: + self.logError(name, _("Send2Trash not installed, no files deleted")) + self.trash = False + + if self.getConfig('delete') == "Permanent": + self.trash = False + self.logInfo(_("Deleting %s files") % len(delfiles)) + + for f in delfiles: file = fs_encode(f) - if os.path.exists(file): + if os.path.exists(file) and self.trash: + send2trash(file) + elif os.path.exists: os.remove(file) else: self.logDebug("%s does not exists" % f) -- cgit v1.2.3 From f4f618f95a2348c8881ae455e1c8ad01ba3eae30 Mon Sep 17 00:00:00 2001 From: Gutz-Pilz <hannes.mueller87@gmail.com> Date: Wed, 25 Mar 2015 22:02:11 +0100 Subject: fixed "permanent" issue (forgot to change filversion) --- module/plugins/hooks/ExtractArchive.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index c0fe22545..5d71e89ec 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -106,7 +106,7 @@ class ArchiveQueue(object): class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.36" + __version__ = "1.37" __config__ = [("activated" , "bool" , "Activated" , True ), ("fullpath" , "bool" , "Extract with full paths" , True ), @@ -471,7 +471,7 @@ class ExtractArchive(Hook): file = fs_encode(f) if os.path.exists(file) and self.trash: send2trash(file) - elif os.path.exists: + elif os.path.exists(file): os.remove(file) else: self.logDebug("%s does not exists" % f) -- cgit v1.2.3 From 7d90803262ccbb4fc5296a4dc3ce30fe98f55631 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Wed, 25 Mar 2015 23:10:07 +0100 Subject: __config__ cosmetics --- module/plugins/hooks/ClickAndLoad.py | 2 +- module/plugins/hooks/MegaRapidoNet.py | 100 +++++++++++++++++----------------- 2 files changed, 51 insertions(+), 51 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 257f58584..0564e31ca 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -58,7 +58,7 @@ class ClickAndLoad(Hook): @threaded def proxy(self, ip, webport, cnlport): - time.sleep(10) #@TODO: Implement addon delay on start in 0.4.10 + time.sleep(10) #@TODO: Remove in 0.4.10 (implement addon delay on startup) self.logInfo(_("Proxy listening on %s:%s") % (ip or "0.0.0.0", cnlport)) diff --git a/module/plugins/hooks/MegaRapidoNet.py b/module/plugins/hooks/MegaRapidoNet.py index 33c74ae6f..fb5e77994 100644 --- a/module/plugins/hooks/MegaRapidoNet.py +++ b/module/plugins/hooks/MegaRapidoNet.py @@ -21,57 +21,57 @@ class MegaRapidoNet(MultiHook): def getHosters(self): - hosters = {'1fichier': [],#leave it there are so many possible addresses? - '1st-files': ['1st-files.com'], - '2shared': ['2shared.com'], - '4shared': ['4shared.com', '4shared-china.com'], - 'asfile': ['http://asfile.com/'], - 'bitshare': ['bitshare.com'], - 'brupload': ['brupload.net'], - 'crocko': ['crocko.com','easy-share.com'], - 'dailymotion': ['dailymotion.com'], - 'depfile': ['depfile.com'], + hosters = {'1fichier' : [],#leave it there are so many possible addresses? + '1st-files' : ['1st-files.com'], + '2shared' : ['2shared.com'], + '4shared' : ['4shared.com', '4shared-china.com'], + 'asfile' : ['http://asfile.com/'], + 'bitshare' : ['bitshare.com'], + 'brupload' : ['brupload.net'], + 'crocko' : ['crocko.com','easy-share.com'], + 'dailymotion' : ['dailymotion.com'], + 'depfile' : ['depfile.com'], 'depositfiles': ['depositfiles.com', 'dfiles.eu'], - 'dizzcloud': ['dizzcloud.com'], - 'dl.dropbox': [], - 'extabit': ['extabit.com'], - 'extmatrix': ['extmatrix.com'], - 'facebook': [], - 'file4go': ['file4go.com'], - 'filecloud': ['filecloud.io','ifile.it','mihd.net'], - 'filefactory': ['filefactory.com'], - 'fileom': ['fileom.com'], - 'fileparadox': ['fileparadox.in'], - 'filepost': ['filepost.com', 'fp.io'], - 'filerio': ['filerio.in','filerio.com','filekeen.com'], - 'filesflash': ['filesflash.com'], - 'firedrive': ['firedrive.com', 'putlocker.com'], - 'flashx': [], - 'freakshare': ['freakshare.net', 'freakshare.com'], - 'gigasize': ['gigasize.com'], - 'hipfile': ['hipfile.com'], - 'junocloud': ['junocloud.me'], - 'letitbit': ['letitbit.net','shareflare.net'], - 'mediafire': ['mediafire.com'], - 'mega': ['mega.co.nz'], - 'megashares': ['megashares.com'], - 'metacafe': ['metacafe.com'], - 'netload': ['netload.in'], - 'oboom': ['oboom.com'], - 'rapidgator': ['rapidgator.net'], - 'rapidshare': ['rapidshare.com'], - 'rarefile': ['rarefile.net'], - 'ryushare': ['ryushare.com'], - 'sendspace': ['sendspace.com'], - 'turbobit': ['turbobit.net', 'unextfiles.com'], - 'uploadable': ['uploadable.ch'], - 'uploadbaz': ['uploadbaz.com'], - 'uploaded': ['uploaded.to', 'uploaded.net', 'ul.to'], - 'uploadhero': ['uploadhero.com'], - 'uploading': ['uploading.com'], - 'uptobox': ['uptobox.com'], - 'xvideos': ['xvideos.com'], - 'youtube': ['youtube.com']} + 'dizzcloud' : ['dizzcloud.com'], + 'dl.dropbox' : [], + 'extabit' : ['extabit.com'], + 'extmatrix' : ['extmatrix.com'], + 'facebook' : [], + 'file4go' : ['file4go.com'], + 'filecloud' : ['filecloud.io','ifile.it','mihd.net'], + 'filefactory' : ['filefactory.com'], + 'fileom' : ['fileom.com'], + 'fileparadox' : ['fileparadox.in'], + 'filepost' : ['filepost.com', 'fp.io'], + 'filerio' : ['filerio.in','filerio.com','filekeen.com'], + 'filesflash' : ['filesflash.com'], + 'firedrive' : ['firedrive.com', 'putlocker.com'], + 'flashx' : [], + 'freakshare' : ['freakshare.net', 'freakshare.com'], + 'gigasize' : ['gigasize.com'], + 'hipfile' : ['hipfile.com'], + 'junocloud' : ['junocloud.me'], + 'letitbit' : ['letitbit.net','shareflare.net'], + 'mediafire' : ['mediafire.com'], + 'mega' : ['mega.co.nz'], + 'megashares' : ['megashares.com'], + 'metacafe' : ['metacafe.com'], + 'netload' : ['netload.in'], + 'oboom' : ['oboom.com'], + 'rapidgator' : ['rapidgator.net'], + 'rapidshare' : ['rapidshare.com'], + 'rarefile' : ['rarefile.net'], + 'ryushare' : ['ryushare.com'], + 'sendspace' : ['sendspace.com'], + 'turbobit' : ['turbobit.net', 'unextfiles.com'], + 'uploadable' : ['uploadable.ch'], + 'uploadbaz' : ['uploadbaz.com'], + 'uploaded' : ['uploaded.to', 'uploaded.net', 'ul.to'], + 'uploadhero' : ['uploadhero.com'], + 'uploading' : ['uploading.com'], + 'uptobox' : ['uptobox.com'], + 'xvideos' : ['xvideos.com'], + 'youtube' : ['youtube.com']} hoster_list = [] -- cgit v1.2.3 From b6dc723bf214e8680f7be29594581d3da5033b90 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Thu, 26 Mar 2015 09:57:34 +0100 Subject: [UpdateManager] Update --- module/plugins/hooks/UpdateManager.py | 173 ++++++++++++++++------------------ 1 file changed, 80 insertions(+), 93 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index 7d8f44fef..643b5c2d1 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -5,6 +5,7 @@ from __future__ import with_statement import os import re import sys +import time from operator import itemgetter @@ -28,67 +29,57 @@ def exists(path): class UpdateManager(Hook): __name__ = "UpdateManager" __type__ = "hook" - __version__ = "0.48" + __version__ = "0.50" - __config__ = [("activated" , "bool" , "Activated" , True ), - ("mode" , "pyLoad + plugins;plugins only", "Check updates for" , "pyLoad + plugins"), - ("interval" , "int" , "Check interval in hours" , 8 ), - ("autorestart" , "bool" , "Automatically restart pyLoad when required" , True ), - ("reloadplugins", "bool" , "Monitor plugins for code changes in debug mode", True ), - ("nodebugupdate", "bool" , "Don't check for updates in debug mode" , False )] + __config__ = [("activated" , "bool", "Activated" , True ), + ("checkinterval", "int" , "Check interval in hours" , 8 ), + ("autorestart" , "bool", "Auto-restart pyLoad when required" , True ), + ("checkonstart" , "bool", "Check for updates on startup" , True ), + ("checkperiod" , "bool", "Check for updates periodically" , True ), + ("reloadplugins", "bool", "Monitor plugin code changes in debug mode", True ), + ("nodebugupdate", "bool", "Don't update plugins in debug mode" , False)] __description__ = """ Check for updates """ __license__ = "GPLv3" __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - # event_list = ["pluginConfigChanged"] + interval = 0 SERVER_URL = "http://updatemanager.pyload.org" - VERSION = re.compile(r'__version__.*=.*("|\')([\d.]+)') MIN_CHECK_INTERVAL = 3 * 60 * 60 #: 3 hours - def pluginConfigChanged(self, plugin, name, value): - if name == "interval": - interval = value * 60 * 60 - if self.MIN_CHECK_INTERVAL <= interval != self.interval: - # self.core.scheduler.removeJob(self.cb) - self.interval = interval - self.initPeriodical() - else: - self.logDebug("Invalid interval value, kept current") - - elif name == "reloadplugins": - if self.cb2: - self.core.scheduler.removeJob(self.cb2) - 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) + if self.checkonstart: + self.update() - - def unload(self): - self.pluginConfigChanged(self.__name__, "reloadplugins", False) + self.initPeriodical() def setup(self): - self.cb2 = None - self.interval = self.MIN_CHECK_INTERVAL - self.updating = False - self.info = {'pyload': False, 'version': None, 'plugins': False} + self.interval = 10 + self.info = {'pyload': False, 'version': None, 'plugins': False, 'last_check': time.time()} self.mtimes = {} #: store modification time for each plugin + if self.getConfig('checkonstart'): + self.core.api.pauseServer() + self.checkonstart = True + else: + self.checkonstart = False - def periodical2(self): - if not self.updating: - self.autoreloadPlugins() - self.cb2 = self.core.scheduler.addJob(4, self.periodical2, threaded=False) + def periodical(self): + if self.core.debug: + if self.getConfig('reloadplugins'): + self.autoreloadPlugins() + + if self.getConfig('nodebugupdate'): + return + + if self.getConfig('checkperiod') \ + and time.time() - max(self.MIN_CHECK_INTERVAL, self.getConfig('checkinterval') * 60 * 60) > self.info['last_check']: + self.update() @Expose @@ -121,11 +112,6 @@ 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_response(self): try: return getURL(self.SERVER_URL, get={'v': self.core.api.getServerVersion()}).splitlines() @@ -134,95 +120,92 @@ class UpdateManager(Hook): self.logWarning(_("Unable to contact server to get updates")) + @Expose @threaded - def updateThread(self): - self.core.api.pauseServer() - self.updating = True + def update(self): + """ check for updates """ - status = self.update(onlyplugin=self.getConfig('mode') == "plugins only") + self.core.api.pauseServer() - if status is 2 and self.getConfig('autorestart'): + if self._update() is 2 and self.getConfig('autorestart'): self.core.api.restart() else: - self.updating = False self.core.api.unpauseServer() - @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 """ + def _update(self): data = self.server_response() + self.info['last_check'] = time.time() + if not data: exitcode = 0 elif data[0] == "None": self.logInfo(_("No new pyLoad version available")) - updates = data[1:] - exitcode = self._updatePlugins(updates) + exitcode = self._updatePlugins(data[1:]) elif onlyplugin: exitcode = 0 else: - newversion = data[0] - self.logInfo(_("*** New pyLoad Version %s available ***") % newversion) + self.logInfo(_("*** New pyLoad Version %s available ***") % data[0]) self.logInfo(_("*** Get it here: https://github.com/pyload/pyload/releases ***")) + self.info['pyload'] = True + self.info['version'] = data[0] exitcode = 3 - self.info['pyload'] = True - 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 + # Exit codes: + # -1 = No plugin updated, new pyLoad version available + # 0 = No plugin updated + # 1 = Plugins updated + # 2 = Plugins updated, but restart required + return exitcode - def _updatePlugins(self, updates): + def _updatePlugins(self, data): """ check for plugin updates """ - if self.info['plugins']: - return False #: plugins were already updated - exitcode = 0 updated = [] - url = updates[0] - schema = updates[1].split('|') + url = data[0] + schema = data[1].split('|') - if "BLACKLIST" in updates: - blacklist = updates[updates.index('BLACKLIST') + 1:] - updates = updates[2:updates.index('BLACKLIST')] + VERSION = re.compile(r'__version__.*=.*("|\')([\d.]+)') + + if "BLACKLIST" in data: + blacklist = data[data.index('BLACKLIST') + 1:] + updatelist = data[2:data.index('BLACKLIST')] else: - blacklist = None - updates = updates[2:] + blacklist = [] + updatelist = data[2:] - upgradable = [dict(zip(schema, x.split('|'))) for x in updates] - blacklisted = [(x.split('|')[0], x.split('|')[1].rsplit('.', 1)[0]) for x in blacklist] if blacklist else [] + updatelist = [dict(zip(schema, x.split('|'))) for x in updatelist] + blacklist = [dict(zip(schema, x.split('|'))) for x in blacklist] if blacklist: + type_plugins = [(plugin['type'], plugin['name'].rsplit('.', 1)[0]) for plugin in blacklist] + # Protect UpdateManager from self-removing try: - blacklisted.remove(("hook", "UpdateManager")) + type_plugins.remove(("hook", "UpdateManager")) except ValueError: pass - for t, n in blacklisted: - for idx, plugin in enumerate(upgradable): + for t, n in type_plugins: + for idx, plugin in enumerate(updatelist): if n == plugin['name'] and t == plugin['type']: - upgradable.pop(idx) + updatelist.pop(idx) break - for t, n in self.removePlugins(sorted(blacklisted)): + for t, n in self.removePlugins(sorted(type_plugins)): self.logInfo(_("Removed blacklisted plugin: [%(type)s] %(name)s") % { 'type': t, 'name': n, }) - for plugin in sorted(upgradable, key=itemgetter("type", "name")): + for plugin in sorted(updatelist, key=itemgetter("type", "name")): filename = plugin['name'] prefix = plugin['type'] version = plugin['version'] @@ -256,7 +239,7 @@ class UpdateManager(Hook): 'newver': newver}) try: content = getURL(url % plugin) - m = self.VERSION.search(content) + m = VERSION.search(content) if m and m.group(2) == version: with open(save_join("userplugins", prefix, filename), "wb") as f: @@ -267,15 +250,15 @@ class UpdateManager(Hook): raise Exception, _("Version mismatch") except Exception, e: - self.logError(_("Error updating plugin: %s") % filename, str(e)) + self.logError(_("Error updating plugin: %s") % filename, e) if updated: - reloaded = self.core.pluginManager.reloadPlugins(updated) - if reloaded: - self.logInfo(_("Plugins updated and reloaded")) + self.logInfo(_("*** Plugins updated ***")) + + if self.core.pluginManager.reloadPlugins(updated): exitcode = 1 else: - self.logInfo(_("*** Plugins have been updated, but need a pyLoad restart to be reloaded ***")) + self.logWarning(_("pyLoad restart required to reload the updated plugins")) self.info['plugins'] = True exitcode = 2 @@ -283,7 +266,11 @@ class UpdateManager(Hook): else: self.logInfo(_("No plugin updates available")) - return exitcode #: 0 = No plugins updated; 1 = Plugins updated; 2 = Plugins updated, but restart required + # Exit codes: + # 0 = No plugin updated + # 1 = Plugins updated + # 2 = Plugins updated, but restart required + return exitcode @Expose -- cgit v1.2.3 From f1ce338ed31e49373cea5453a2fbdb6c686ca510 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Thu, 26 Mar 2015 10:16:04 +0100 Subject: interval code cosmetics --- module/plugins/hooks/AndroidPhoneNotify.py | 6 +----- module/plugins/hooks/AntiVirus.py | 4 +--- module/plugins/hooks/BypassCaptcha.py | 7 ++----- module/plugins/hooks/Captcha9Kw.py | 7 ++----- module/plugins/hooks/CaptchaBrotherhood.py | 7 ++----- module/plugins/hooks/Checksum.py | 20 ++++++++------------ module/plugins/hooks/ClickAndLoad.py | 4 +--- module/plugins/hooks/DeathByCaptcha.py | 7 ++----- module/plugins/hooks/DownloadScheduler.py | 4 +--- module/plugins/hooks/ExpertDecoders.py | 7 ++----- module/plugins/hooks/ExternalScripts.py | 6 +----- module/plugins/hooks/IRCInterface.py | 8 +++----- module/plugins/hooks/ImageTyperz.py | 7 ++----- module/plugins/hooks/JustPremium.py | 6 +----- module/plugins/hooks/MergeFiles.py | 7 ++----- module/plugins/hooks/MultiHome.py | 4 +--- module/plugins/hooks/RestartSlow.py | 5 +---- module/plugins/hooks/SkipRev.py | 4 +--- module/plugins/hooks/UnSkipOnFail.py | 5 ++--- module/plugins/hooks/WindowsPhoneNotify.py | 6 +----- module/plugins/hooks/XFileSharingPro.py | 6 +----- 21 files changed, 38 insertions(+), 99 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/AndroidPhoneNotify.py b/module/plugins/hooks/AndroidPhoneNotify.py index 55ba3e73d..67a0ea4f0 100644 --- a/module/plugins/hooks/AndroidPhoneNotify.py +++ b/module/plugins/hooks/AndroidPhoneNotify.py @@ -28,11 +28,7 @@ class AndroidPhoneNotify(Hook): event_list = ["allDownloadsProcessed", "plugin_updated"] - - - #@TODO: Remove in 0.4.10 - def initPeriodical(self): - pass + interval = 0 #@TODO: Remove in 0.4.10 def setup(self): diff --git a/module/plugins/hooks/AntiVirus.py b/module/plugins/hooks/AntiVirus.py index 6f88b982a..cc3c5c754 100644 --- a/module/plugins/hooks/AntiVirus.py +++ b/module/plugins/hooks/AntiVirus.py @@ -26,9 +26,7 @@ class AntiVirus(Hook): __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - #@TODO: Remove in 0.4.10 - def initPeriodical(self): - pass + interval = 0 #@TODO: Remove in 0.4.10 def setup(self): diff --git a/module/plugins/hooks/BypassCaptcha.py b/module/plugins/hooks/BypassCaptcha.py index d7995650b..3c8f72524 100644 --- a/module/plugins/hooks/BypassCaptcha.py +++ b/module/plugins/hooks/BypassCaptcha.py @@ -40,6 +40,8 @@ class BypassCaptcha(Hook): ("zoidberg" , "zoidberg@mujmail.cz" )] + interval = 0 #@TODO: Remove in 0.4.10 + PYLOAD_KEY = "4f771155b640970d5607f919a615bdefc67e7d32" SUBMIT_URL = "http://bypasscaptcha.com/upload.php" @@ -47,11 +49,6 @@ class BypassCaptcha(Hook): GETCREDITS_URL = "http://bypasscaptcha.com/ex_left.php" - #@TODO: Remove in 0.4.10 - def initPeriodical(self): - pass - - def setup(self): self.info = {} #@TODO: Remove in 0.4.10 diff --git a/module/plugins/hooks/Captcha9Kw.py b/module/plugins/hooks/Captcha9Kw.py index 825db510b..60482b8fc 100644 --- a/module/plugins/hooks/Captcha9Kw.py +++ b/module/plugins/hooks/Captcha9Kw.py @@ -36,12 +36,9 @@ class Captcha9Kw(Hook): ("Walter Purcaro", "vuolter@gmail.com")] - API_URL = "http://www.9kw.eu/index.cgi" - + interval = 0 #@TODO: Remove in 0.4.10 - #@TODO: Remove in 0.4.10 - def initPeriodical(self): - pass + API_URL = "http://www.9kw.eu/index.cgi" def setup(self): diff --git a/module/plugins/hooks/CaptchaBrotherhood.py b/module/plugins/hooks/CaptchaBrotherhood.py index 161f2805b..e5285a493 100644 --- a/module/plugins/hooks/CaptchaBrotherhood.py +++ b/module/plugins/hooks/CaptchaBrotherhood.py @@ -50,12 +50,9 @@ class CaptchaBrotherhood(Hook): ("zoidberg", "zoidberg@mujmail.cz")] - API_URL = "http://www.captchabrotherhood.com/" - + interval = 0 #@TODO: Remove in 0.4.10 - #@TODO: Remove in 0.4.10 - def initPeriodical(self): - pass + API_URL = "http://www.captchabrotherhood.com/" def setup(self): diff --git a/module/plugins/hooks/Checksum.py b/module/plugins/hooks/Checksum.py index 42a4ca236..4ad17f55a 100644 --- a/module/plugins/hooks/Checksum.py +++ b/module/plugins/hooks/Checksum.py @@ -55,18 +55,14 @@ class Checksum(Hook): ("stickell" , "l.stickell@yahoo.it")] - methods = {'sfv' : 'crc32', - 'crc' : 'crc32', - 'hash': 'md5'} - regexps = {'sfv' : r'^(?P<NAME>[^;].+)\s+(?P<HASH>[0-9A-Fa-f]{8})$', - 'md5' : r'^(?P<NAME>[0-9A-Fa-f]{32}) (?P<FILE>.+)$', - 'crc' : r'filename=(?P<NAME>.+)\nsize=(?P<SIZE>\d+)\ncrc32=(?P<HASH>[0-9A-Fa-f]{8})$', - 'default': r'^(?P<HASH>[0-9A-Fa-f]+)\s+\*?(?P<NAME>.+)$'} - - - #@TODO: Remove in 0.4.10 - def initPeriodical(self): - pass + interval = 0 #@TODO: Remove in 0.4.10 + methods = {'sfv' : 'crc32', + 'crc' : 'crc32', + 'hash': 'md5'} + regexps = {'sfv' : r'^(?P<NAME>[^;].+)\s+(?P<HASH>[0-9A-Fa-f]{8})$', + 'md5' : r'^(?P<NAME>[0-9A-Fa-f]{32}) (?P<FILE>.+)$', + 'crc' : r'filename=(?P<NAME>.+)\nsize=(?P<SIZE>\d+)\ncrc32=(?P<HASH>[0-9A-Fa-f]{8})$', + 'default': r'^(?P<HASH>[0-9A-Fa-f]+)\s+\*?(?P<NAME>.+)$'} def coreReady(self): diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 0564e31ca..2ddd66daa 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -36,9 +36,7 @@ class ClickAndLoad(Hook): ("Walter Purcaro", "vuolter@gmail.com")] - #@TODO: Remove in 0.4.10 - def initPeriodical(self): - pass + interval = 0 #@TODO: Remove in 0.4.10 def setup(self): diff --git a/module/plugins/hooks/DeathByCaptcha.py b/module/plugins/hooks/DeathByCaptcha.py index e408dcab7..501de0c1a 100644 --- a/module/plugins/hooks/DeathByCaptcha.py +++ b/module/plugins/hooks/DeathByCaptcha.py @@ -63,12 +63,9 @@ class DeathByCaptcha(Hook): ("zoidberg", "zoidberg@mujmail.cz")] - API_URL = "http://api.dbcapi.me/api/" - + interval = 0 #@TODO: Remove in 0.4.10 - #@TODO: Remove in 0.4.10 - def initPeriodical(self): - pass + API_URL = "http://api.dbcapi.me/api/" def setup(self): diff --git a/module/plugins/hooks/DownloadScheduler.py b/module/plugins/hooks/DownloadScheduler.py index 5f9388b57..9c74ac1d4 100644 --- a/module/plugins/hooks/DownloadScheduler.py +++ b/module/plugins/hooks/DownloadScheduler.py @@ -21,9 +21,7 @@ class DownloadScheduler(Hook): ("stickell", "l.stickell@yahoo.it")] - #@TODO: Remove in 0.4.10 - def initPeriodical(self): - pass + interval = 0 #@TODO: Remove in 0.4.10 def setup(self): diff --git a/module/plugins/hooks/ExpertDecoders.py b/module/plugins/hooks/ExpertDecoders.py index fa1c7a14b..79e98c020 100644 --- a/module/plugins/hooks/ExpertDecoders.py +++ b/module/plugins/hooks/ExpertDecoders.py @@ -25,12 +25,9 @@ class ExpertDecoders(Hook): ("zoidberg", "zoidberg@mujmail.cz")] - API_URL = "http://www.fasttypers.org/imagepost.ashx" - + interval = 0 #@TODO: Remove in 0.4.10 - #@TODO: Remove in 0.4.10 - def initPeriodical(self): - pass + API_URL = "http://www.fasttypers.org/imagepost.ashx" def setup(self): diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index 8f6c405fd..8ab7af55c 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -28,11 +28,7 @@ class ExternalScripts(Hook): "all_archives_extracted", "all_archives_processed", "allDownloadsFinished" , "allDownloadsProcessed" , "packageDeleted"] - - - #@TODO: Remove in 0.4.10 - def initPeriodical(self): - pass + interval = 0 #@TODO: Remove in 0.4.10 def setup(self): diff --git a/module/plugins/hooks/IRCInterface.py b/module/plugins/hooks/IRCInterface.py index 7032c6592..d76b9cb85 100644 --- a/module/plugins/hooks/IRCInterface.py +++ b/module/plugins/hooks/IRCInterface.py @@ -37,17 +37,15 @@ class IRCInterface(Thread, Hook): __authors__ = [("Jeix", "Jeix@hasnomail.com")] + interval = 0 #@TODO: Remove in 0.4.10 + + def __init__(self, core, manager): Thread.__init__(self) Hook.__init__(self, core, manager) self.setDaemon(True) - #@TODO: Remove in 0.4.10 - def initPeriodical(self): - pass - - def coreReady(self): self.abort = False self.more = [] diff --git a/module/plugins/hooks/ImageTyperz.py b/module/plugins/hooks/ImageTyperz.py index 2cf611b9f..132ab2e02 100644 --- a/module/plugins/hooks/ImageTyperz.py +++ b/module/plugins/hooks/ImageTyperz.py @@ -44,16 +44,13 @@ class ImageTyperz(Hook): ("zoidberg", "zoidberg@mujmail.cz")] + interval = 0 #@TODO: Remove in 0.4.10 + SUBMIT_URL = "http://captchatypers.com/Forms/UploadFileAndGetTextNEW.ashx" RESPOND_URL = "http://captchatypers.com/Forms/SetBadImage.ashx" GETCREDITS_URL = "http://captchatypers.com/Forms/RequestBalance.ashx" - #@TODO: Remove in 0.4.10 - def initPeriodical(self): - pass - - def setup(self): self.info = {} #@TODO: Remove in 0.4.10 diff --git a/module/plugins/hooks/JustPremium.py b/module/plugins/hooks/JustPremium.py index b82af3e78..d18afc524 100644 --- a/module/plugins/hooks/JustPremium.py +++ b/module/plugins/hooks/JustPremium.py @@ -21,11 +21,7 @@ class JustPremium(Hook): event_list = ["linksAdded"] - - - #@TODO: Remove in 0.4.10 - def initPeriodical(self): - pass + interval = 0 #@TODO: Remove in 0.4.10 def setup(self): diff --git a/module/plugins/hooks/MergeFiles.py b/module/plugins/hooks/MergeFiles.py index 74bcbe3c1..2900b0d29 100644 --- a/module/plugins/hooks/MergeFiles.py +++ b/module/plugins/hooks/MergeFiles.py @@ -23,12 +23,9 @@ class MergeFiles(Hook): __authors__ = [("and9000", "me@has-no-mail.com")] - BUFFER_SIZE = 4096 - + interval = 0 #@TODO: Remove in 0.4.10 - #@TODO: Remove in 0.4.10 - def initPeriodical(self): - pass + BUFFER_SIZE = 4096 def setup(self): diff --git a/module/plugins/hooks/MultiHome.py b/module/plugins/hooks/MultiHome.py index 94c671340..a26d139c0 100644 --- a/module/plugins/hooks/MultiHome.py +++ b/module/plugins/hooks/MultiHome.py @@ -17,9 +17,7 @@ class MultiHome(Hook): __authors__ = [("mkaay", "mkaay@mkaay.de")] - #@TODO: Remove in 0.4.10 - def initPeriodical(self): - pass + interval = 0 #@TODO: Remove in 0.4.10 def setup(self): diff --git a/module/plugins/hooks/RestartSlow.py b/module/plugins/hooks/RestartSlow.py index 834128489..db535b3d1 100644 --- a/module/plugins/hooks/RestartSlow.py +++ b/module/plugins/hooks/RestartSlow.py @@ -22,16 +22,13 @@ class RestartSlow(Hook): event_list = ["downloadStarts"] + interval = 0 #@TODO: Remove in 0.4.10 def setup(self): self.info = {'chunk': {}} - def initPeriodical(self): - pass - - def periodical(self): if not self.pyfile.plugin.req.dl: return diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py index 9109d4f80..157b55bbd 100644 --- a/module/plugins/hooks/SkipRev.py +++ b/module/plugins/hooks/SkipRev.py @@ -24,9 +24,7 @@ class SkipRev(Hook): __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - #@TODO: Remove in 0.4.10 - def initPeriodical(self): - pass + interval = 0 #@TODO: Remove in 0.4.10 def setup(self): diff --git a/module/plugins/hooks/UnSkipOnFail.py b/module/plugins/hooks/UnSkipOnFail.py index f1f2288fe..ebd370a0f 100644 --- a/module/plugins/hooks/UnSkipOnFail.py +++ b/module/plugins/hooks/UnSkipOnFail.py @@ -16,9 +16,8 @@ class UnSkipOnFail(Hook): __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - #@TODO: Remove in 0.4.10 - def initPeriodical(self): - pass + interval = 0 #@TODO: Remove in 0.4.10 + def setup(self): self.info = {} #@TODO: Remove in 0.4.10 diff --git a/module/plugins/hooks/WindowsPhoneNotify.py b/module/plugins/hooks/WindowsPhoneNotify.py index d8215f9fe..e61057f9f 100644 --- a/module/plugins/hooks/WindowsPhoneNotify.py +++ b/module/plugins/hooks/WindowsPhoneNotify.py @@ -29,11 +29,7 @@ class WindowsPhoneNotify(Hook): event_list = ["allDownloadsProcessed", "plugin_updated"] - - - #@TODO: Remove in 0.4.10 - def initPeriodical(self): - pass + interval = 0 #@TODO: Remove in 0.4.10 def setup(self): diff --git a/module/plugins/hooks/XFileSharingPro.py b/module/plugins/hooks/XFileSharingPro.py index b7b5eed73..4f8b0a846 100644 --- a/module/plugins/hooks/XFileSharingPro.py +++ b/module/plugins/hooks/XFileSharingPro.py @@ -23,6 +23,7 @@ class XFileSharingPro(Hook): # event_list = ["pluginConfigChanged"] + interval = 0 #@TODO: Remove in 0.4.10 regexp = {'hoster' : (r'https?://(?:www\.)?(?P<DOMAIN>[\w\-.^_]{3,63}(?:\.[a-zA-Z]{2,})(?:\:\d+)?)/(?:embed-)?\w{12}(?:\W|$)', r'https?://(?:[^/]+\.)?(?P<DOMAIN>%s)/(?:embed-)?\w+'), 'crypter': (r'https?://(?:www\.)?(?P<DOMAIN>[\w\-.^_]{3,63}(?:\.[a-zA-Z]{2,})(?:\:\d+)?)/(?:user|folder)s?/\w+', @@ -45,11 +46,6 @@ class XFileSharingPro(Hook): # self.loadPattern() - #@TODO: Remove in 0.4.10 - def initPeriodical(self): - pass - - def setup(self): self.info = {} #@TODO: Remove in 0.4.10 -- cgit v1.2.3 From 329293e0bb0cf4008688d8c73d4b98caa7082141 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Thu, 26 Mar 2015 10:40:32 +0100 Subject: [Extractor] Rename method 'test' to 'verify' --- module/plugins/hooks/ExtractArchive.py | 61 +++++++++++++++++----------------- 1 file changed, 30 insertions(+), 31 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 5d71e89ec..c5f842fdd 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -106,24 +106,24 @@ class ArchiveQueue(object): class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.37" - - __config__ = [("activated" , "bool" , "Activated" , True ), - ("fullpath" , "bool" , "Extract with full paths" , True ), - ("overwrite" , "bool" , "Overwrite files" , False ), - ("keepbroken" , "bool" , "Try to extract broken archives" , False ), - ("repair" , "bool" , "Repair broken archives (RAR required)" , False ), - ("test" , "bool" , "Test archive before extracting" , False ), - ("usepasswordfile", "bool" , "Use password file" , True ), - ("passwordfile" , "file" , "Password file" , "archive_password.txt" ), - ("delete" , "No;Permanent;Trash" , "Delete archive after extraction" , "No" ), - ("subfolder" , "bool" , "Create subfolder for each package" , False ), - ("destination" , "folder" , "Extract files to folder" , "" ), - ("extensions" , "str" , "Extract archives ending with extension", "7z,bz2,bzip2,gz,gzip,lha,lzh,lzma,rar,tar,taz,tbz,tbz2,tgz,xar,xz,z,zip"), - ("excludefiles" , "str" , "Don't extract the following files" , "*.nfo,*.DS_Store,index.dat,thumb.db" ), - ("recursive" , "bool" , "Extract archives in archives" , True ), - ("waitall" , "bool" , "Run after all downloads was processed" , False ), - ("renice" , "int" , "CPU priority" , 0 )] + __version__ = "1.38" + + __config__ = [("activated" , "bool" , "Activated" , True ), + ("fullpath" , "bool" , "Extract with full paths" , True ), + ("overwrite" , "bool" , "Overwrite files" , False ), + ("keepbroken" , "bool" , "Try to extract broken archives" , False ), + ("repair" , "bool" , "Repair broken archives (RAR required)" , False ), + ("test" , "bool" , "Test archive before extracting" , False ), + ("usepasswordfile", "bool" , "Use password file" , True ), + ("passwordfile" , "file" , "Password file" , "archive_password.txt" ), + ("delete" , "No;Permanent;Trash", "Delete archive after extraction" , "No" ), + ("subfolder" , "bool" , "Create subfolder for each package" , False ), + ("destination" , "folder" , "Extract files to folder" , "" ), + ("extensions" , "str" , "Extract archives ending with extension", "7z,bz2,bzip2,gz,gzip,lha,lzh,lzma,rar,tar,taz,tbz,tbz2,tgz,xar,xz,z,zip"), + ("excludefiles" , "str" , "Don't extract the following files" , "*.nfo,*.DS_Store,index.dat,thumb.db" ), + ("recursive" , "bool" , "Extract archives in archives" , True ), + ("waitall" , "bool" , "Run after all downloads was processed" , False ), + ("renice" , "int" , "CPU priority" , 0 )] __description__ = """Extract different kind of archives""" __license__ = "GPLv3" @@ -235,14 +235,14 @@ class ExtractArchive(Hook): toList = lambda string: string.replace(' ', '').replace(',', '|').replace(';', '|').split('|') - destination = self.getConfig('destination') - subfolder = self.getConfig('subfolder') - fullpath = self.getConfig('fullpath') - overwrite = self.getConfig('overwrite') - renice = self.getConfig('renice') - recursive = self.getConfig('recursive') - delete = self.getConfig('delete') - keepbroken = self.getConfig('keepbroken') + destination = self.getConfig('destination') + subfolder = self.getConfig('subfolder') + fullpath = self.getConfig('fullpath') + overwrite = self.getConfig('overwrite') + renice = self.getConfig('renice') + recursive = self.getConfig('recursive') + delete = self.getConfig('delete') + keepbroken = self.getConfig('keepbroken') extensions = [x.lstrip('.').lower() for x in toList(self.getConfig('extensions'))] excludefiles = toList(self.getConfig('excludefiles')) @@ -253,8 +253,7 @@ class ExtractArchive(Hook): # reload from txt file self.reloadPasswords() - # dl folder - dl = self.config['general']['download_folder'] + download_folder = self.config['general']['download_folder'] # iterate packages -> extractors -> targets for pid in ids: @@ -267,7 +266,7 @@ class ExtractArchive(Hook): self.logInfo(_("Check package: %s") % pypack.name) # determine output folder - out = save_join(dl, pypack.folder, destination, "") #: force trailing slash + out = save_join(download_folder, pypack.folder, destination, "") #: force trailing slash if subfolder: out = save_join(out, pypack.folder) @@ -277,7 +276,7 @@ class ExtractArchive(Hook): matched = False success = True - files_ids = dict((pylink['name'],((save_join(dl, pypack.folder, pylink['name'])), pylink['id'], out)) for pylink \ + files_ids = dict((pylink['name'],((save_join(download_folder, pypack.folder, pylink['name'])), pylink['id'], out)) for pylink \ in sorted(pypack.getChildren().itervalues(), key=lambda k: k['name'])).values() #: remove duplicates # check as long there are unseen files @@ -390,7 +389,7 @@ class ExtractArchive(Hook): if pw: self.logDebug("Testing with password: %s" % pw) pyfile.setProgress(0) - archive.test(pw) + archive.verify(pw) pyfile.setProgress(100) else: archive.check(pw) -- cgit v1.2.3 From 589121e80835c63aea0880a53c6678de5c31c16e Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Sat, 28 Mar 2015 01:59:01 +0100 Subject: Spare code cosmetics --- module/plugins/hooks/DeleteFinished.py | 5 ++--- module/plugins/hooks/ExtractArchive.py | 2 +- module/plugins/hooks/MultishareCz.py | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/DeleteFinished.py b/module/plugins/hooks/DeleteFinished.py index 75cb33e96..bde4ca259 100644 --- a/module/plugins/hooks/DeleteFinished.py +++ b/module/plugins/hooks/DeleteFinished.py @@ -9,9 +9,8 @@ class DeleteFinished(Hook): __type__ = "hook" __version__ = "1.12" - __config__ = [("activated" , "bool", "Activated" , "False"), - ("interval" , "int" , "Delete every (hours)" , "72" ), - ("deloffline", "bool", "Delete packages with offline links", "False")] + __config__ = [("interval" , "int" , "Check interval in hours" , 72 ), + ("deloffline", "bool", "Delete package with offline links", False)] __description__ = """Automatically delete all finished packages from queue""" __license__ = "GPLv3" diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index c5f842fdd..8c40667c2 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -175,7 +175,7 @@ class ExtractArchive(Hook): print_exc() if self.extractors: - self.logInfo(_("Activated") + " " + "|".join("%s %s" % (Extractor.__name__,Extractor.VERSION) for Extractor in self.extractors)) + self.logInfo(_("Activated") + " " + "|".join("%s %s" % (Extractor.__name__, Extractor.VERSION) for Extractor in self.extractors)) self.extractQueued() #: Resume unfinished extractions else: self.logInfo(_("No Extract plugins activated")) diff --git a/module/plugins/hooks/MultishareCz.py b/module/plugins/hooks/MultishareCz.py index e696d3fef..6ead88c34 100644 --- a/module/plugins/hooks/MultishareCz.py +++ b/module/plugins/hooks/MultishareCz.py @@ -21,7 +21,7 @@ class MultishareCz(MultiHook): __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] - HOSTER_PATTERN = r'<img class="logo-shareserveru"[^>]*?alt="([^"]+)"></td>\s*<td class="stav">[^>]*?alt="OK"' + HOSTER_PATTERN = r'<img class="logo-shareserveru"[^>]*?alt="(.+?)"></td>\s*<td class="stav">[^>]*?alt="OK"' def getHosters(self): -- cgit v1.2.3 From 031cc3a5f5b842698c0323fbec7d7a33f3ca99f8 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Sun, 29 Mar 2015 18:45:11 +0200 Subject: [ExternalScripts] Update --- module/plugins/hooks/ExternalScripts.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index 8ab7af55c..9324e306e 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -10,7 +10,7 @@ from module.utils import fs_encode, save_join class ExternalScripts(Hook): __name__ = "ExternalScripts" __type__ = "hook" - __version__ = "0.37" + __version__ = "0.38" __config__ = [("activated", "bool", "Activated" , True ), ("waitend" , "bool", "Wait script ending", False)] @@ -120,7 +120,7 @@ class ExternalScripts(Hook): def downloadPreparing(self, pyfile): for script in self.scripts['download_preparing']: - self.callScript(script, pyfile.id, pyfile.name, pyfile.pluginname, pyfile.url, None) + self.callScript(script, pyfile.id, pyfile.name, None, pyfile.pluginname, pyfile.url) def downloadFailed(self, pyfile): @@ -131,7 +131,7 @@ class ExternalScripts(Hook): for script in self.scripts['download_failed']: file = save_join(download_folder, pyfile.name) - self.callScript(script, pyfile.id, pyfile.name, pyfile.pluginname, pyfile.url, file) + self.callScript(script, pyfile.id, pyfile.name, file, pyfile.pluginname, pyfile.url) def downloadFinished(self, pyfile): @@ -142,17 +142,17 @@ class ExternalScripts(Hook): for script in self.scripts['download_finished']: file = save_join(download_folder, pyfile.name) - self.callScript(script, pyfile.id, pyfile.name, pyfile.pluginname, pyfile.url, file) + self.callScript(script, pyfile.id, pyfile.name, file, pyfile.pluginname, pyfile.url) def archive_extract_failed(self, pyfile, archive): for script in self.scripts['archive_extract_failed']: - self.callScript(script, pyfile.id, pyfile.name, archive.out, archive.filename, archive.files) + self.callScript(script, pyfile.id, pyfile.name, archive.filename, archive.out, archive.files) def archive_extracted(self, pyfile, archive): for script in self.scripts['archive_extracted']: - self.callScript(script, pyfile.id, pyfile.name, archive.out, archive.filename, archive.files) + self.callScript(script, pyfile.id, pyfile.name, archive.filename, archive.out, archive.files) def packageFinished(self, pypack): @@ -162,7 +162,7 @@ class ExternalScripts(Hook): download_folder = self.config['general']['download_folder'] for script in self.scripts['package_finished']: - self.callScript(script, pypack.id, pypack.name, download_folder) + self.callScript(script, pypack.id, pypack.name, download_folder, pypack.password) def packageDeleted(self, pid): @@ -174,7 +174,7 @@ class ExternalScripts(Hook): download_folder = self.config['general']['download_folder'] for script in self.scripts['package_deleted']: - self.callScript(script, pack.id, pack.name, download_folder) + self.callScript(script, pack.id, pack.name, download_folder, pack.password) def package_extract_failed(self, pypack): @@ -184,7 +184,7 @@ class ExternalScripts(Hook): download_folder = self.config['general']['download_folder'] for script in self.scripts['package_extract_failed']: - self.callScript(script, pypack.id, pypack.name, download_folder) + self.callScript(script, pypack.id, pypack.name, download_folder, pypack.password) def package_extracted(self, pypack): -- cgit v1.2.3 From ec093a83368aeb80691e08b5cb86e87352d5ad60 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Fri, 3 Apr 2015 14:24:14 +0200 Subject: [ExternalScripts] Fix https://github.com/pyload/pyload/issues/1307 --- module/plugins/hooks/ExternalScripts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index 9324e306e..be0857009 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -10,7 +10,7 @@ from module.utils import fs_encode, save_join class ExternalScripts(Hook): __name__ = "ExternalScripts" __type__ = "hook" - __version__ = "0.38" + __version__ = "0.39" __config__ = [("activated", "bool", "Activated" , True ), ("waitend" , "bool", "Wait script ending", False)] -- cgit v1.2.3 From e948054ea4eb6bbba8091482cca52fd2454322a5 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Tue, 7 Apr 2015 19:30:29 +0200 Subject: New plugin: UserAgentSwitcher Fix https://github.com/pyload/pyload/issues/1305 --- module/plugins/hooks/UserAgentSwitcher.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 module/plugins/hooks/UserAgentSwitcher.py (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/UserAgentSwitcher.py b/module/plugins/hooks/UserAgentSwitcher.py new file mode 100644 index 000000000..56c605bac --- /dev/null +++ b/module/plugins/hooks/UserAgentSwitcher.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- + +import pycurl + +from module.plugins.Hook import Hook + + +class UserAgentSwitcher(Hook): + __name__ = "UserAgentSwitcher" + __type__ = "hook" + __version__ = "0.01" + + __config__ = [("ua", "str", "Custom user-agent string", "")] + + __description__ = """Custom user-agent""" + __license__ = "GPLv3" + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] + + + interval = 0 #@TODO: Remove in 0.4.10 + + + def setup(self): + self.info = {} #@TODO: Remove in 0.4.10 + + + def downloadPreparing(self, pyfile): + ua = self.getConfig('ua') + if ua: + self.logDebug("Use custom user-agent string: " + ua) + pyfile.plugin.req.http.c.setopt(pycurl.USERAGENT, ua) -- cgit v1.2.3 From 0d2ae48fae0abb4274e477f54235d4f389b5e6b2 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Tue, 7 Apr 2015 19:36:10 +0200 Subject: [AntiVirus] Recycle bin support --- module/plugins/hooks/AntiVirus.py | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/AntiVirus.py b/module/plugins/hooks/AntiVirus.py index cc3c5c754..f94d8d205 100644 --- a/module/plugins/hooks/AntiVirus.py +++ b/module/plugins/hooks/AntiVirus.py @@ -11,15 +11,16 @@ from module.utils import fs_encode, save_join class AntiVirus(Hook): __name__ = "AntiVirus" __type__ = "hook" - __version__ = "0.05" + __version__ = "0.06" #@TODO: add trash option (use Send2Trash lib) - __config__ = [("action" , "Antivirus default;Delete;Quarantine", "Manage infected files" , "Antivirus default"), - ("quardir" , "folder" , "Quarantine folder" , "" ), - ("scanfailed", "bool" , "Scan incompleted files (failed downloads)", False ), - ("cmdfile" , "file" , "Antivirus executable" , "" ), - ("cmdargs" , "str" , "Scan options" , "" ), - ("ignore-err", "bool" , "Ignore scan errors" , False )] + __config__ = [("action" , "Antivirus default;Delete;Quarantine", "Manage infected files" , "Antivirus default"), + ("quardir" , "folder" , "Quarantine folder" , "" ), + ("deltotrash", "bool" , "Move to trash (recycle bin) instead delete", True ), + ("scanfailed", "bool" , "Scan incompleted files (failed downloads)" , False ), + ("cmdfile" , "file" , "Antivirus executable" , "" ), + ("cmdargs" , "str" , "Scan options" , "" ), + ("ignore-err", "bool" , "Ignore scan errors" , False )] __description__ = """Scan downloaded files with antivirus program""" __license__ = "GPLv3" @@ -32,6 +33,16 @@ class AntiVirus(Hook): def setup(self): self.info = {} #@TODO: Remove in 0.4.10 + try: + import send2trash + + except ImportError: + self.logDebug(name, _("Send2Trash lib not found")) + self.trashable = False + + else: + self.trashable = True + @Expose @threaded @@ -46,6 +57,7 @@ class AntiVirus(Hook): thread.addActive(pyfile) pyfile.setCustomStatus(_("virus scanning")) + pyfile.setProgress(0) try: p = subprocess.Popen([cmdfile, cmdargs, file], bufsize=-1, stdout=subprocess.PIPE, stderr=subprocess.PIPE) @@ -66,11 +78,19 @@ class AntiVirus(Hook): action = self.getConfig('action') try: if action == "Delete": - os.remove(file) + if not self.getConfig('deltotrash'): + os.remove(file) + + elif self.trashable: + send2trash.send2trash(file) + + else: + self.logWarning("Unable to move file to trash, move to quarantine instead") + pyfile.setCustomStatus(_("file moving")) + shutil.move(file, self.getConfig('quardir')) elif action == "Quarantine": pyfile.setCustomStatus(_("file moving")) - pyfile.setProgress(0) shutil.move(file, self.getConfig('quardir')) except (IOError, shutil.Error), e: -- cgit v1.2.3 From a01a2dcb91bb2020aa4c7548a52ba98dbe43ceef Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Tue, 7 Apr 2015 21:12:09 +0200 Subject: [ExtractArchive] Improve send2trash feature --- module/plugins/hooks/ExtractArchive.py | 81 ++++++++++++++++++---------------- 1 file changed, 43 insertions(+), 38 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 8c40667c2..8b6a140cd 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -106,24 +106,25 @@ class ArchiveQueue(object): class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.38" - - __config__ = [("activated" , "bool" , "Activated" , True ), - ("fullpath" , "bool" , "Extract with full paths" , True ), - ("overwrite" , "bool" , "Overwrite files" , False ), - ("keepbroken" , "bool" , "Try to extract broken archives" , False ), - ("repair" , "bool" , "Repair broken archives (RAR required)" , False ), - ("test" , "bool" , "Test archive before extracting" , False ), - ("usepasswordfile", "bool" , "Use password file" , True ), - ("passwordfile" , "file" , "Password file" , "archive_password.txt" ), - ("delete" , "No;Permanent;Trash", "Delete archive after extraction" , "No" ), - ("subfolder" , "bool" , "Create subfolder for each package" , False ), - ("destination" , "folder" , "Extract files to folder" , "" ), - ("extensions" , "str" , "Extract archives ending with extension", "7z,bz2,bzip2,gz,gzip,lha,lzh,lzma,rar,tar,taz,tbz,tbz2,tgz,xar,xz,z,zip"), - ("excludefiles" , "str" , "Don't extract the following files" , "*.nfo,*.DS_Store,index.dat,thumb.db" ), - ("recursive" , "bool" , "Extract archives in archives" , True ), - ("waitall" , "bool" , "Run after all downloads was processed" , False ), - ("renice" , "int" , "CPU priority" , 0 )] + __version__ = "1.39" + + __config__ = [("activated" , "bool" , "Activated" , True ), + ("fullpath" , "bool" , "Extract with full paths" , True ), + ("overwrite" , "bool" , "Overwrite files" , False ), + ("keepbroken" , "bool" , "Try to extract broken archives" , False ), + ("repair" , "bool" , "Repair broken archives (RAR required)" , False ), + ("test" , "bool" , "Test archive before extracting" , False ), + ("usepasswordfile", "bool" , "Use password file" , True ), + ("passwordfile" , "file" , "Password file" , "archive_password.txt" ), + ("delete" , "bool" , "Delete archive after extraction" , True ), + ("deltotrash" , "bool" , "Move to trash (recycle bin) instead delete", True ), + ("subfolder" , "bool" , "Create subfolder for each package" , False ), + ("destination" , "folder" , "Extract files to folder" , "" ), + ("extensions" , "str" , "Extract archives ending with extension" , "7z,bz2,bzip2,gz,gzip,lha,lzh,lzma,rar,tar,taz,tbz,tbz2,tgz,xar,xz,z,zip"), + ("excludefiles" , "str" , "Don't extract the following files" , "*.nfo,*.DS_Store,index.dat,thumb.db" ), + ("recursive" , "bool" , "Extract archives in archives" , True ), + ("waitall" , "bool" , "Run after all downloads was processed" , False ), + ("renice" , "int" , "CPU priority" , 0 )] __description__ = """Extract different kind of archives""" __license__ = "GPLv3" @@ -148,7 +149,16 @@ class ExtractArchive(Hook): self.extractors = [] self.passwords = [] self.repair = False - self.trash = False + + try: + import send2trash + + except ImportError: + self.logDebug(name, _("Send2Trash lib not found")) + self.trashable = False + + else: + self.trashable = True def coreReady(self): @@ -321,6 +331,7 @@ class ExtractArchive(Hook): new_files = self._extract(pyfile, archive, pypack.password) finally: + pyfile.setProgress(100) thread.finishFile(pyfile) except Exception, e: @@ -449,31 +460,25 @@ class ExtractArchive(Hook): pyfile.setStatus("processing") delfiles = archive.getDeleteFiles() - if self.core.debug: - self.logDebug("Would delete: %s" % ", ".join(delfiles)) + self.logDebug("Would delete: " + ", ".join(delfiles)) - if self.getConfig('delete') != 'No': - try: - from send2trash import send2trash - if self.getConfig('delete') == "Trash": - self.trash = True - self.logInfo(_("Sending %s files to trash") % len(delfiles)) - except ImportError: - self.logError(name, _("Send2Trash not installed, no files deleted")) - self.trash = False - - if self.getConfig('delete') == "Permanent": - self.trash = False - self.logInfo(_("Deleting %s files") % len(delfiles)) + if self.getConfig('delete'): + self.logInfo(_("Deleting %s files") % len(delfiles)) + deltotrash = self.getConfig('deltotrash') for f in delfiles: file = fs_encode(f) - if os.path.exists(file) and self.trash: - send2trash(file) - elif os.path.exists(file): + if not os.path.exists(file) + continue + + if not deltotrash: os.remove(file) + + elif self.trashable: + send2trash.send2trash(file) + else: - self.logDebug("%s does not exists" % f) + self.logWarning("Unable to move %s to trash" % os.path.basename(f)) self.logInfo(name, _("Extracting finished")) extracted_files = archive.files or archive.list() -- cgit v1.2.3 From 034d87c836f9fba82142a06b5f666c84ca10bd50 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Tue, 7 Apr 2015 21:26:23 +0200 Subject: [YadiSk] Fix https://github.com/pyload/pyload/issues/1321 --- module/plugins/hooks/AntiVirus.py | 2 +- module/plugins/hooks/ExtractArchive.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/AntiVirus.py b/module/plugins/hooks/AntiVirus.py index f94d8d205..78f5aaa23 100644 --- a/module/plugins/hooks/AntiVirus.py +++ b/module/plugins/hooks/AntiVirus.py @@ -85,7 +85,7 @@ class AntiVirus(Hook): send2trash.send2trash(file) else: - self.logWarning("Unable to move file to trash, move to quarantine instead") + self.logWarning(_("Unable to move file to trash, move to quarantine instead")) pyfile.setCustomStatus(_("file moving")) shutil.move(file, self.getConfig('quardir')) diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 8b6a140cd..2f981d06b 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -478,7 +478,7 @@ class ExtractArchive(Hook): send2trash.send2trash(file) else: - self.logWarning("Unable to move %s to trash" % os.path.basename(f)) + self.logWarning(_("Unable to move %s to trash") % os.path.basename(f)) self.logInfo(name, _("Extracting finished")) extracted_files = archive.files or archive.list() -- cgit v1.2.3 From c99421d6385e0f6b8bd9095c705becbc35f873a0 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Tue, 7 Apr 2015 22:08:58 +0200 Subject: Traceback code cosmetics --- module/plugins/hooks/ExtractArchive.py | 8 ++++---- module/plugins/hooks/IRCInterface.py | 4 ++-- module/plugins/hooks/MergeFiles.py | 5 ++--- 3 files changed, 8 insertions(+), 9 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 2f981d06b..595512c12 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -4,9 +4,9 @@ from __future__ import with_statement import os import sys +import traceback from copy import copy -from traceback import print_exc # monkey patch bug in python 2.6 and lower # http://bugs.python.org/issue6122 , http://bugs.python.org/issue1236 , http://bugs.python.org/issue1731717 @@ -177,12 +177,12 @@ class ExtractArchive(Hook): else: self.logWarning(_("Could not activate: %s") % p, e) if self.core.debug: - print_exc() + traceback.print_exc() except Exception, e: self.logWarning(_("Could not activate: %s") % p, e) if self.core.debug: - print_exc() + traceback.print_exc() if self.extractors: self.logInfo(_("Activated") + " " + "|".join("%s %s" % (Extractor.__name__, Extractor.VERSION) for Extractor in self.extractors)) @@ -497,7 +497,7 @@ class ExtractArchive(Hook): except Exception, e: self.logError(name, _("Unknown error"), e) if self.core.debug: - print_exc() + traceback.print_exc() self.manager.dispatchEvent("archive_extract_failed", pyfile, archive) diff --git a/module/plugins/hooks/IRCInterface.py b/module/plugins/hooks/IRCInterface.py index d76b9cb85..9e2f670e6 100644 --- a/module/plugins/hooks/IRCInterface.py +++ b/module/plugins/hooks/IRCInterface.py @@ -4,11 +4,11 @@ import re import socket import ssl import time +import traceback from pycurl import FORM_FILE from select import select from threading import Thread -from traceback import print_exc from module.Api import PackageDoesNotExists, FileDoesNotExists from module.network.RequestFactory import getURL @@ -106,7 +106,7 @@ class IRCInterface(Thread, Hook): except IRCError, ex: self.sock.send("QUIT :byebye\r\n") - print_exc() + traceback.print_exc() self.sock.close() diff --git a/module/plugins/hooks/MergeFiles.py b/module/plugins/hooks/MergeFiles.py index 2900b0d29..941938920 100644 --- a/module/plugins/hooks/MergeFiles.py +++ b/module/plugins/hooks/MergeFiles.py @@ -4,8 +4,7 @@ from __future__ import with_statement import os import re - -from traceback import print_exc +import traceback from module.plugins.Hook import Hook, threaded from module.utils import save_join @@ -75,7 +74,7 @@ class MergeFiles(Hook): self.logDebug("Finished merging part", splitted_file) except Exception, e: - print_exc() + traceback.print_exc() finally: pyfile.setProgress(100) -- cgit v1.2.3 From 48abd898139b3f40d52b17680c9d5b8a674545c6 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Wed, 8 Apr 2015 00:10:43 +0200 Subject: [UserAgentSwitcher] Default activated set to True --- module/plugins/hooks/UserAgentSwitcher.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/UserAgentSwitcher.py b/module/plugins/hooks/UserAgentSwitcher.py index 56c605bac..31eac9820 100644 --- a/module/plugins/hooks/UserAgentSwitcher.py +++ b/module/plugins/hooks/UserAgentSwitcher.py @@ -8,9 +8,10 @@ from module.plugins.Hook import Hook class UserAgentSwitcher(Hook): __name__ = "UserAgentSwitcher" __type__ = "hook" - __version__ = "0.01" + __version__ = "0.02" - __config__ = [("ua", "str", "Custom user-agent string", "")] + __config__ = [("activated", "bool", "Activated" , True ), + ("ua" , "str" , "Custom user-agent string", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:37.0) Gecko/20100101 Firefox/37.0")] __description__ = """Custom user-agent""" __license__ = "GPLv3" -- cgit v1.2.3 From 41a9fc39c201f663ee308840b8443f760b3678da Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Wed, 8 Apr 2015 00:30:57 +0200 Subject: [ExtractArchive] Fix https://github.com/pyload/pyload/issues/1322 --- module/plugins/hooks/ExtractArchive.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 595512c12..b418f802f 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -106,7 +106,7 @@ class ArchiveQueue(object): class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.39" + __version__ = "1.40" __config__ = [("activated" , "bool" , "Activated" , True ), ("fullpath" , "bool" , "Extract with full paths" , True ), @@ -468,7 +468,7 @@ class ExtractArchive(Hook): deltotrash = self.getConfig('deltotrash') for f in delfiles: file = fs_encode(f) - if not os.path.exists(file) + if not os.path.exists(file): continue if not deltotrash: -- cgit v1.2.3 From bc2ec03799dbb8479b8e519bb30eb5bf316dec57 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Wed, 8 Apr 2015 03:14:32 +0200 Subject: [UserAgentSwitcher] Fix https://github.com/pyload/pyload/issues/1324 --- module/plugins/hooks/UserAgentSwitcher.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/UserAgentSwitcher.py b/module/plugins/hooks/UserAgentSwitcher.py index 31eac9820..b0cf66709 100644 --- a/module/plugins/hooks/UserAgentSwitcher.py +++ b/module/plugins/hooks/UserAgentSwitcher.py @@ -8,7 +8,7 @@ from module.plugins.Hook import Hook class UserAgentSwitcher(Hook): __name__ = "UserAgentSwitcher" __type__ = "hook" - __version__ = "0.02" + __version__ = "0.03" __config__ = [("activated", "bool", "Activated" , True ), ("ua" , "str" , "Custom user-agent string", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:37.0) Gecko/20100101 Firefox/37.0")] @@ -29,4 +29,4 @@ class UserAgentSwitcher(Hook): ua = self.getConfig('ua') if ua: self.logDebug("Use custom user-agent string: " + ua) - pyfile.plugin.req.http.c.setopt(pycurl.USERAGENT, ua) + pyfile.plugin.req.http.c.setopt(pycurl.USERAGENT, ua.encode('utf-8')) -- cgit v1.2.3 From c5bd9e25f08248834aa6192b60ab968e95a10dc1 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Wed, 8 Apr 2015 04:32:51 +0200 Subject: [AntiVirus][ExtractArchive] Fixup --- module/plugins/hooks/AntiVirus.py | 4 ++-- module/plugins/hooks/ExtractArchive.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/AntiVirus.py b/module/plugins/hooks/AntiVirus.py index 78f5aaa23..27e3801b5 100644 --- a/module/plugins/hooks/AntiVirus.py +++ b/module/plugins/hooks/AntiVirus.py @@ -11,7 +11,7 @@ from module.utils import fs_encode, save_join class AntiVirus(Hook): __name__ = "AntiVirus" __type__ = "hook" - __version__ = "0.06" + __version__ = "0.07" #@TODO: add trash option (use Send2Trash lib) __config__ = [("action" , "Antivirus default;Delete;Quarantine", "Manage infected files" , "Antivirus default"), @@ -37,7 +37,7 @@ class AntiVirus(Hook): import send2trash except ImportError: - self.logDebug(name, _("Send2Trash lib not found")) + self.logDebug("Send2Trash lib not found") self.trashable = False else: diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index b418f802f..9e6f2d379 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -106,7 +106,7 @@ class ArchiveQueue(object): class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.40" + __version__ = "1.41" __config__ = [("activated" , "bool" , "Activated" , True ), ("fullpath" , "bool" , "Extract with full paths" , True ), @@ -154,7 +154,7 @@ class ExtractArchive(Hook): import send2trash except ImportError: - self.logDebug(name, _("Send2Trash lib not found")) + self.logDebug("Send2Trash lib not found") self.trashable = False else: -- cgit v1.2.3 From 77ef36eae8c6d930656c5b060bf2e41b6f7fc743 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Wed, 8 Apr 2015 15:10:43 +0200 Subject: [UserAgentSwitcher] Random user-agent feature --- module/plugins/hooks/UpdateManager.py | 4 ++-- module/plugins/hooks/UserAgentSwitcher.py | 27 +++++++++++++++++++++------ 2 files changed, 23 insertions(+), 8 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index 643b5c2d1..d66810d6d 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -117,7 +117,7 @@ class UpdateManager(Hook): return getURL(self.SERVER_URL, get={'v': self.core.api.getServerVersion()}).splitlines() except Exception: - self.logWarning(_("Unable to contact server to get updates")) + self.logWarning(_("Unable to retrieve server to get updates")) @Expose @@ -258,7 +258,7 @@ class UpdateManager(Hook): if self.core.pluginManager.reloadPlugins(updated): exitcode = 1 else: - self.logWarning(_("pyLoad restart required to reload the updated plugins")) + self.logWarning(_("Restart pyLoad to reload the updated plugins")) self.info['plugins'] = True exitcode = 2 diff --git a/module/plugins/hooks/UserAgentSwitcher.py b/module/plugins/hooks/UserAgentSwitcher.py index b0cf66709..912c2ef09 100644 --- a/module/plugins/hooks/UserAgentSwitcher.py +++ b/module/plugins/hooks/UserAgentSwitcher.py @@ -1,17 +1,24 @@ # -*- coding: utf-8 -*- +from __future__ import with_statement + +import os import pycurl +import random from module.plugins.Hook import Hook +from module.utils import fs_encode class UserAgentSwitcher(Hook): __name__ = "UserAgentSwitcher" __type__ = "hook" - __version__ = "0.03" + __version__ = "0.04" __config__ = [("activated", "bool", "Activated" , True ), - ("ua" , "str" , "Custom user-agent string", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:37.0) Gecko/20100101 Firefox/37.0")] + ("uaf" , "file", "Random user-agents file" , "" ), + ("uar" , "bool", "Random user-agent" , False ), + ("uas" , "str" , "Custom user-agent string", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:37.0) Gecko/20100101 Firefox/37.0")] __description__ = """Custom user-agent""" __license__ = "GPLv3" @@ -26,7 +33,15 @@ class UserAgentSwitcher(Hook): def downloadPreparing(self, pyfile): - ua = self.getConfig('ua') - if ua: - self.logDebug("Use custom user-agent string: " + ua) - pyfile.plugin.req.http.c.setopt(pycurl.USERAGENT, ua.encode('utf-8')) + uar = self.getConfig('uar') + uaf = fs_encode(self.getConfig('uaf')) + + if uar and os.path.isfile(uaf): + with open(uaf) as f: + uas = random.choice([ua for ua in f.read().splitlines()]) + else: + uas = self.getConfig('uas') + + if uas: + self.logDebug("Use custom user-agent string: " + uas) + pyfile.plugin.req.http.c.setopt(pycurl.USERAGENT, uas.encode('utf-8')) -- cgit v1.2.3 From 348a386486d081d86363774e64525484ef159cd6 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Wed, 8 Apr 2015 19:23:06 +0200 Subject: Fix https://github.com/pyload/pyload/issues/1157 --- module/plugins/hooks/AlldebridCom.py | 27 ---------- module/plugins/hooks/AlldebridComHook.py | 27 ++++++++++ module/plugins/hooks/DebridItaliaCom.py | 26 --------- module/plugins/hooks/DebridItaliaComHook.py | 26 +++++++++ module/plugins/hooks/EasybytezCom.py | 30 ----------- module/plugins/hooks/EasybytezComHook.py | 30 +++++++++++ module/plugins/hooks/FastixRu.py | 29 ---------- module/plugins/hooks/FastixRuHook.py | 29 ++++++++++ module/plugins/hooks/FreeWayMe.py | 32 ----------- module/plugins/hooks/FreeWayMeHook.py | 32 +++++++++++ module/plugins/hooks/LinkdecrypterCom.py | 25 --------- module/plugins/hooks/LinkdecrypterComHook.py | 26 +++++++++ module/plugins/hooks/LinksnappyCom.py | 27 ---------- module/plugins/hooks/LinksnappyComHook.py | 27 ++++++++++ module/plugins/hooks/MegaDebridEu.py | 33 ------------ module/plugins/hooks/MegaDebridEuHook.py | 33 ++++++++++++ module/plugins/hooks/MegaRapidoNet.py | 81 ---------------------------- module/plugins/hooks/MegaRapidoNetHook.py | 81 ++++++++++++++++++++++++++++ module/plugins/hooks/MultihostersCom.py | 18 ------- module/plugins/hooks/MultihostersComHook.py | 18 +++++++ module/plugins/hooks/MultishareCz.py | 29 ---------- module/plugins/hooks/MultishareCzHook.py | 29 ++++++++++ module/plugins/hooks/MyfastfileCom.py | 28 ---------- module/plugins/hooks/MyfastfileComHook.py | 28 ++++++++++ module/plugins/hooks/NoPremiumPl.py | 29 ---------- module/plugins/hooks/NoPremiumPlHook.py | 29 ++++++++++ module/plugins/hooks/OverLoadMe.py | 29 ---------- module/plugins/hooks/OverLoadMeHook.py | 29 ++++++++++ module/plugins/hooks/PremiumTo.py | 27 ---------- module/plugins/hooks/PremiumToHook.py | 27 ++++++++++ module/plugins/hooks/PremiumizeMe.py | 38 ------------- module/plugins/hooks/PremiumizeMeHook.py | 38 +++++++++++++ module/plugins/hooks/PutdriveCom.py | 18 ------- module/plugins/hooks/PutdriveComHook.py | 18 +++++++ module/plugins/hooks/RPNetBiz.py | 36 ------------- module/plugins/hooks/RPNetBizHook.py | 36 +++++++++++++ module/plugins/hooks/RapideoPl.py | 29 ---------- module/plugins/hooks/RapideoPlHook.py | 29 ++++++++++ module/plugins/hooks/RealdebridCom.py | 27 ---------- module/plugins/hooks/RealdebridComHook.py | 27 ++++++++++ module/plugins/hooks/RehostTo.py | 27 ---------- module/plugins/hooks/RehostToHook.py | 27 ++++++++++ module/plugins/hooks/SimplyPremiumCom.py | 29 ---------- module/plugins/hooks/SimplyPremiumComHook.py | 29 ++++++++++ module/plugins/hooks/SimplydebridCom.py | 24 --------- module/plugins/hooks/SimplydebridComHook.py | 24 +++++++++ module/plugins/hooks/SmoozedCom.py | 24 --------- module/plugins/hooks/SmoozedComHook.py | 24 +++++++++ module/plugins/hooks/UnrestrictLi.py | 28 ---------- module/plugins/hooks/UnrestrictLiHook.py | 28 ++++++++++ module/plugins/hooks/ZeveraCom.py | 25 --------- module/plugins/hooks/ZeveraComHook.py | 25 +++++++++ 52 files changed, 776 insertions(+), 775 deletions(-) delete mode 100644 module/plugins/hooks/AlldebridCom.py create mode 100644 module/plugins/hooks/AlldebridComHook.py delete mode 100644 module/plugins/hooks/DebridItaliaCom.py create mode 100644 module/plugins/hooks/DebridItaliaComHook.py delete mode 100644 module/plugins/hooks/EasybytezCom.py create mode 100644 module/plugins/hooks/EasybytezComHook.py delete mode 100644 module/plugins/hooks/FastixRu.py create mode 100644 module/plugins/hooks/FastixRuHook.py delete mode 100644 module/plugins/hooks/FreeWayMe.py create mode 100644 module/plugins/hooks/FreeWayMeHook.py delete mode 100644 module/plugins/hooks/LinkdecrypterCom.py create mode 100644 module/plugins/hooks/LinkdecrypterComHook.py delete mode 100644 module/plugins/hooks/LinksnappyCom.py create mode 100644 module/plugins/hooks/LinksnappyComHook.py delete mode 100644 module/plugins/hooks/MegaDebridEu.py create mode 100644 module/plugins/hooks/MegaDebridEuHook.py delete mode 100644 module/plugins/hooks/MegaRapidoNet.py create mode 100644 module/plugins/hooks/MegaRapidoNetHook.py delete mode 100644 module/plugins/hooks/MultihostersCom.py create mode 100644 module/plugins/hooks/MultihostersComHook.py delete mode 100644 module/plugins/hooks/MultishareCz.py create mode 100644 module/plugins/hooks/MultishareCzHook.py delete mode 100644 module/plugins/hooks/MyfastfileCom.py create mode 100644 module/plugins/hooks/MyfastfileComHook.py delete mode 100644 module/plugins/hooks/NoPremiumPl.py create mode 100644 module/plugins/hooks/NoPremiumPlHook.py delete mode 100644 module/plugins/hooks/OverLoadMe.py create mode 100644 module/plugins/hooks/OverLoadMeHook.py delete mode 100644 module/plugins/hooks/PremiumTo.py create mode 100644 module/plugins/hooks/PremiumToHook.py delete mode 100644 module/plugins/hooks/PremiumizeMe.py create mode 100644 module/plugins/hooks/PremiumizeMeHook.py delete mode 100644 module/plugins/hooks/PutdriveCom.py create mode 100644 module/plugins/hooks/PutdriveComHook.py delete mode 100644 module/plugins/hooks/RPNetBiz.py create mode 100644 module/plugins/hooks/RPNetBizHook.py delete mode 100644 module/plugins/hooks/RapideoPl.py create mode 100644 module/plugins/hooks/RapideoPlHook.py delete mode 100644 module/plugins/hooks/RealdebridCom.py create mode 100644 module/plugins/hooks/RealdebridComHook.py delete mode 100644 module/plugins/hooks/RehostTo.py create mode 100644 module/plugins/hooks/RehostToHook.py delete mode 100644 module/plugins/hooks/SimplyPremiumCom.py create mode 100644 module/plugins/hooks/SimplyPremiumComHook.py delete mode 100644 module/plugins/hooks/SimplydebridCom.py create mode 100644 module/plugins/hooks/SimplydebridComHook.py delete mode 100644 module/plugins/hooks/SmoozedCom.py create mode 100644 module/plugins/hooks/SmoozedComHook.py delete mode 100644 module/plugins/hooks/UnrestrictLi.py create mode 100644 module/plugins/hooks/UnrestrictLiHook.py delete mode 100644 module/plugins/hooks/ZeveraCom.py create mode 100644 module/plugins/hooks/ZeveraComHook.py (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/AlldebridCom.py b/module/plugins/hooks/AlldebridCom.py deleted file mode 100644 index 34f44c91d..000000000 --- a/module/plugins/hooks/AlldebridCom.py +++ /dev/null @@ -1,27 +0,0 @@ -# -*- coding: utf-8 -*- - -from module.plugins.internal.MultiHook import MultiHook - - -class AlldebridCom(MultiHook): - __name__ = "AlldebridCom" - __type__ = "hook" - __version__ = "0.16" - - __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), - ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), - ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("reload" , "bool" , "Reload plugin list" , True ), - ("reloadinterval", "int" , "Reload interval in hours" , 12 ), - ("ssl" , "bool" , "Use HTTPS" , True )] - - __description__ = """Alldebrid.com hook plugin""" - __license__ = "GPLv3" - __authors__ = [("Andy Voigt", "spamsales@online.de")] - - - def getHosters(self): - https = "https" if self.getConfig('ssl') else "http" - html = self.getURL(https + "://www.alldebrid.com/api.php", get={'action': "get_host"}).replace("\"", "").strip() - - return [x.strip() for x in html.split(",") if x.strip()] diff --git a/module/plugins/hooks/AlldebridComHook.py b/module/plugins/hooks/AlldebridComHook.py new file mode 100644 index 000000000..092921134 --- /dev/null +++ b/module/plugins/hooks/AlldebridComHook.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- + +from module.plugins.internal.MultiHook import MultiHook + + +class AlldebridComHook(MultiHook): + __name__ = "AlldebridComHook" + __type__ = "hook" + __version__ = "0.16" + + __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), + ("revertfailed" , "bool" , "Revert to standard download if fails", True ), + ("reload" , "bool" , "Reload plugin list" , True ), + ("reloadinterval", "int" , "Reload interval in hours" , 12 ), + ("ssl" , "bool" , "Use HTTPS" , True )] + + __description__ = """Alldebrid.com hook plugin""" + __license__ = "GPLv3" + __authors__ = [("Andy Voigt", "spamsales@online.de")] + + + def getHosters(self): + https = "https" if self.getConfig('ssl') else "http" + html = self.getURL(https + "://www.alldebrid.com/api.php", get={'action': "get_host"}).replace("\"", "").strip() + + return [x.strip() for x in html.split(",") if x.strip()] diff --git a/module/plugins/hooks/DebridItaliaCom.py b/module/plugins/hooks/DebridItaliaCom.py deleted file mode 100644 index a970ae195..000000000 --- a/module/plugins/hooks/DebridItaliaCom.py +++ /dev/null @@ -1,26 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from module.plugins.internal.MultiHook import MultiHook - - -class DebridItaliaCom(MultiHook): - __name__ = "DebridItaliaCom" - __type__ = "hook" - __version__ = "0.12" - - __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), - ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), - ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("reload" , "bool" , "Reload plugin list" , True ), - ("reloadinterval", "int" , "Reload interval in hours" , 12 )] - - __description__ = """Debriditalia.com hook plugin""" - __license__ = "GPLv3" - __authors__ = [("stickell" , "l.stickell@yahoo.it"), - ("Walter Purcaro", "vuolter@gmail.com" )] - - - def getHosters(self): - return self.getURL("http://debriditalia.com/api.php", get={'hosts': ""}).replace('"', '').split(',') diff --git a/module/plugins/hooks/DebridItaliaComHook.py b/module/plugins/hooks/DebridItaliaComHook.py new file mode 100644 index 000000000..36b307696 --- /dev/null +++ b/module/plugins/hooks/DebridItaliaComHook.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- + +import re + +from module.plugins.internal.MultiHook import MultiHook + + +class DebridItaliaComHook(MultiHook): + __name__ = "DebridItaliaComHook" + __type__ = "hook" + __version__ = "0.12" + + __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), + ("revertfailed" , "bool" , "Revert to standard download if fails", True ), + ("reload" , "bool" , "Reload plugin list" , True ), + ("reloadinterval", "int" , "Reload interval in hours" , 12 )] + + __description__ = """Debriditalia.com hook plugin""" + __license__ = "GPLv3" + __authors__ = [("stickell" , "l.stickell@yahoo.it"), + ("Walter Purcaro", "vuolter@gmail.com" )] + + + def getHosters(self): + return self.getURL("http://debriditalia.com/api.php", get={'hosts': ""}).replace('"', '').split(',') diff --git a/module/plugins/hooks/EasybytezCom.py b/module/plugins/hooks/EasybytezCom.py deleted file mode 100644 index 04da21ee2..000000000 --- a/module/plugins/hooks/EasybytezCom.py +++ /dev/null @@ -1,30 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from module.plugins.internal.MultiHook import MultiHook - - -class EasybytezCom(MultiHook): - __name__ = "EasybytezCom" - __type__ = "hook" - __version__ = "0.07" - - __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), - ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), - ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("reload" , "bool" , "Reload plugin list" , True ), - ("reloadinterval", "int" , "Reload interval in hours" , 12 )] - - __description__ = """EasyBytez.com hook plugin""" - __license__ = "GPLv3" - __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] - - - def getHosters(self): - user, data = self.account.selectAccount() - - req = self.account.getAccountRequest(user) - html = req.load("http://www.easybytez.com") - - return re.search(r'</textarea>\s*Supported sites:(.*)', html).group(1).split(',') diff --git a/module/plugins/hooks/EasybytezComHook.py b/module/plugins/hooks/EasybytezComHook.py new file mode 100644 index 000000000..43efb5048 --- /dev/null +++ b/module/plugins/hooks/EasybytezComHook.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- + +import re + +from module.plugins.internal.MultiHook import MultiHook + + +class EasybytezComHook(MultiHook): + __name__ = "EasybytezComHook" + __type__ = "hook" + __version__ = "0.07" + + __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), + ("revertfailed" , "bool" , "Revert to standard download if fails", True ), + ("reload" , "bool" , "Reload plugin list" , True ), + ("reloadinterval", "int" , "Reload interval in hours" , 12 )] + + __description__ = """EasyBytez.com hook plugin""" + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] + + + def getHosters(self): + user, data = self.account.selectAccount() + + req = self.account.getAccountRequest(user) + html = req.load("http://www.easybytez.com") + + return re.search(r'</textarea>\s*Supported sites:(.*)', html).group(1).split(',') diff --git a/module/plugins/hooks/FastixRu.py b/module/plugins/hooks/FastixRu.py deleted file mode 100644 index 9e74587ac..000000000 --- a/module/plugins/hooks/FastixRu.py +++ /dev/null @@ -1,29 +0,0 @@ -# -*- coding: utf-8 -*- - -from module.common.json_layer import json_loads -from module.plugins.internal.MultiHook import MultiHook - - -class FastixRu(MultiHook): - __name__ = "FastixRu" - __type__ = "hook" - __version__ = "0.05" - - __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), - ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), - ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("reload" , "bool" , "Reload plugin list" , True ), - ("reloadinterval", "int" , "Reload interval in hours" , 12 )] - - __description__ = """Fastix.ru hook plugin""" - __license__ = "GPLv3" - __authors__ = [("Massimo Rosamilia", "max@spiritix.eu")] - - - def getHosters(self): - html = self.getURL("http://fastix.ru/api_v2", - get={'apikey': "5182964c3f8f9a7f0b00000a_kelmFB4n1IrnCDYuIFn2y", - 'sub' : "allowed_sources"}) - host_list = json_loads(html) - host_list = host_list['allow'] - return host_list diff --git a/module/plugins/hooks/FastixRuHook.py b/module/plugins/hooks/FastixRuHook.py new file mode 100644 index 000000000..16e30e93a --- /dev/null +++ b/module/plugins/hooks/FastixRuHook.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- + +from module.common.json_layer import json_loads +from module.plugins.internal.MultiHook import MultiHook + + +class FastixRuHook(MultiHook): + __name__ = "FastixRuHook" + __type__ = "hook" + __version__ = "0.05" + + __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), + ("revertfailed" , "bool" , "Revert to standard download if fails", True ), + ("reload" , "bool" , "Reload plugin list" , True ), + ("reloadinterval", "int" , "Reload interval in hours" , 12 )] + + __description__ = """Fastix.ru hook plugin""" + __license__ = "GPLv3" + __authors__ = [("Massimo Rosamilia", "max@spiritix.eu")] + + + def getHosters(self): + html = self.getURL("http://fastix.ru/api_v2", + get={'apikey': "5182964c3f8f9a7f0b00000a_kelmFB4n1IrnCDYuIFn2y", + 'sub' : "allowed_sources"}) + host_list = json_loads(html) + host_list = host_list['allow'] + return host_list diff --git a/module/plugins/hooks/FreeWayMe.py b/module/plugins/hooks/FreeWayMe.py deleted file mode 100644 index 31ef8201f..000000000 --- a/module/plugins/hooks/FreeWayMe.py +++ /dev/null @@ -1,32 +0,0 @@ -# -*- coding: utf-8 -*- - -from module.plugins.internal.MultiHook import MultiHook - - -class FreeWayMe(MultiHook): - __name__ = "FreeWayMe" - __type__ = "hook" - __version__ = "0.15" - - __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), - ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), - ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("reload" , "bool" , "Reload plugin list" , True ), - ("reloadinterval", "int" , "Reload interval in hours" , 12 )] - - __description__ = """FreeWay.me hook plugin""" - __license__ = "GPLv3" - __authors__ = [("Nicolas Giese", "james@free-way.me")] - - - def getHosters(self): - # Get account data - if not self.account or not self.account.canUse(): - hostis = self.getURL("https://www.free-way.me/ajax/jd.php", get={"id": 3}).replace("\"", "").strip() - else: - self.logDebug("AccountInfo available - Get HosterList with User Pass") - (user, data) = self.account.selectAccount() - hostis = self.getURL("https://www.free-way.me/ajax/jd.php", get={"id": 3, "user": user, "pass": data['password']}).replace("\"", "").strip() - - self.logDebug("hosters: %s" % hostis) - return [x.strip() for x in hostis.split(",") if x.strip()] diff --git a/module/plugins/hooks/FreeWayMeHook.py b/module/plugins/hooks/FreeWayMeHook.py new file mode 100644 index 000000000..baea44540 --- /dev/null +++ b/module/plugins/hooks/FreeWayMeHook.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- + +from module.plugins.internal.MultiHook import MultiHook + + +class FreeWayMeHook(MultiHook): + __name__ = "FreeWayMeHook" + __type__ = "hook" + __version__ = "0.15" + + __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), + ("revertfailed" , "bool" , "Revert to standard download if fails", True ), + ("reload" , "bool" , "Reload plugin list" , True ), + ("reloadinterval", "int" , "Reload interval in hours" , 12 )] + + __description__ = """FreeWay.me hook plugin""" + __license__ = "GPLv3" + __authors__ = [("Nicolas Giese", "james@free-way.me")] + + + def getHosters(self): + # Get account data + if not self.account or not self.account.canUse(): + hostis = self.getURL("https://www.free-way.me/ajax/jd.php", get={"id": 3}).replace("\"", "").strip() + else: + self.logDebug("AccountInfo available - Get HosterList with User Pass") + (user, data) = self.account.selectAccount() + hostis = self.getURL("https://www.free-way.me/ajax/jd.php", get={"id": 3, "user": user, "pass": data['password']}).replace("\"", "").strip() + + self.logDebug("hosters: %s" % hostis) + return [x.strip() for x in hostis.split(",") if x.strip()] diff --git a/module/plugins/hooks/LinkdecrypterCom.py b/module/plugins/hooks/LinkdecrypterCom.py deleted file mode 100644 index 769e63e81..000000000 --- a/module/plugins/hooks/LinkdecrypterCom.py +++ /dev/null @@ -1,25 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from module.plugins.internal.MultiHook import MultiHook - - -class LinkdecrypterCom(MultiHook): - __name__ = "LinkdecrypterCom" - __type__ = "hook" - __version__ = "1.03" - - __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), - ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), - ("reload" , "bool" , "Reload plugin list" , True ), - ("reloadinterval", "int" , "Reload interval in hours" , 12 )] - - __description__ = """Linkdecrypter.com hook plugin""" - __license__ = "GPLv3" - __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - - - def getCrypters(self): - return re.search(r'>Supported\(\d+\)</b>: <i>(.[\w.\-, ]+)', - self.getURL("http://linkdecrypter.com/", decode=True).replace("(g)", "")).group(1).split(', ') diff --git a/module/plugins/hooks/LinkdecrypterComHook.py b/module/plugins/hooks/LinkdecrypterComHook.py new file mode 100644 index 000000000..596a397a4 --- /dev/null +++ b/module/plugins/hooks/LinkdecrypterComHook.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- + +import re + +from module.plugins.internal.MultiHook import MultiHook + + +class LinkdecrypterComHook(MultiHook): + __name__ = "LinkdecrypterComHook" + __type__ = "hook" + __version__ = "1.04" + + __config__ = [("activated" , "bool" , "Activated" , True ), + ("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)", "" ), + ("reload" , "bool" , "Reload plugin list" , True ), + ("reloadinterval", "int" , "Reload interval in hours" , 12 )] + + __description__ = """Linkdecrypter.com hook plugin""" + __license__ = "GPLv3" + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] + + + def getCrypters(self): + return re.search(r'>Supported\(\d+\)</b>: <i>(.[\w.\-, ]+)', + self.getURL("http://linkdecrypter.com/", decode=True).replace("(g)", "")).group(1).split(', ') diff --git a/module/plugins/hooks/LinksnappyCom.py b/module/plugins/hooks/LinksnappyCom.py deleted file mode 100644 index a5b77b93f..000000000 --- a/module/plugins/hooks/LinksnappyCom.py +++ /dev/null @@ -1,27 +0,0 @@ -# -*- coding: utf-8 -*- - -from module.common.json_layer import json_loads -from module.plugins.internal.MultiHook import MultiHook - - -class LinksnappyCom(MultiHook): - __name__ = "LinksnappyCom" - __type__ = "hook" - __version__ = "0.04" - - __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), - ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), - ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("reload" , "bool" , "Reload plugin list" , True ), - ("reloadinterval", "int" , "Reload interval in hours" , 12 )] - - __description__ = """Linksnappy.com hook plugin""" - __license__ = "GPLv3" - __authors__ = [("stickell", "l.stickell@yahoo.it")] - - - def getHosters(self): - json_data = self.getURL("http://gen.linksnappy.com/lseAPI.php", get={'act': "FILEHOSTS"}) - json_data = json_loads(json_data) - - return json_data['return'].keys() diff --git a/module/plugins/hooks/LinksnappyComHook.py b/module/plugins/hooks/LinksnappyComHook.py new file mode 100644 index 000000000..72282575b --- /dev/null +++ b/module/plugins/hooks/LinksnappyComHook.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- + +from module.common.json_layer import json_loads +from module.plugins.internal.MultiHook import MultiHook + + +class LinksnappyComHook(MultiHook): + __name__ = "LinksnappyComHook" + __type__ = "hook" + __version__ = "0.04" + + __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), + ("revertfailed" , "bool" , "Revert to standard download if fails", True ), + ("reload" , "bool" , "Reload plugin list" , True ), + ("reloadinterval", "int" , "Reload interval in hours" , 12 )] + + __description__ = """Linksnappy.com hook plugin""" + __license__ = "GPLv3" + __authors__ = [("stickell", "l.stickell@yahoo.it")] + + + def getHosters(self): + json_data = self.getURL("http://gen.linksnappy.com/lseAPI.php", get={'act': "FILEHOSTS"}) + json_data = json_loads(json_data) + + return json_data['return'].keys() diff --git a/module/plugins/hooks/MegaDebridEu.py b/module/plugins/hooks/MegaDebridEu.py deleted file mode 100644 index b32656019..000000000 --- a/module/plugins/hooks/MegaDebridEu.py +++ /dev/null @@ -1,33 +0,0 @@ -# -*- coding: utf-8 -*- - -from module.common.json_layer import json_loads -from module.plugins.internal.MultiHook import MultiHook - - -class MegaDebridEu(MultiHook): - __name__ = "MegaDebridEu" - __type__ = "hook" - __version__ = "0.05" - - __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), - ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), - ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("reload" , "bool" , "Reload plugin list" , True ), - ("reloadinterval", "int" , "Reload interval in hours" , 12 )] - - __description__ = """Mega-debrid.eu hook plugin""" - __license__ = "GPLv3" - __authors__ = [("D.Ducatel", "dducatel@je-geek.fr")] - - - def getHosters(self): - reponse = self.getURL("http://www.mega-debrid.eu/api.php", get={'action': "getHosters"}) - json_data = json_loads(reponse) - - if json_data['response_code'] == "ok": - host_list = [element[0] for element in json_data['hosters']] - else: - self.logError(_("Unable to retrieve hoster list")) - host_list = list() - - return host_list diff --git a/module/plugins/hooks/MegaDebridEuHook.py b/module/plugins/hooks/MegaDebridEuHook.py new file mode 100644 index 000000000..0de7b4dcf --- /dev/null +++ b/module/plugins/hooks/MegaDebridEuHook.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- + +from module.common.json_layer import json_loads +from module.plugins.internal.MultiHook import MultiHook + + +class MegaDebridEuHook(MultiHook): + __name__ = "MegaDebridEuHook" + __type__ = "hook" + __version__ = "0.05" + + __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), + ("revertfailed" , "bool" , "Revert to standard download if fails", True ), + ("reload" , "bool" , "Reload plugin list" , True ), + ("reloadinterval", "int" , "Reload interval in hours" , 12 )] + + __description__ = """Mega-debrid.eu hook plugin""" + __license__ = "GPLv3" + __authors__ = [("D.Ducatel", "dducatel@je-geek.fr")] + + + def getHosters(self): + reponse = self.getURL("http://www.mega-debrid.eu/api.php", get={'action': "getHosters"}) + json_data = json_loads(reponse) + + if json_data['response_code'] == "ok": + host_list = [element[0] for element in json_data['hosters']] + else: + self.logError(_("Unable to retrieve hoster list")) + host_list = list() + + return host_list diff --git a/module/plugins/hooks/MegaRapidoNet.py b/module/plugins/hooks/MegaRapidoNet.py deleted file mode 100644 index fb5e77994..000000000 --- a/module/plugins/hooks/MegaRapidoNet.py +++ /dev/null @@ -1,81 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from module.plugins.internal.MultiHook import MultiHook - - -class MegaRapidoNet(MultiHook): - __name__ = "MegaRapidoNet" - __type__ = "hook" - __version__ = "0.02" - - __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), - ("pluginlist" , "str" , "Plugin list (comma separated)", "" ), - ("reload" , "bool" , "Reload plugin list" , True ), - ("reloadinterval", "int" , "Reload interval in hours" , 12 )] - - __description__ = """MegaRapido.net hook plugin""" - __license__ = "GPLv3" - __authors__ = [("Kagenoshin", "kagenoshin@gmx.ch")] - - - def getHosters(self): - hosters = {'1fichier' : [],#leave it there are so many possible addresses? - '1st-files' : ['1st-files.com'], - '2shared' : ['2shared.com'], - '4shared' : ['4shared.com', '4shared-china.com'], - 'asfile' : ['http://asfile.com/'], - 'bitshare' : ['bitshare.com'], - 'brupload' : ['brupload.net'], - 'crocko' : ['crocko.com','easy-share.com'], - 'dailymotion' : ['dailymotion.com'], - 'depfile' : ['depfile.com'], - 'depositfiles': ['depositfiles.com', 'dfiles.eu'], - 'dizzcloud' : ['dizzcloud.com'], - 'dl.dropbox' : [], - 'extabit' : ['extabit.com'], - 'extmatrix' : ['extmatrix.com'], - 'facebook' : [], - 'file4go' : ['file4go.com'], - 'filecloud' : ['filecloud.io','ifile.it','mihd.net'], - 'filefactory' : ['filefactory.com'], - 'fileom' : ['fileom.com'], - 'fileparadox' : ['fileparadox.in'], - 'filepost' : ['filepost.com', 'fp.io'], - 'filerio' : ['filerio.in','filerio.com','filekeen.com'], - 'filesflash' : ['filesflash.com'], - 'firedrive' : ['firedrive.com', 'putlocker.com'], - 'flashx' : [], - 'freakshare' : ['freakshare.net', 'freakshare.com'], - 'gigasize' : ['gigasize.com'], - 'hipfile' : ['hipfile.com'], - 'junocloud' : ['junocloud.me'], - 'letitbit' : ['letitbit.net','shareflare.net'], - 'mediafire' : ['mediafire.com'], - 'mega' : ['mega.co.nz'], - 'megashares' : ['megashares.com'], - 'metacafe' : ['metacafe.com'], - 'netload' : ['netload.in'], - 'oboom' : ['oboom.com'], - 'rapidgator' : ['rapidgator.net'], - 'rapidshare' : ['rapidshare.com'], - 'rarefile' : ['rarefile.net'], - 'ryushare' : ['ryushare.com'], - 'sendspace' : ['sendspace.com'], - 'turbobit' : ['turbobit.net', 'unextfiles.com'], - 'uploadable' : ['uploadable.ch'], - 'uploadbaz' : ['uploadbaz.com'], - 'uploaded' : ['uploaded.to', 'uploaded.net', 'ul.to'], - 'uploadhero' : ['uploadhero.com'], - 'uploading' : ['uploading.com'], - 'uptobox' : ['uptobox.com'], - 'xvideos' : ['xvideos.com'], - 'youtube' : ['youtube.com']} - - hoster_list = [] - - for item in hosters.itervalues(): - hoster_list.extend(item) - - return hoster_list diff --git a/module/plugins/hooks/MegaRapidoNetHook.py b/module/plugins/hooks/MegaRapidoNetHook.py new file mode 100644 index 000000000..e113b305e --- /dev/null +++ b/module/plugins/hooks/MegaRapidoNetHook.py @@ -0,0 +1,81 @@ +# -*- coding: utf-8 -*- + +import re + +from module.plugins.internal.MultiHook import MultiHook + + +class MegaRapidoNetHook(MultiHook): + __name__ = "MegaRapidoNetHook" + __type__ = "hook" + __version__ = "0.02" + + __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)", "" ), + ("reload" , "bool" , "Reload plugin list" , True ), + ("reloadinterval", "int" , "Reload interval in hours" , 12 )] + + __description__ = """MegaRapido.net hook plugin""" + __license__ = "GPLv3" + __authors__ = [("Kagenoshin", "kagenoshin@gmx.ch")] + + + def getHosters(self): + hosters = {'1fichier' : [],#leave it there are so many possible addresses? + '1st-files' : ['1st-files.com'], + '2shared' : ['2shared.com'], + '4shared' : ['4shared.com', '4shared-china.com'], + 'asfile' : ['http://asfile.com/'], + 'bitshare' : ['bitshare.com'], + 'brupload' : ['brupload.net'], + 'crocko' : ['crocko.com','easy-share.com'], + 'dailymotion' : ['dailymotion.com'], + 'depfile' : ['depfile.com'], + 'depositfiles': ['depositfiles.com', 'dfiles.eu'], + 'dizzcloud' : ['dizzcloud.com'], + 'dl.dropbox' : [], + 'extabit' : ['extabit.com'], + 'extmatrix' : ['extmatrix.com'], + 'facebook' : [], + 'file4go' : ['file4go.com'], + 'filecloud' : ['filecloud.io','ifile.it','mihd.net'], + 'filefactory' : ['filefactory.com'], + 'fileom' : ['fileom.com'], + 'fileparadox' : ['fileparadox.in'], + 'filepost' : ['filepost.com', 'fp.io'], + 'filerio' : ['filerio.in','filerio.com','filekeen.com'], + 'filesflash' : ['filesflash.com'], + 'firedrive' : ['firedrive.com', 'putlocker.com'], + 'flashx' : [], + 'freakshare' : ['freakshare.net', 'freakshare.com'], + 'gigasize' : ['gigasize.com'], + 'hipfile' : ['hipfile.com'], + 'junocloud' : ['junocloud.me'], + 'letitbit' : ['letitbit.net','shareflare.net'], + 'mediafire' : ['mediafire.com'], + 'mega' : ['mega.co.nz'], + 'megashares' : ['megashares.com'], + 'metacafe' : ['metacafe.com'], + 'netload' : ['netload.in'], + 'oboom' : ['oboom.com'], + 'rapidgator' : ['rapidgator.net'], + 'rapidshare' : ['rapidshare.com'], + 'rarefile' : ['rarefile.net'], + 'ryushare' : ['ryushare.com'], + 'sendspace' : ['sendspace.com'], + 'turbobit' : ['turbobit.net', 'unextfiles.com'], + 'uploadable' : ['uploadable.ch'], + 'uploadbaz' : ['uploadbaz.com'], + 'uploaded' : ['uploaded.to', 'uploaded.net', 'ul.to'], + 'uploadhero' : ['uploadhero.com'], + 'uploading' : ['uploading.com'], + 'uptobox' : ['uptobox.com'], + 'xvideos' : ['xvideos.com'], + 'youtube' : ['youtube.com']} + + hoster_list = [] + + for item in hosters.itervalues(): + hoster_list.extend(item) + + return hoster_list diff --git a/module/plugins/hooks/MultihostersCom.py b/module/plugins/hooks/MultihostersCom.py deleted file mode 100644 index bf88cfae7..000000000 --- a/module/plugins/hooks/MultihostersCom.py +++ /dev/null @@ -1,18 +0,0 @@ -# -*- coding: utf-8 -*- - -from module.plugins.hooks.ZeveraCom import ZeveraCom - - -class MultihostersCom(ZeveraCom): - __name__ = "MultihostersCom" - __type__ = "hook" - __version__ = "0.02" - - __config__ = [("mode" , "all;listed;unlisted", "Use for plugins (if supported)" , "all"), - ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), - ("revertfailed", "bool" , "Revert to standard download if download fails", False), - ("interval" , "int" , "Reload interval in hours (0 to disable)" , 12 )] - - __description__ = """Multihosters.com hook plugin""" - __license__ = "GPLv3" - __authors__ = [("tjeh", "tjeh@gmx.net")] diff --git a/module/plugins/hooks/MultihostersComHook.py b/module/plugins/hooks/MultihostersComHook.py new file mode 100644 index 000000000..7b5e49c49 --- /dev/null +++ b/module/plugins/hooks/MultihostersComHook.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- + +from module.plugins.hooks.ZeveraComHook import ZeveraComHook + + +class MultihostersComHook(ZeveraComHook): + __name__ = "MultihostersComHook" + __type__ = "hook" + __version__ = "0.02" + + __config__ = [("mode" , "all;listed;unlisted", "Use for plugins (if supported)" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), + ("revertfailed", "bool" , "Revert to standard download if download fails", False), + ("interval" , "int" , "Reload interval in hours (0 to disable)" , 12 )] + + __description__ = """Multihosters.com hook plugin""" + __license__ = "GPLv3" + __authors__ = [("tjeh", "tjeh@gmx.net")] diff --git a/module/plugins/hooks/MultishareCz.py b/module/plugins/hooks/MultishareCz.py deleted file mode 100644 index 6ead88c34..000000000 --- a/module/plugins/hooks/MultishareCz.py +++ /dev/null @@ -1,29 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from module.plugins.internal.MultiHook import MultiHook - - -class MultishareCz(MultiHook): - __name__ = "MultishareCz" - __type__ = "hook" - __version__ = "0.07" - - __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), - ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), - ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("reload" , "bool" , "Reload plugin list" , True ), - ("reloadinterval", "int" , "Reload interval in hours" , 12 )] - - __description__ = """MultiShare.cz hook plugin""" - __license__ = "GPLv3" - __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] - - - HOSTER_PATTERN = r'<img class="logo-shareserveru"[^>]*?alt="(.+?)"></td>\s*<td class="stav">[^>]*?alt="OK"' - - - def getHosters(self): - html = self.getURL("http://www.multishare.cz/monitoring/") - return re.findall(self.HOSTER_PATTERN, html) diff --git a/module/plugins/hooks/MultishareCzHook.py b/module/plugins/hooks/MultishareCzHook.py new file mode 100644 index 000000000..6052b7673 --- /dev/null +++ b/module/plugins/hooks/MultishareCzHook.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- + +import re + +from module.plugins.internal.MultiHook import MultiHook + + +class MultishareCzHook(MultiHook): + __name__ = "MultishareCzHook" + __type__ = "hook" + __version__ = "0.07" + + __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), + ("revertfailed" , "bool" , "Revert to standard download if fails", True ), + ("reload" , "bool" , "Reload plugin list" , True ), + ("reloadinterval", "int" , "Reload interval in hours" , 12 )] + + __description__ = """MultiShare.cz hook plugin""" + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] + + + HOSTER_PATTERN = r'<img class="logo-shareserveru"[^>]*?alt="(.+?)"></td>\s*<td class="stav">[^>]*?alt="OK"' + + + def getHosters(self): + html = self.getURL("http://www.multishare.cz/monitoring/") + return re.findall(self.HOSTER_PATTERN, html) diff --git a/module/plugins/hooks/MyfastfileCom.py b/module/plugins/hooks/MyfastfileCom.py deleted file mode 100644 index 1e7a6421d..000000000 --- a/module/plugins/hooks/MyfastfileCom.py +++ /dev/null @@ -1,28 +0,0 @@ -# -*- coding: utf-8 -*- - -from module.common.json_layer import json_loads -from module.plugins.internal.MultiHook import MultiHook - - -class MyfastfileCom(MultiHook): - __name__ = "MyfastfileCom" - __type__ = "hook" - __version__ = "0.05" - - __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), - ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), - ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("reload" , "bool" , "Reload plugin list" , True ), - ("reloadinterval", "int" , "Reload interval in hours" , 12 )] - - __description__ = """Myfastfile.com hook plugin""" - __license__ = "GPLv3" - __authors__ = [("stickell", "l.stickell@yahoo.it")] - - - def getHosters(self): - json_data = self.getURL("http://myfastfile.com/api.php", get={'hosts': ""}, decode=True) - self.logDebug("JSON data", json_data) - json_data = json_loads(json_data) - - return json_data['hosts'] diff --git a/module/plugins/hooks/MyfastfileComHook.py b/module/plugins/hooks/MyfastfileComHook.py new file mode 100644 index 000000000..20a1cfac2 --- /dev/null +++ b/module/plugins/hooks/MyfastfileComHook.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- + +from module.common.json_layer import json_loads +from module.plugins.internal.MultiHook import MultiHook + + +class MyfastfileComHook(MultiHook): + __name__ = "MyfastfileComHook" + __type__ = "hook" + __version__ = "0.05" + + __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), + ("revertfailed" , "bool" , "Revert to standard download if fails", True ), + ("reload" , "bool" , "Reload plugin list" , True ), + ("reloadinterval", "int" , "Reload interval in hours" , 12 )] + + __description__ = """Myfastfile.com hook plugin""" + __license__ = "GPLv3" + __authors__ = [("stickell", "l.stickell@yahoo.it")] + + + def getHosters(self): + json_data = self.getURL("http://myfastfile.com/api.php", get={'hosts': ""}, decode=True) + self.logDebug("JSON data", json_data) + json_data = json_loads(json_data) + + return json_data['hosts'] diff --git a/module/plugins/hooks/NoPremiumPl.py b/module/plugins/hooks/NoPremiumPl.py deleted file mode 100644 index 77ee83cb1..000000000 --- a/module/plugins/hooks/NoPremiumPl.py +++ /dev/null @@ -1,29 +0,0 @@ -# -*- coding: utf-8 -*- - -from module.common.json_layer import json_loads -from module.plugins.internal.MultiHook import MultiHook - - -class NoPremiumPl(MultiHook): - __name__ = "NoPremiumPl" - __type__ = "hook" - __version__ = "0.03" - - __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), - ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), - ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("reload" , "bool" , "Reload plugin list" , True ), - ("reloadinterval", "int" , "Reload interval in hours" , 12 )] - - __description__ = """NoPremium.pl hook plugin""" - __license__ = "GPLv3" - __authors__ = [("goddie", "dev@nopremium.pl")] - - - def getHosters(self): - hostings = json_loads(self.getURL("https://www.nopremium.pl/clipboard.php?json=3").strip()) - hostings_domains = [domain for row in hostings for domain in row["domains"] if row["sdownload"] == "0"] - - self.logDebug(hostings_domains) - - return hostings_domains diff --git a/module/plugins/hooks/NoPremiumPlHook.py b/module/plugins/hooks/NoPremiumPlHook.py new file mode 100644 index 000000000..b5a007ff9 --- /dev/null +++ b/module/plugins/hooks/NoPremiumPlHook.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- + +from module.common.json_layer import json_loads +from module.plugins.internal.MultiHook import MultiHook + + +class NoPremiumPlHook(MultiHook): + __name__ = "NoPremiumPlHook" + __type__ = "hook" + __version__ = "0.03" + + __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), + ("revertfailed" , "bool" , "Revert to standard download if fails", True ), + ("reload" , "bool" , "Reload plugin list" , True ), + ("reloadinterval", "int" , "Reload interval in hours" , 12 )] + + __description__ = """NoPremium.pl hook plugin""" + __license__ = "GPLv3" + __authors__ = [("goddie", "dev@nopremium.pl")] + + + def getHosters(self): + hostings = json_loads(self.getURL("https://www.nopremium.pl/clipboard.php?json=3").strip()) + hostings_domains = [domain for row in hostings for domain in row["domains"] if row["sdownload"] == "0"] + + self.logDebug(hostings_domains) + + return hostings_domains diff --git a/module/plugins/hooks/OverLoadMe.py b/module/plugins/hooks/OverLoadMe.py deleted file mode 100644 index 7b9a1f414..000000000 --- a/module/plugins/hooks/OverLoadMe.py +++ /dev/null @@ -1,29 +0,0 @@ -# -*- coding: utf-8 -*- - -from module.plugins.internal.MultiHook import MultiHook - - -class OverLoadMe(MultiHook): - __name__ = "OverLoadMe" - __type__ = "hook" - __version__ = "0.04" - - __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), - ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), - ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("reload" , "bool" , "Reload plugin list" , True ), - ("reloadinterval", "int" , "Reload interval in hours" , 12 ), - ("ssl" , "bool" , "Use HTTPS" , True )] - - __description__ = """Over-Load.me hook plugin""" - __license__ = "GPLv3" - __authors__ = [("marley", "marley@over-load.me")] - - - def getHosters(self): - https = "https" if self.getConfig('ssl') else "http" - html = self.getURL(https + "://api.over-load.me/hoster.php", - get={'auth': "0001-cb1f24dadb3aa487bda5afd3b76298935329be7700cd7-5329be77-00cf-1ca0135f"}).replace("\"", "").strip() - self.logDebug("Hosterlist", html) - - return [x.strip() for x in html.split(",") if x.strip()] diff --git a/module/plugins/hooks/OverLoadMeHook.py b/module/plugins/hooks/OverLoadMeHook.py new file mode 100644 index 000000000..d608a2ecd --- /dev/null +++ b/module/plugins/hooks/OverLoadMeHook.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- + +from module.plugins.internal.MultiHook import MultiHook + + +class OverLoadMeHook(MultiHook): + __name__ = "OverLoadMeHook" + __type__ = "hook" + __version__ = "0.04" + + __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), + ("revertfailed" , "bool" , "Revert to standard download if fails", True ), + ("reload" , "bool" , "Reload plugin list" , True ), + ("reloadinterval", "int" , "Reload interval in hours" , 12 ), + ("ssl" , "bool" , "Use HTTPS" , True )] + + __description__ = """Over-Load.me hook plugin""" + __license__ = "GPLv3" + __authors__ = [("marley", "marley@over-load.me")] + + + def getHosters(self): + https = "https" if self.getConfig('ssl') else "http" + html = self.getURL(https + "://api.over-load.me/hoster.php", + get={'auth': "0001-cb1f24dadb3aa487bda5afd3b76298935329be7700cd7-5329be77-00cf-1ca0135f"}).replace("\"", "").strip() + self.logDebug("Hosterlist", html) + + return [x.strip() for x in html.split(",") if x.strip()] diff --git a/module/plugins/hooks/PremiumTo.py b/module/plugins/hooks/PremiumTo.py deleted file mode 100644 index f5636cb72..000000000 --- a/module/plugins/hooks/PremiumTo.py +++ /dev/null @@ -1,27 +0,0 @@ -# -*- coding: utf-8 -*- - -from module.plugins.internal.MultiHook import MultiHook - - -class PremiumTo(MultiHook): - __name__ = "PremiumTo" - __type__ = "hook" - __version__ = "0.08" - - __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), - ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), - ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("reload" , "bool" , "Reload plugin list" , True ), - ("reloadinterval", "int" , "Reload interval in hours" , 12 )] - - __description__ = """Premium.to hook plugin""" - __license__ = "GPLv3" - __authors__ = [("RaNaN" , "RaNaN@pyload.org" ), - ("zoidberg", "zoidberg@mujmail.cz"), - ("stickell", "l.stickell@yahoo.it")] - - - def getHosters(self): - html = self.getURL("http://premium.to/api/hosters.php", - get={'username': self.account.username, 'password': self.account.password}) - return [x.strip() for x in html.replace("\"", "").split(";")] diff --git a/module/plugins/hooks/PremiumToHook.py b/module/plugins/hooks/PremiumToHook.py new file mode 100644 index 000000000..ef2a84223 --- /dev/null +++ b/module/plugins/hooks/PremiumToHook.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- + +from module.plugins.internal.MultiHook import MultiHook + + +class PremiumToHook(MultiHook): + __name__ = "PremiumToHook" + __type__ = "hook" + __version__ = "0.08" + + __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), + ("revertfailed" , "bool" , "Revert to standard download if fails", True ), + ("reload" , "bool" , "Reload plugin list" , True ), + ("reloadinterval", "int" , "Reload interval in hours" , 12 )] + + __description__ = """Premium.to hook plugin""" + __license__ = "GPLv3" + __authors__ = [("RaNaN" , "RaNaN@pyload.org" ), + ("zoidberg", "zoidberg@mujmail.cz"), + ("stickell", "l.stickell@yahoo.it")] + + + def getHosters(self): + html = self.getURL("http://premium.to/api/hosters.php", + get={'username': self.account.username, 'password': self.account.password}) + return [x.strip() for x in html.replace("\"", "").split(";")] diff --git a/module/plugins/hooks/PremiumizeMe.py b/module/plugins/hooks/PremiumizeMe.py deleted file mode 100644 index 266c62549..000000000 --- a/module/plugins/hooks/PremiumizeMe.py +++ /dev/null @@ -1,38 +0,0 @@ -# -*- coding: utf-8 -*- - -from module.common.json_layer import json_loads -from module.plugins.internal.MultiHook import MultiHook - - -class PremiumizeMe(MultiHook): - __name__ = "PremiumizeMe" - __type__ = "hook" - __version__ = "0.17" - - __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), - ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), - ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("reload" , "bool" , "Reload plugin list" , True ), - ("reloadinterval", "int" , "Reload interval in hours" , 12 )] - - __description__ = """Premiumize.me hook plugin""" - __license__ = "GPLv3" - __authors__ = [("Florian Franzen", "FlorianFranzen@gmail.com")] - - - def getHosters(self): - # Get account data - user, data = self.account.selectAccount() - - # Get supported hosters list from premiumize.me using the - # json API v1 (see https://secure.premiumize.me/?show=api) - answer = self.getURL("https://api.premiumize.me/pm-api/v1.php", - get={'method': "hosterlist", 'params[login]': user, 'params[pass]': data['password']}) - data = json_loads(answer) - - # If account is not valid thera are no hosters available - if data['status'] != 200: - return [] - - # Extract hosters from json file - return data['result']['hosterlist'] diff --git a/module/plugins/hooks/PremiumizeMeHook.py b/module/plugins/hooks/PremiumizeMeHook.py new file mode 100644 index 000000000..e081fb389 --- /dev/null +++ b/module/plugins/hooks/PremiumizeMeHook.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- + +from module.common.json_layer import json_loads +from module.plugins.internal.MultiHook import MultiHook + + +class PremiumizeMeHook(MultiHook): + __name__ = "PremiumizeMeHook" + __type__ = "hook" + __version__ = "0.17" + + __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), + ("revertfailed" , "bool" , "Revert to standard download if fails", True ), + ("reload" , "bool" , "Reload plugin list" , True ), + ("reloadinterval", "int" , "Reload interval in hours" , 12 )] + + __description__ = """Premiumize.me hook plugin""" + __license__ = "GPLv3" + __authors__ = [("Florian Franzen", "FlorianFranzen@gmail.com")] + + + def getHosters(self): + # Get account data + user, data = self.account.selectAccount() + + # Get supported hosters list from premiumize.me using the + # json API v1 (see https://secure.premiumize.me/?show=api) + answer = self.getURL("https://api.premiumize.me/pm-api/v1.php", + get={'method': "hosterlist", 'params[login]': user, 'params[pass]': data['password']}) + data = json_loads(answer) + + # If account is not valid thera are no hosters available + if data['status'] != 200: + return [] + + # Extract hosters from json file + return data['result']['hosterlist'] diff --git a/module/plugins/hooks/PutdriveCom.py b/module/plugins/hooks/PutdriveCom.py deleted file mode 100644 index f665dabee..000000000 --- a/module/plugins/hooks/PutdriveCom.py +++ /dev/null @@ -1,18 +0,0 @@ -# -*- coding: utf-8 -*- - -from module.plugins.hooks.ZeveraCom import ZeveraCom - - -class PutdriveCom(ZeveraCom): - __name__ = "PutdriveCom" - __type__ = "hook" - __version__ = "0.01" - - __config__ = [("mode" , "all;listed;unlisted", "Use for plugins (if supported)" , "all"), - ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), - ("revertfailed", "bool" , "Revert to standard download if download fails", False), - ("interval" , "int" , "Reload interval in hours (0 to disable)" , 12 )] - - __description__ = """Putdrive.com hook plugin""" - __license__ = "GPLv3" - __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] diff --git a/module/plugins/hooks/PutdriveComHook.py b/module/plugins/hooks/PutdriveComHook.py new file mode 100644 index 000000000..c3ebf4ff3 --- /dev/null +++ b/module/plugins/hooks/PutdriveComHook.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- + +from module.plugins.hooks.ZeveraComHook import ZeveraComHook + + +class PutdriveComHook(ZeveraComHook): + __name__ = "PutdriveComHook" + __type__ = "hook" + __version__ = "0.01" + + __config__ = [("mode" , "all;listed;unlisted", "Use for plugins (if supported)" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), + ("revertfailed", "bool" , "Revert to standard download if download fails", False), + ("interval" , "int" , "Reload interval in hours (0 to disable)" , 12 )] + + __description__ = """Putdrive.com hook plugin""" + __license__ = "GPLv3" + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] diff --git a/module/plugins/hooks/RPNetBiz.py b/module/plugins/hooks/RPNetBiz.py deleted file mode 100644 index a24697265..000000000 --- a/module/plugins/hooks/RPNetBiz.py +++ /dev/null @@ -1,36 +0,0 @@ -# -*- coding: utf-8 -*- - -from module.common.json_layer import json_loads -from module.plugins.internal.MultiHook import MultiHook - - -class RPNetBiz(MultiHook): - __name__ = "RPNetBiz" - __type__ = "hook" - __version__ = "0.14" - - __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), - ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), - ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("reload" , "bool" , "Reload plugin list" , True ), - ("reloadinterval", "int" , "Reload interval in hours" , 12 )] - - __description__ = """RPNet.biz hook plugin""" - __license__ = "GPLv3" - __authors__ = [("Dman", "dmanugm@gmail.com")] - - - def getHosters(self): - # Get account data - user, data = self.account.selectAccount() - - res = self.getURL("https://premium.rpnet.biz/client_api.php", - get={'username': user, 'password': data['password'], 'action': "showHosterList"}) - hoster_list = json_loads(res) - - # If account is not valid thera are no hosters available - if 'error' in hoster_list: - return [] - - # Extract hosters from json file - return hoster_list['hosters'] diff --git a/module/plugins/hooks/RPNetBizHook.py b/module/plugins/hooks/RPNetBizHook.py new file mode 100644 index 000000000..10332948d --- /dev/null +++ b/module/plugins/hooks/RPNetBizHook.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- + +from module.common.json_layer import json_loads +from module.plugins.internal.MultiHook import MultiHook + + +class RPNetBizHook(MultiHook): + __name__ = "RPNetBizHook" + __type__ = "hook" + __version__ = "0.14" + + __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), + ("revertfailed" , "bool" , "Revert to standard download if fails", True ), + ("reload" , "bool" , "Reload plugin list" , True ), + ("reloadinterval", "int" , "Reload interval in hours" , 12 )] + + __description__ = """RPNet.biz hook plugin""" + __license__ = "GPLv3" + __authors__ = [("Dman", "dmanugm@gmail.com")] + + + def getHosters(self): + # Get account data + user, data = self.account.selectAccount() + + res = self.getURL("https://premium.rpnet.biz/client_api.php", + get={'username': user, 'password': data['password'], 'action': "showHosterList"}) + hoster_list = json_loads(res) + + # If account is not valid thera are no hosters available + if 'error' in hoster_list: + return [] + + # Extract hosters from json file + return hoster_list['hosters'] diff --git a/module/plugins/hooks/RapideoPl.py b/module/plugins/hooks/RapideoPl.py deleted file mode 100644 index 70d499de5..000000000 --- a/module/plugins/hooks/RapideoPl.py +++ /dev/null @@ -1,29 +0,0 @@ -# -*- coding: utf-8 -*- - -from module.common.json_layer import json_loads -from module.plugins.internal.MultiHook import MultiHook - - -class RapideoPl(MultiHook): - __name__ = "RapideoPl" - __type__ = "hook" - __version__ = "0.03" - - __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), - ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), - ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("reload" , "bool" , "Reload plugin list" , True ), - ("reloadinterval", "int" , "Reload interval in hours" , 12 )] - - __description__ = """Rapideo.pl hook plugin""" - __license__ = "GPLv3" - __authors__ = [("goddie", "dev@rapideo.pl")] - - - def getHosters(self): - hostings = json_loads(self.getURL("https://www.rapideo.pl/clipboard.php?json=3").strip()) - hostings_domains = [domain for row in hostings for domain in row["domains"] if row["sdownload"] == "0"] - - self.logDebug(hostings_domains) - - return hostings_domains diff --git a/module/plugins/hooks/RapideoPlHook.py b/module/plugins/hooks/RapideoPlHook.py new file mode 100644 index 000000000..0400f07ba --- /dev/null +++ b/module/plugins/hooks/RapideoPlHook.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- + +from module.common.json_layer import json_loads +from module.plugins.internal.MultiHook import MultiHook + + +class RapideoPlHook(MultiHook): + __name__ = "RapideoPlHook" + __type__ = "hook" + __version__ = "0.03" + + __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), + ("revertfailed" , "bool" , "Revert to standard download if fails", True ), + ("reload" , "bool" , "Reload plugin list" , True ), + ("reloadinterval", "int" , "Reload interval in hours" , 12 )] + + __description__ = """Rapideo.pl hook plugin""" + __license__ = "GPLv3" + __authors__ = [("goddie", "dev@rapideo.pl")] + + + def getHosters(self): + hostings = json_loads(self.getURL("https://www.rapideo.pl/clipboard.php?json=3").strip()) + hostings_domains = [domain for row in hostings for domain in row["domains"] if row["sdownload"] == "0"] + + self.logDebug(hostings_domains) + + return hostings_domains diff --git a/module/plugins/hooks/RealdebridCom.py b/module/plugins/hooks/RealdebridCom.py deleted file mode 100644 index 4260940d0..000000000 --- a/module/plugins/hooks/RealdebridCom.py +++ /dev/null @@ -1,27 +0,0 @@ -# -*- coding: utf-8 -*- - -from module.plugins.internal.MultiHook import MultiHook - - -class RealdebridCom(MultiHook): - __name__ = "RealdebridCom" - __type__ = "hook" - __version__ = "0.46" - - __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), - ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), - ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("reload" , "bool" , "Reload plugin list" , True ), - ("reloadinterval", "int" , "Reload interval in hours" , 12 ), - ("ssl" , "bool" , "Use HTTPS" , True )] - - __description__ = """Real-Debrid.com hook plugin""" - __license__ = "GPLv3" - __authors__ = [("Devirex Hazzard", "naibaf_11@yahoo.de")] - - - def getHosters(self): - https = "https" if self.getConfig('ssl') else "http" - html = self.getURL(https + "://real-debrid.com/api/hosters.php").replace("\"", "").strip() - - return [x.strip() for x in html.split(",") if x.strip()] diff --git a/module/plugins/hooks/RealdebridComHook.py b/module/plugins/hooks/RealdebridComHook.py new file mode 100644 index 000000000..aa0c9f640 --- /dev/null +++ b/module/plugins/hooks/RealdebridComHook.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- + +from module.plugins.internal.MultiHook import MultiHook + + +class RealdebridComHook(MultiHook): + __name__ = "RealdebridComHook" + __type__ = "hook" + __version__ = "0.46" + + __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), + ("revertfailed" , "bool" , "Revert to standard download if fails", True ), + ("reload" , "bool" , "Reload plugin list" , True ), + ("reloadinterval", "int" , "Reload interval in hours" , 12 ), + ("ssl" , "bool" , "Use HTTPS" , True )] + + __description__ = """Real-Debrid.com hook plugin""" + __license__ = "GPLv3" + __authors__ = [("Devirex Hazzard", "naibaf_11@yahoo.de")] + + + def getHosters(self): + https = "https" if self.getConfig('ssl') else "http" + html = self.getURL(https + "://real-debrid.com/api/hosters.php").replace("\"", "").strip() + + return [x.strip() for x in html.split(",") if x.strip()] diff --git a/module/plugins/hooks/RehostTo.py b/module/plugins/hooks/RehostTo.py deleted file mode 100644 index 1e608f87a..000000000 --- a/module/plugins/hooks/RehostTo.py +++ /dev/null @@ -1,27 +0,0 @@ -# -*- coding: utf-8 -*- - -from module.plugins.internal.MultiHook import MultiHook - - -class RehostTo(MultiHook): - __name__ = "RehostTo" - __type__ = "hook" - __version__ = "0.50" - - __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), - ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), - ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("reload" , "bool" , "Reload plugin list" , True ), - ("reloadinterval", "int" , "Reload interval in hours" , 12 )] - - __description__ = """Rehost.to hook plugin""" - __license__ = "GPLv3" - __authors__ = [("RaNaN", "RaNaN@pyload.org")] - - - def getHosters(self): - user, data = self.account.selectAccount() - html = self.getURL("http://rehost.to/api.php", - get={'cmd' : "get_supported_och_dl", - 'long_ses': self.account.getAccountInfo(user)['session']}) - return [x.strip() for x in html.replace("\"", "").split(",")] diff --git a/module/plugins/hooks/RehostToHook.py b/module/plugins/hooks/RehostToHook.py new file mode 100644 index 000000000..a2415129a --- /dev/null +++ b/module/plugins/hooks/RehostToHook.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- + +from module.plugins.internal.MultiHook import MultiHook + + +class RehostToHook(MultiHook): + __name__ = "RehostToHook" + __type__ = "hook" + __version__ = "0.50" + + __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), + ("revertfailed" , "bool" , "Revert to standard download if fails", True ), + ("reload" , "bool" , "Reload plugin list" , True ), + ("reloadinterval", "int" , "Reload interval in hours" , 12 )] + + __description__ = """Rehost.to hook plugin""" + __license__ = "GPLv3" + __authors__ = [("RaNaN", "RaNaN@pyload.org")] + + + def getHosters(self): + user, data = self.account.selectAccount() + html = self.getURL("http://rehost.to/api.php", + get={'cmd' : "get_supported_och_dl", + 'long_ses': self.account.getAccountInfo(user)['session']}) + return [x.strip() for x in html.replace("\"", "").split(",")] diff --git a/module/plugins/hooks/SimplyPremiumCom.py b/module/plugins/hooks/SimplyPremiumCom.py deleted file mode 100644 index a5173dbfa..000000000 --- a/module/plugins/hooks/SimplyPremiumCom.py +++ /dev/null @@ -1,29 +0,0 @@ -# -*- coding: utf-8 -*- - -from module.common.json_layer import json_loads -from module.plugins.internal.MultiHook import MultiHook - - -class SimplyPremiumCom(MultiHook): - __name__ = "SimplyPremiumCom" - __type__ = "hook" - __version__ = "0.05" - - __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), - ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), - ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("reload" , "bool" , "Reload plugin list" , True ), - ("reloadinterval", "int" , "Reload interval in hours" , 12 )] - - __description__ = """Simply-Premium.com hook plugin""" - __license__ = "GPLv3" - __authors__ = [("EvolutionClip", "evolutionclip@live.de")] - - - def getHosters(self): - json_data = self.getURL("http://www.simply-premium.com/api/hosts.php", get={'format': "json", 'online': 1}) - json_data = json_loads(json_data) - - host_list = [element['regex'] for element in json_data['result']] - - return host_list diff --git a/module/plugins/hooks/SimplyPremiumComHook.py b/module/plugins/hooks/SimplyPremiumComHook.py new file mode 100644 index 000000000..116e3a76e --- /dev/null +++ b/module/plugins/hooks/SimplyPremiumComHook.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- + +from module.common.json_layer import json_loads +from module.plugins.internal.MultiHook import MultiHook + + +class SimplyPremiumComHook(MultiHook): + __name__ = "SimplyPremiumComHook" + __type__ = "hook" + __version__ = "0.05" + + __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), + ("revertfailed" , "bool" , "Revert to standard download if fails", True ), + ("reload" , "bool" , "Reload plugin list" , True ), + ("reloadinterval", "int" , "Reload interval in hours" , 12 )] + + __description__ = """Simply-Premium.com hook plugin""" + __license__ = "GPLv3" + __authors__ = [("EvolutionClip", "evolutionclip@live.de")] + + + def getHosters(self): + json_data = self.getURL("http://www.simply-premium.com/api/hosts.php", get={'format': "json", 'online': 1}) + json_data = json_loads(json_data) + + host_list = [element['regex'] for element in json_data['result']] + + return host_list diff --git a/module/plugins/hooks/SimplydebridCom.py b/module/plugins/hooks/SimplydebridCom.py deleted file mode 100644 index a37a6eb7f..000000000 --- a/module/plugins/hooks/SimplydebridCom.py +++ /dev/null @@ -1,24 +0,0 @@ -# -*- coding: utf-8 -*- - -from module.plugins.internal.MultiHook import MultiHook - - -class SimplydebridCom(MultiHook): - __name__ = "SimplydebridCom" - __type__ = "hook" - __version__ = "0.04" - - __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), - ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), - ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("reload" , "bool" , "Reload plugin list" , True ), - ("reloadinterval", "int" , "Reload interval in hours" , 12 )] - - __description__ = """Simply-Debrid.com hook plugin""" - __license__ = "GPLv3" - __authors__ = [("Kagenoshin", "kagenoshin@gmx.ch")] - - - def getHosters(self): - html = self.getURL("http://simply-debrid.com/api.php", get={'list': 1}) - return [x.strip() for x in html.rstrip(';').replace("\"", "").split(";")] diff --git a/module/plugins/hooks/SimplydebridComHook.py b/module/plugins/hooks/SimplydebridComHook.py new file mode 100644 index 000000000..01629df99 --- /dev/null +++ b/module/plugins/hooks/SimplydebridComHook.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- + +from module.plugins.internal.MultiHook import MultiHook + + +class SimplydebridComHook(MultiHook): + __name__ = "SimplydebridComHook" + __type__ = "hook" + __version__ = "0.04" + + __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), + ("revertfailed" , "bool" , "Revert to standard download if fails", True ), + ("reload" , "bool" , "Reload plugin list" , True ), + ("reloadinterval", "int" , "Reload interval in hours" , 12 )] + + __description__ = """Simply-Debrid.com hook plugin""" + __license__ = "GPLv3" + __authors__ = [("Kagenoshin", "kagenoshin@gmx.ch")] + + + def getHosters(self): + html = self.getURL("http://simply-debrid.com/api.php", get={'list': 1}) + return [x.strip() for x in html.rstrip(';').replace("\"", "").split(";")] diff --git a/module/plugins/hooks/SmoozedCom.py b/module/plugins/hooks/SmoozedCom.py deleted file mode 100644 index cd9b2fa6e..000000000 --- a/module/plugins/hooks/SmoozedCom.py +++ /dev/null @@ -1,24 +0,0 @@ -# -*- coding: utf-8 -*- - -from module.plugins.internal.MultiHook import MultiHook - - -class SmoozedCom(MultiHook): - __name__ = "SmoozedCom" - __type__ = "hook" - __version__ = "0.03" - - __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), - ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), - ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("reload" , "bool" , "Reload plugin list" , True ), - ("reloadinterval", "int" , "Reload interval in hours" , 12 )] - - __description__ = """Smoozed.com hook plugin""" - __license__ = "GPLv3" - __authors__ = [("", "")] - - - def getHosters(self): - user, data = self.account.selectAccount() - return self.account.getAccountInfo(user)["hosters"] diff --git a/module/plugins/hooks/SmoozedComHook.py b/module/plugins/hooks/SmoozedComHook.py new file mode 100644 index 000000000..24b7c8df0 --- /dev/null +++ b/module/plugins/hooks/SmoozedComHook.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- + +from module.plugins.internal.MultiHook import MultiHook + + +class SmoozedComHook(MultiHook): + __name__ = "SmoozedComHook" + __type__ = "hook" + __version__ = "0.03" + + __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), + ("revertfailed" , "bool" , "Revert to standard download if fails", True ), + ("reload" , "bool" , "Reload plugin list" , True ), + ("reloadinterval", "int" , "Reload interval in hours" , 12 )] + + __description__ = """Smoozed.com hook plugin""" + __license__ = "GPLv3" + __authors__ = [("", "")] + + + def getHosters(self): + user, data = self.account.selectAccount() + return self.account.getAccountInfo(user)["hosters"] diff --git a/module/plugins/hooks/UnrestrictLi.py b/module/plugins/hooks/UnrestrictLi.py deleted file mode 100644 index 58f31f2aa..000000000 --- a/module/plugins/hooks/UnrestrictLi.py +++ /dev/null @@ -1,28 +0,0 @@ -# -*- coding: utf-8 -*- - -from module.common.json_layer import json_loads -from module.plugins.internal.MultiHook import MultiHook - - -class UnrestrictLi(MultiHook): - __name__ = "UnrestrictLi" - __type__ = "hook" - __version__ = "0.05" - - __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), - ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), - ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("reload" , "bool" , "Reload plugin list" , True ), - ("reloadinterval", "int" , "Reload interval in hours" , 12 ), - ("history" , "bool" , "Delete History" , False)] - - __description__ = """Unrestrict.li hook plugin""" - __license__ = "GPLv3" - __authors__ = [("stickell", "l.stickell@yahoo.it")] - - - def getHosters(self): - json_data = self.getURL("http://unrestrict.li/api/jdownloader/hosts.php", get={'format': "json"}) - json_data = json_loads(json_data) - - return [element['host'] for element in json_data['result']] diff --git a/module/plugins/hooks/UnrestrictLiHook.py b/module/plugins/hooks/UnrestrictLiHook.py new file mode 100644 index 000000000..f1ffd1886 --- /dev/null +++ b/module/plugins/hooks/UnrestrictLiHook.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- + +from module.common.json_layer import json_loads +from module.plugins.internal.MultiHook import MultiHook + + +class UnrestrictLiHook(MultiHook): + __name__ = "UnrestrictLiHook" + __type__ = "hook" + __version__ = "0.05" + + __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), + ("revertfailed" , "bool" , "Revert to standard download if fails", True ), + ("reload" , "bool" , "Reload plugin list" , True ), + ("reloadinterval", "int" , "Reload interval in hours" , 12 ), + ("history" , "bool" , "Delete History" , False)] + + __description__ = """Unrestrict.li hook plugin""" + __license__ = "GPLv3" + __authors__ = [("stickell", "l.stickell@yahoo.it")] + + + def getHosters(self): + json_data = self.getURL("http://unrestrict.li/api/jdownloader/hosts.php", get={'format': "json"}) + json_data = json_loads(json_data) + + return [element['host'] for element in json_data['result']] diff --git a/module/plugins/hooks/ZeveraCom.py b/module/plugins/hooks/ZeveraCom.py deleted file mode 100644 index 7fcfb18da..000000000 --- a/module/plugins/hooks/ZeveraCom.py +++ /dev/null @@ -1,25 +0,0 @@ -# -*- coding: utf-8 -*- - -from module.plugins.internal.MultiHook import MultiHook - - -class ZeveraCom(MultiHook): - __name__ = "ZeveraCom" - __type__ = "hook" - __version__ = "0.05" - - __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), - ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), - ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("reload" , "bool" , "Reload plugin list" , True ), - ("reloadinterval", "int" , "Reload interval in hours" , 12 )] - - __description__ = """Zevera.com hook plugin""" - __license__ = "GPLv3" - __authors__ = [("zoidberg" , "zoidberg@mujmail.cz"), - ("Walter Purcaro", "vuolter@gmail.com" )] - - - def getHosters(self): - html = self.account.api_response(pyreq.getHTTPRequest(timeout=120), cmd="gethosters") - return [x.strip() for x in html.split(",")] diff --git a/module/plugins/hooks/ZeveraComHook.py b/module/plugins/hooks/ZeveraComHook.py new file mode 100644 index 000000000..21c1741d2 --- /dev/null +++ b/module/plugins/hooks/ZeveraComHook.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- + +from module.plugins.internal.MultiHook import MultiHook + + +class ZeveraComHook(MultiHook): + __name__ = "ZeveraComHook" + __type__ = "hook" + __version__ = "0.05" + + __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), + ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), + ("revertfailed" , "bool" , "Revert to standard download if fails", True ), + ("reload" , "bool" , "Reload plugin list" , True ), + ("reloadinterval", "int" , "Reload interval in hours" , 12 )] + + __description__ = """Zevera.com hook plugin""" + __license__ = "GPLv3" + __authors__ = [("zoidberg" , "zoidberg@mujmail.cz"), + ("Walter Purcaro", "vuolter@gmail.com" )] + + + def getHosters(self): + html = self.account.api_response(pyreq.getHTTPRequest(timeout=120), cmd="gethosters") + return [x.strip() for x in html.split(",")] -- cgit v1.2.3 From 73f99ea811d01a2e113a882fe5ab86b0aa9c4f4c Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Thu, 9 Apr 2015 00:22:51 +0200 Subject: [SimpleHoster] Improve file name handling --- module/plugins/hooks/ExtractArchive.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 9e6f2d379..d40b52aa7 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -173,7 +173,7 @@ class ExtractArchive(Hook): except OSError, e: if e.errno == 2: - self.logInfo(_("No %s installed") % p) + self.logWarning(_("No %s installed") % p) else: self.logWarning(_("Could not activate: %s") % p, e) if self.core.debug: @@ -185,7 +185,7 @@ class ExtractArchive(Hook): traceback.print_exc() if self.extractors: - self.logInfo(_("Activated") + " " + "|".join("%s %s" % (Extractor.__name__, Extractor.VERSION) for Extractor in self.extractors)) + self.logDebug(*["Found %s %s" % (Extractor.__name__, Extractor.VERSION) for Extractor in self.extractors]) self.extractQueued() #: Resume unfinished extractions else: self.logInfo(_("No Extract plugins activated")) -- cgit v1.2.3 From d9846612baf0ae82548e6cb7b9176ec1d5dd48f3 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Fri, 10 Apr 2015 03:28:03 +0200 Subject: [RestartSlow] Remove (temp) --- module/plugins/hooks/RestartSlow.py | 58 ------------------------------------- 1 file changed, 58 deletions(-) delete mode 100644 module/plugins/hooks/RestartSlow.py (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/RestartSlow.py b/module/plugins/hooks/RestartSlow.py deleted file mode 100644 index db535b3d1..000000000 --- a/module/plugins/hooks/RestartSlow.py +++ /dev/null @@ -1,58 +0,0 @@ -# -*- coding: utf-8 -*- - -import pycurl - -from module.plugins.Hook import Hook - - -class RestartSlow(Hook): - __name__ = "RestartSlow" - __type__ = "hook" - __version__ = "0.04" - - __config__ = [("free_limit" , "int" , "Transfer speed threshold in kilobytes" , 100 ), - ("free_time" , "int" , "Sample interval in minutes" , 5 ), - ("premium_limit", "int" , "Transfer speed threshold for premium download in kilobytes", 300 ), - ("premium_time" , "int" , "Sample interval for premium download in minutes" , 2 ), - ("safe_mode" , "bool", "Don't restart if download is not resumable" , True)] - - __description__ = """Restart slow downloads""" - __license__ = "GPLv3" - __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - - - event_list = ["downloadStarts"] - interval = 0 #@TODO: Remove in 0.4.10 - - - def setup(self): - self.info = {'chunk': {}} - - - def periodical(self): - if not self.pyfile.plugin.req.dl: - return - - if self.getConfig('safe_mode') and not self.pyfile.plugin.resumeDownload: - time = 30 - limit = 5 - else: - type = "premium" if self.pyfile.plugin.premium else "free" - time = max(30, self.getConfig("%s_time" % type) * 60) - limit = max(5, self.getConfig("%s_limit" % type) * 1024) - - chunks = [chunk for chunk in self.pyfile.plugin.req.dl.chunks \ - if chunk.id not in self.info['chunk'] or self.info['chunk'][chunk.id] is not (time, limit)] - - for chunk in chunks: - chunk.c.setopt(pycurl.LOW_SPEED_TIME , time) - chunk.c.setopt(pycurl.LOW_SPEED_LIMIT, limit) - - self.info['chunk'][chunk.id] = (time, limit) - - - def downloadStarts(self, pyfile, url, filename): - if self.cb or (self.getConfig('safe_mode') and not pyfile.plugin.resumeDownload): - return - self.pyfile = pyfile - super(RestartSlow, self).initPeriodical() -- cgit v1.2.3 From ba16563f549663dd8fdd98acc3c47210c329a0bf Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Mon, 13 Apr 2015 15:13:13 +0200 Subject: [UnSkipOnFail] Typo --- module/plugins/hooks/UnSkipOnFail.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/UnSkipOnFail.py b/module/plugins/hooks/UnSkipOnFail.py index ebd370a0f..6cd742c91 100644 --- a/module/plugins/hooks/UnSkipOnFail.py +++ b/module/plugins/hooks/UnSkipOnFail.py @@ -7,7 +7,7 @@ from module.plugins.Hook import Hook class UnSkipOnFail(Hook): __name__ = "UnSkipOnFail" __type__ = "hook" - __version__ = "0.05" + __version__ = "0.06" __config__ = [("activated", "bool", "Activated", True)] @@ -43,7 +43,7 @@ class UnSkipOnFail(Hook): # It creates a temporary PyFile object using # "link" data, changes its status, and tells # the core.files-manager to save its data. - pylink = _pyfile(link) + pylink = self._pyfile(link) pylink.setCustomStatus(_("unskipped"), "queued") -- cgit v1.2.3 From ae14e28b210a164c3d3f58de7656d854f5f98037 Mon Sep 17 00:00:00 2001 From: GammaC0de <GammaC0de@users.noreply.github.com> Date: Tue, 14 Apr 2015 12:47:39 +0300 Subject: Update UpdateManager.py --- module/plugins/hooks/UpdateManager.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index d66810d6d..33de276d2 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -29,7 +29,7 @@ def exists(path): class UpdateManager(Hook): __name__ = "UpdateManager" __type__ = "hook" - __version__ = "0.50" + __version__ = "0.51" __config__ = [("activated" , "bool", "Activated" , True ), ("checkinterval", "int" , "Check interval in hours" , 8 ), @@ -45,10 +45,13 @@ class UpdateManager(Hook): interval = 0 + restartrequired = False SERVER_URL = "http://updatemanager.pyload.org" MIN_CHECK_INTERVAL = 3 * 60 * 60 #: 3 hours + event_list = ["allDownloadsProcessed"] + def coreReady(self): if self.checkonstart: @@ -68,6 +71,14 @@ class UpdateManager(Hook): else: self.checkonstart = False + self.restartrequired = False + + + def allDownloadsProcessed(self): + if self.restartrequired is True: + self.logWarning(_("Downloads are done, restarting pyLoad to reload the updated plugins")) + self.core.api.restart() + def periodical(self): if self.core.debug: @@ -128,7 +139,12 @@ class UpdateManager(Hook): self.core.api.pauseServer() if self._update() is 2 and self.getConfig('autorestart'): - self.core.api.restart() + downloads = self.core.api.statusDownloads() + if not downloads: + self.core.api.restart() + else: + self.restartrequired = True + self.logWarning(_("Downloads are active, will restart once the download is done")) else: self.core.api.unpauseServer() @@ -258,7 +274,7 @@ class UpdateManager(Hook): if self.core.pluginManager.reloadPlugins(updated): exitcode = 1 else: - self.logWarning(_("Restart pyLoad to reload the updated plugins")) + self.logWarning(_("pyLoad restart required to reload the updated plugins")) self.info['plugins'] = True exitcode = 2 -- cgit v1.2.3 From d38fc44f61177592ce0c925b947dde6a7d39d55b Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Thu, 16 Apr 2015 16:19:29 +0200 Subject: [UpdateManager] Cleanup --- module/plugins/hooks/UpdateManager.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index 33de276d2..5779e7c80 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -45,7 +45,6 @@ class UpdateManager(Hook): interval = 0 - restartrequired = False SERVER_URL = "http://updatemanager.pyload.org" MIN_CHECK_INTERVAL = 3 * 60 * 60 #: 3 hours @@ -71,11 +70,11 @@ class UpdateManager(Hook): else: self.checkonstart = False - self.restartrequired = False + self.do_restart = False def allDownloadsProcessed(self): - if self.restartrequired is True: + if self.do_restart is True: self.logWarning(_("Downloads are done, restarting pyLoad to reload the updated plugins")) self.core.api.restart() @@ -139,11 +138,10 @@ class UpdateManager(Hook): self.core.api.pauseServer() if self._update() is 2 and self.getConfig('autorestart'): - downloads = self.core.api.statusDownloads() - if not downloads: + if not self.core.api.statusDownloads(): self.core.api.restart() else: - self.restartrequired = True + self.do_restart = True self.logWarning(_("Downloads are active, will restart once the download is done")) else: self.core.api.unpauseServer() -- cgit v1.2.3 From 3c75bb3ac5ecd27b147dd28b9185a080aa66a675 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Thu, 16 Apr 2015 21:22:24 +0200 Subject: [UnSkipOnFail] Typo (2) --- module/plugins/hooks/UnSkipOnFail.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/UnSkipOnFail.py b/module/plugins/hooks/UnSkipOnFail.py index 6cd742c91..9059d0350 100644 --- a/module/plugins/hooks/UnSkipOnFail.py +++ b/module/plugins/hooks/UnSkipOnFail.py @@ -7,7 +7,7 @@ from module.plugins.Hook import Hook class UnSkipOnFail(Hook): __name__ = "UnSkipOnFail" __type__ = "hook" - __version__ = "0.06" + __version__ = "0.07" __config__ = [("activated", "bool", "Activated", True)] @@ -32,9 +32,9 @@ class UnSkipOnFail(Hook): msg = _("Looking for skipped duplicates of: %s (pid:%s)") self.logInfo(msg % (pyfile.name, pyfile.package().id)) - dup = self.findDuplicate(pyfile) - if dup: - self.logInfo(_("Queue found duplicate: %s (pid:%s)") % (dup.name, dup.packageID)) + link = self.findDuplicate(pyfile) + if link: + self.logInfo(_("Queue found duplicate: %s (pid:%s)") % (link.name, link.packageID)) #: Change status of "link" to "new_status". # "link" has to be a valid FileData object, -- cgit v1.2.3 From 1ef93e913238275f7657d496ba3d2e7eeb5a30a2 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Fri, 1 May 2015 01:06:01 +0200 Subject: Use 'import' instead 'from' --- module/plugins/hooks/BypassCaptcha.py | 6 +++--- module/plugins/hooks/CaptchaBrotherhood.py | 11 +++++------ module/plugins/hooks/Checksum.py | 14 ++++++-------- module/plugins/hooks/DeathByCaptcha.py | 6 +++--- module/plugins/hooks/ExpertDecoders.py | 9 +++++---- module/plugins/hooks/IRCInterface.py | 4 ++-- module/plugins/hooks/ImageTyperz.py | 6 +++--- module/plugins/hooks/SkipRev.py | 6 +++--- 8 files changed, 30 insertions(+), 32 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/BypassCaptcha.py b/module/plugins/hooks/BypassCaptcha.py index 3c8f72524..9e01edfa2 100644 --- a/module/plugins/hooks/BypassCaptcha.py +++ b/module/plugins/hooks/BypassCaptcha.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -from pycurl import FORM_FILE, LOW_SPEED_TIME +import pycurl from module.network.HTTPRequest import BadHeader from module.network.RequestFactory import getURL, getRequest @@ -64,14 +64,14 @@ class BypassCaptcha(Hook): req = getRequest() #raise timeout threshold - req.c.setopt(LOW_SPEED_TIME, 80) + req.c.setopt(pycurl.LOW_SPEED_TIME, 80) try: res = req.load(self.SUBMIT_URL, post={'vendor_key': self.PYLOAD_KEY, 'key': self.getConfig('passkey'), 'gen_task_id': "1", - 'file': (FORM_FILE, captcha)}, + 'file': (pycurl.FORM_FILE, captcha)}, multipart=True) finally: req.close() diff --git a/module/plugins/hooks/CaptchaBrotherhood.py b/module/plugins/hooks/CaptchaBrotherhood.py index e5285a493..bda080037 100644 --- a/module/plugins/hooks/CaptchaBrotherhood.py +++ b/module/plugins/hooks/CaptchaBrotherhood.py @@ -5,14 +5,13 @@ from __future__ import with_statement import StringIO import pycurl import time +import urllib try: from PIL import Image except ImportError: import Image -from urllib import urlencode - from module.network.RequestFactory import getURL, getRequest from module.plugins.Hook import Hook, threaded @@ -90,10 +89,10 @@ class CaptchaBrotherhood(Hook): req = getRequest() url = "%ssendNewCaptcha.aspx?%s" % (self.API_URL, - urlencode({'username' : self.getConfig('username'), - 'password' : self.getConfig('passkey'), - 'captchaSource': "pyLoad", - 'timeout' : "80"})) + urllib.urlencode({'username' : self.getConfig('username'), + 'password' : self.getConfig('passkey'), + 'captchaSource': "pyLoad", + 'timeout' : "80"})) req.c.setopt(pycurl.URL, url) req.c.setopt(pycurl.POST, 1) diff --git a/module/plugins/hooks/Checksum.py b/module/plugins/hooks/Checksum.py index 4ad17f55a..ab7daf701 100644 --- a/module/plugins/hooks/Checksum.py +++ b/module/plugins/hooks/Checksum.py @@ -3,12 +3,10 @@ from __future__ import with_statement import hashlib +import os import re import zlib -from os import remove -from os.path import getsize, isfile, splitext - from module.plugins.Hook import Hook from module.utils import save_join, fs_encode @@ -109,13 +107,13 @@ class Checksum(Hook): #download_folder = self.config['general']['download_folder'] #local_file = fs_encode(save_join(download_folder, pyfile.package().folder, pyfile.name)) - if not isfile(local_file): + if not os.path.isfile(local_file): self.checkFailed(pyfile, None, "File does not exist") # validate file size if "size" in data: api_size = int(data['size']) - file_size = getsize(local_file) + file_size = os.path.getsize(local_file) if api_size != file_size: self.logWarning(_("File %s has incorrect size: %d B (%d expected)") % (pyfile.name, file_size, api_size)) @@ -157,7 +155,7 @@ class Checksum(Hook): retry_action = self.getConfig('retry_action') if pyfile.plugin.retries < max_tries: if local_file: - remove(local_file) + os.remove(local_file) pyfile.plugin.retry(max_tries, self.getConfig('wait_time'), msg) elif retry_action == "nothing": return @@ -170,13 +168,13 @@ class Checksum(Hook): download_folder = save_join(self.config['general']['download_folder'], pypack.folder, "") for link in pypack.getChildren().itervalues(): - file_type = splitext(link['name'])[1][1:].lower() + file_type = os.path.splitext(link['name'])[1][1:].lower() if file_type not in self.formats: continue hash_file = fs_encode(save_join(download_folder, link['name'])) - if not isfile(hash_file): + if not os.path.isfile(hash_file): self.logWarning(_("File not found"), link['name']) continue diff --git a/module/plugins/hooks/DeathByCaptcha.py b/module/plugins/hooks/DeathByCaptcha.py index 501de0c1a..f9618f011 100644 --- a/module/plugins/hooks/DeathByCaptcha.py +++ b/module/plugins/hooks/DeathByCaptcha.py @@ -2,11 +2,11 @@ from __future__ import with_statement +import pycurl import re import time from base64 import b64encode -from pycurl import FORM_FILE, HTTPHEADER from module.common.json_layer import json_loads from module.network.HTTPRequest import BadHeader @@ -74,7 +74,7 @@ class DeathByCaptcha(Hook): def api_response(self, api="captcha", post=False, multipart=False): req = getRequest() - req.c.setopt(HTTPHEADER, ["Accept: application/json", "User-Agent: pyLoad %s" % self.core.version]) + req.c.setopt(pycurl.HTTPHEADER, ["Accept: application/json", "User-Agent: pyLoad %s" % self.core.version]) if post: if not isinstance(post, dict): @@ -135,7 +135,7 @@ class DeathByCaptcha(Hook): #@NOTE: Workaround multipart-post bug in HTTPRequest.py if re.match("^\w*$", self.getConfig('passkey')): multipart = True - data = (FORM_FILE, captcha) + data = (pycurl.FORM_FILE, captcha) else: multipart = False with open(captcha, 'rb') as f: diff --git a/module/plugins/hooks/ExpertDecoders.py b/module/plugins/hooks/ExpertDecoders.py index 79e98c020..ccd48f664 100644 --- a/module/plugins/hooks/ExpertDecoders.py +++ b/module/plugins/hooks/ExpertDecoders.py @@ -2,9 +2,10 @@ from __future__ import with_statement +import pycurl +import uuid + from base64 import b64encode -from pycurl import LOW_SPEED_TIME -from uuid import uuid4 from module.network.HTTPRequest import BadHeader from module.network.RequestFactory import getURL, getRequest @@ -48,7 +49,7 @@ class ExpertDecoders(Hook): @threaded def _processCaptcha(self, task): - task.data['ticket'] = ticket = uuid4() + task.data['ticket'] = ticket = uuid.uuid4() result = None with open(task.captchaFile, 'rb') as f: @@ -56,7 +57,7 @@ class ExpertDecoders(Hook): req = getRequest() #raise timeout threshold - req.c.setopt(LOW_SPEED_TIME, 80) + req.c.setopt(pycurl.LOW_SPEED_TIME, 80) try: result = req.load(self.API_URL, diff --git a/module/plugins/hooks/IRCInterface.py b/module/plugins/hooks/IRCInterface.py index 9e2f670e6..33fde3d20 100644 --- a/module/plugins/hooks/IRCInterface.py +++ b/module/plugins/hooks/IRCInterface.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- +import pycurl import re import socket import ssl import time import traceback -from pycurl import FORM_FILE from select import select from threading import Thread @@ -77,7 +77,7 @@ class IRCInterface(Thread, Hook): task.setWaiting(60) html = getURL("http://www.freeimagehosting.net/upload.php", - post={"attached": (FORM_FILE, task.captchaFile)}, multipart=True) + post={"attached": (pycurl.FORM_FILE, task.captchaFile)}, multipart=True) url = re.search(r"\[img\]([^\[]+)\[/img\]\[/url\]", html).group(1) self.response(_("New Captcha Request: %s") % url) diff --git a/module/plugins/hooks/ImageTyperz.py b/module/plugins/hooks/ImageTyperz.py index 132ab2e02..f1fcacb71 100644 --- a/module/plugins/hooks/ImageTyperz.py +++ b/module/plugins/hooks/ImageTyperz.py @@ -2,10 +2,10 @@ from __future__ import with_statement +import pycurl import re from base64 import b64encode -from pycurl import FORM_FILE, LOW_SPEED_TIME from module.network.RequestFactory import getURL, getRequest from module.plugins.Hook import Hook, threaded @@ -76,13 +76,13 @@ class ImageTyperz(Hook): def submit(self, captcha, captchaType="file", match=None): req = getRequest() #raise timeout threshold - req.c.setopt(LOW_SPEED_TIME, 80) + req.c.setopt(pycurl.LOW_SPEED_TIME, 80) try: #@NOTE: Workaround multipart-post bug in HTTPRequest.py if re.match("^\w*$", self.getConfig('passkey')): multipart = True - data = (FORM_FILE, captcha) + data = (pycurl.FORM_FILE, captcha) else: multipart = False with open(captcha, 'rb') as f: diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py index 157b55bbd..7901ca540 100644 --- a/module/plugins/hooks/SkipRev.py +++ b/module/plugins/hooks/SkipRev.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- import re +import urllib +import urlparse from types import MethodType -from urllib import unquote -from urlparse import urlparse from module.PyFile import PyFile from module.plugins.Hook import Hook @@ -43,7 +43,7 @@ class SkipRev(Hook): return pyfile.pluginmodule.getInfo([pyfile.url]).next()[0] else: self.logWarning("Unable to grab file name") - return urlparse(unquote(pyfile.url)).path.split('/')[-1] + return urlparse.urlparse(urllib.unquote(pyfile.url)).path.split('/')[-1] def _pyfile(self, link): -- cgit v1.2.3 From daccea9c91daa4e6bcdaa12c0af92f13d30ba203 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Fri, 1 May 2015 01:10:34 +0200 Subject: [XFileSharingPro] worldbytez.com support --- module/plugins/hooks/XFileSharingPro.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/XFileSharingPro.py b/module/plugins/hooks/XFileSharingPro.py index 4f8b0a846..3205596fa 100644 --- a/module/plugins/hooks/XFileSharingPro.py +++ b/module/plugins/hooks/XFileSharingPro.py @@ -8,7 +8,7 @@ from module.plugins.Hook import Hook class XFileSharingPro(Hook): __name__ = "XFileSharingPro" __type__ = "hook" - __version__ = "0.36" + __version__ = "0.37" __config__ = [("activated" , "bool", "Activated" , True ), ("use_hoster_list" , "bool", "Load listed hosters only" , False), @@ -32,7 +32,7 @@ class XFileSharingPro(Hook): HOSTER_BUILTIN = [#WORKING HOSTERS: "backin.net", "eyesfile.ca", "file4safe.com", "fileband.com", "filedwon.com", "fileparadox.in", "filevice.com", "hostingbulk.com", "junkyvideo.com", "linestorage.com", "ravishare.com", "ryushare.com", - "salefiles.com", "sendmyway.com", "sharesix.com", "thefile.me", "verzend.be", "xvidstage.com", + "salefiles.com", "sendmyway.com", "sharesix.com", "thefile.me", "verzend.be", "worldbytez.com", "xvidstage.com", #NOT TESTED: "101shared.com", "4upfiles.com", "filemaze.ws", "filenuke.com", "linkzhost.com", "mightyupload.com", "rockdizfile.com", "sharebeast.com", "sharerepo.com", "shareswift.com", "uploadbaz.com", "uploadc.com", -- cgit v1.2.3 From 711621f3d3a59f7ec5c2684dfac921e2c5902563 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Fri, 1 May 2015 02:54:22 +0200 Subject: Fix https://github.com/pyload/pyload/issues/1351 --- module/plugins/hooks/AntiVirus.py | 30 +++++++++++++----------------- module/plugins/hooks/ExtractArchive.py | 29 ++++++++++++----------------- module/plugins/hooks/XFileSharingPro.py | 4 ++-- 3 files changed, 27 insertions(+), 36 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/AntiVirus.py b/module/plugins/hooks/AntiVirus.py index 27e3801b5..ac9373a37 100644 --- a/module/plugins/hooks/AntiVirus.py +++ b/module/plugins/hooks/AntiVirus.py @@ -4,6 +4,11 @@ import os import shutil import subprocess +try: + import send2trash +except ImportError: + pass + from module.plugins.Hook import Hook, Expose, threaded from module.utils import fs_encode, save_join @@ -11,7 +16,7 @@ from module.utils import fs_encode, save_join class AntiVirus(Hook): __name__ = "AntiVirus" __type__ = "hook" - __version__ = "0.07" + __version__ = "0.08" #@TODO: add trash option (use Send2Trash lib) __config__ = [("action" , "Antivirus default;Delete;Quarantine", "Manage infected files" , "Antivirus default"), @@ -33,16 +38,6 @@ class AntiVirus(Hook): def setup(self): self.info = {} #@TODO: Remove in 0.4.10 - try: - import send2trash - - except ImportError: - self.logDebug("Send2Trash lib not found") - self.trashable = False - - else: - self.trashable = True - @Expose @threaded @@ -81,13 +76,14 @@ class AntiVirus(Hook): if not self.getConfig('deltotrash'): os.remove(file) - elif self.trashable: - send2trash.send2trash(file) - else: - self.logWarning(_("Unable to move file to trash, move to quarantine instead")) - pyfile.setCustomStatus(_("file moving")) - shutil.move(file, self.getConfig('quardir')) + try: + send2trash.send2trash(file) + + except Exception: + self.logWarning(_("Unable to move file to trash, move to quarantine instead")) + pyfile.setCustomStatus(_("file moving")) + shutil.move(file, self.getConfig('quardir')) elif action == "Quarantine": pyfile.setCustomStatus(_("file moving")) diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index d40b52aa7..05a1e368a 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -6,8 +6,6 @@ import os import sys import traceback -from copy import copy - # monkey patch bug in python 2.6 and lower # http://bugs.python.org/issue6122 , http://bugs.python.org/issue1236 , http://bugs.python.org/issue1731717 if sys.version_info < (2, 7) and os.name != "nt": @@ -45,6 +43,12 @@ if sys.version_info < (2, 7) and os.name != "nt": subprocess.Popen.wait = wait +try: + import send2trash +except ImportError: + pass + +from copy import copy if os.name != "nt": from grp import getgrnam from pwd import getpwnam @@ -106,7 +110,7 @@ class ArchiveQueue(object): class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.41" + __version__ = "1.42" __config__ = [("activated" , "bool" , "Activated" , True ), ("fullpath" , "bool" , "Extract with full paths" , True ), @@ -150,16 +154,6 @@ class ExtractArchive(Hook): self.passwords = [] self.repair = False - try: - import send2trash - - except ImportError: - self.logDebug("Send2Trash lib not found") - self.trashable = False - - else: - self.trashable = True - def coreReady(self): for p in ("UnRar", "SevenZip", "UnZip"): @@ -474,11 +468,12 @@ class ExtractArchive(Hook): if not deltotrash: os.remove(file) - elif self.trashable: - send2trash.send2trash(file) - else: - self.logWarning(_("Unable to move %s to trash") % os.path.basename(f)) + try: + send2trash.send2trash(file) + + except Exception: + self.logWarning(_("Unable to move %s to trash") % os.path.basename(f)) self.logInfo(name, _("Extracting finished")) extracted_files = archive.files or archive.list() diff --git a/module/plugins/hooks/XFileSharingPro.py b/module/plugins/hooks/XFileSharingPro.py index 3205596fa..d80515a22 100644 --- a/module/plugins/hooks/XFileSharingPro.py +++ b/module/plugins/hooks/XFileSharingPro.py @@ -32,11 +32,11 @@ class XFileSharingPro(Hook): HOSTER_BUILTIN = [#WORKING HOSTERS: "backin.net", "eyesfile.ca", "file4safe.com", "fileband.com", "filedwon.com", "fileparadox.in", "filevice.com", "hostingbulk.com", "junkyvideo.com", "linestorage.com", "ravishare.com", "ryushare.com", - "salefiles.com", "sendmyway.com", "sharesix.com", "thefile.me", "verzend.be", "worldbytez.com", "xvidstage.com", + "salefiles.com", "sendmyway.com", "sharesix.com", "thefile.me", "verzend.be", "xvidstage.com", #NOT TESTED: "101shared.com", "4upfiles.com", "filemaze.ws", "filenuke.com", "linkzhost.com", "mightyupload.com", "rockdizfile.com", "sharebeast.com", "sharerepo.com", "shareswift.com", "uploadbaz.com", "uploadc.com", - "vidbull.com", "zalaa.com", "zomgupload.com", + "vidbull.com", "worldbytez.com", "zalaa.com", "zomgupload.com", #NOT WORKING: "amonshare.com", "banicrazy.info", "boosterking.com", "host4desi.com", "laoupload.com", "rd-fs.com"] CRYPTER_BUILTIN = ["junocloud.me", "rapidfileshare.net"] -- cgit v1.2.3 From fc36aa1a426fb8c75897debdc6cb4104dbff8200 Mon Sep 17 00:00:00 2001 From: GammaC0de <GammaC0de@users.noreply.github.com> Date: Sat, 2 May 2015 22:36:02 +0300 Subject: [AntiVirus] report missing send2trash --- module/plugins/hooks/AntiVirus.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/AntiVirus.py b/module/plugins/hooks/AntiVirus.py index ac9373a37..69dffbe73 100644 --- a/module/plugins/hooks/AntiVirus.py +++ b/module/plugins/hooks/AntiVirus.py @@ -16,7 +16,7 @@ from module.utils import fs_encode, save_join class AntiVirus(Hook): __name__ = "AntiVirus" __type__ = "hook" - __version__ = "0.08" + __version__ = "0.09" #@TODO: add trash option (use Send2Trash lib) __config__ = [("action" , "Antivirus default;Delete;Quarantine", "Manage infected files" , "Antivirus default"), @@ -80,8 +80,13 @@ class AntiVirus(Hook): try: send2trash.send2trash(file) - except Exception: - self.logWarning(_("Unable to move file to trash, move to quarantine instead")) + except NameError: + self.logWarning(_("Send2Trash lib not found, moving to quarantine instead")) + pyfile.setCustomStatus(_("file moving")) + shutil.move(file, self.getConfig('quardir')) + + except Exception: + self.logWarning(_("Unable to move file to trash, moving to quarantine instead")) pyfile.setCustomStatus(_("file moving")) shutil.move(file, self.getConfig('quardir')) -- cgit v1.2.3 From dec360bee84f046bf40612173ec4e74aebd60599 Mon Sep 17 00:00:00 2001 From: GammaC0de <GammaC0de@users.noreply.github.com> Date: Sat, 2 May 2015 22:40:55 +0300 Subject: [ExtractArchive] report missing send2trash --- module/plugins/hooks/ExtractArchive.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 05a1e368a..609d0ad62 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -110,7 +110,7 @@ class ArchiveQueue(object): class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.42" + __version__ = "1.43" __config__ = [("activated" , "bool" , "Activated" , True ), ("fullpath" , "bool" , "Extract with full paths" , True ), @@ -472,6 +472,9 @@ class ExtractArchive(Hook): try: send2trash.send2trash(file) + except NameError: + self.logWarning(_("Unable to move %s to trash: Send2Trash lib not found") % os.path.basename(f)) + except Exception: self.logWarning(_("Unable to move %s to trash") % os.path.basename(f)) -- cgit v1.2.3 From c6932a1ea6e44867e2b2caedfad444d4b34aea4f Mon Sep 17 00:00:00 2001 From: GammaC0de <GammaC0de@users.noreply.github.com> Date: Mon, 4 May 2015 01:33:47 +0300 Subject: more verbose --- module/plugins/hooks/ExtractArchive.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 609d0ad62..d0a84364a 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -475,8 +475,8 @@ class ExtractArchive(Hook): except NameError: self.logWarning(_("Unable to move %s to trash: Send2Trash lib not found") % os.path.basename(f)) - except Exception: - self.logWarning(_("Unable to move %s to trash") % os.path.basename(f)) + except Exception, e: + self.logWarning(_("Unable to move %s to trash: %s") % (os.path.basename(f), e.message)) self.logInfo(name, _("Extracting finished")) extracted_files = archive.files or archive.list() -- cgit v1.2.3 From dc7c81b6ab0813745ee03116c27f870138b3fc7f Mon Sep 17 00:00:00 2001 From: GammaC0de <GammaC0de@users.noreply.github.com> Date: Mon, 4 May 2015 01:36:23 +0300 Subject: more verbose --- module/plugins/hooks/AntiVirus.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/AntiVirus.py b/module/plugins/hooks/AntiVirus.py index 69dffbe73..6823729af 100644 --- a/module/plugins/hooks/AntiVirus.py +++ b/module/plugins/hooks/AntiVirus.py @@ -85,8 +85,8 @@ class AntiVirus(Hook): pyfile.setCustomStatus(_("file moving")) shutil.move(file, self.getConfig('quardir')) - except Exception: - self.logWarning(_("Unable to move file to trash, moving to quarantine instead")) + except Exception, e: + self.logWarning(_("Unable to move file to trash: %s, moving to quarantine instead") % e.message) pyfile.setCustomStatus(_("file moving")) shutil.move(file, self.getConfig('quardir')) -- cgit v1.2.3 From e26ba64714e84745db1f6dfc73ccc8c68ad4abcc Mon Sep 17 00:00:00 2001 From: GammaC0de <GammaC0de@users.noreply.github.com> Date: Mon, 4 May 2015 02:22:06 +0300 Subject: even more --- module/plugins/hooks/ExtractArchive.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index d0a84364a..5b90b28fc 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -478,6 +478,9 @@ class ExtractArchive(Hook): except Exception, e: self.logWarning(_("Unable to move %s to trash: %s") % (os.path.basename(f), e.message)) + else: + self.logDebug(_("Successfully moved %s to trash") % os.path.basename(f)) + self.logInfo(name, _("Extracting finished")) extracted_files = archive.files or archive.list() -- cgit v1.2.3 From ee360021434803991226d1cc36e7221fb9cbc418 Mon Sep 17 00:00:00 2001 From: GammaC0de <GammaC0de@users.noreply.github.com> Date: Mon, 4 May 2015 02:24:23 +0300 Subject: even more --- module/plugins/hooks/AntiVirus.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/AntiVirus.py b/module/plugins/hooks/AntiVirus.py index 6823729af..c620f556d 100644 --- a/module/plugins/hooks/AntiVirus.py +++ b/module/plugins/hooks/AntiVirus.py @@ -85,11 +85,14 @@ class AntiVirus(Hook): pyfile.setCustomStatus(_("file moving")) shutil.move(file, self.getConfig('quardir')) - except Exception, e: + except Exception, e: self.logWarning(_("Unable to move file to trash: %s, moving to quarantine instead") % e.message) pyfile.setCustomStatus(_("file moving")) shutil.move(file, self.getConfig('quardir')) + else: + self.logDebug(_("Successfully moved file to trash")) + elif action == "Quarantine": pyfile.setCustomStatus(_("file moving")) shutil.move(file, self.getConfig('quardir')) -- cgit v1.2.3 From 8483aacbcd7f3f4c6ad92ef2255b449b88d64a35 Mon Sep 17 00:00:00 2001 From: GammaC0de <GammaC0de@users.noreply.github.com> Date: Tue, 5 May 2015 01:23:31 +0300 Subject: fix bug causing `extractQueued` called twice --- module/plugins/hooks/ExtractArchive.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 05a1e368a..62eb36714 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -187,6 +187,11 @@ class ExtractArchive(Hook): @threaded def extractQueued(self, thread): + if self.extracting: #@NOTE: doing the check here for safty (called by coreReady) + return + + self.extracting = True + packages = self.queue.get() while packages: if self.lastPackage: #: called from allDownloadsProcessed @@ -200,6 +205,8 @@ class ExtractArchive(Hook): packages = self.queue.get() #: check for packages added during extraction + self.extracting = False + @Expose def extractPackage(self, *ids): @@ -222,7 +229,7 @@ class ExtractArchive(Hook): def allDownloadsProcessed(self): self.lastPackage = True - if not self.extracting: + if self.getConfig('waitall') and not self.extracting: self.extractQueued() @@ -231,8 +238,6 @@ class ExtractArchive(Hook): if not ids: return False - self.extracting = True - processed = [] extracted = [] failed = [] @@ -374,7 +379,6 @@ class ExtractArchive(Hook): self.queue.remove(pid) - self.extracting = False return True if not failed else False -- cgit v1.2.3 From e3d3ad079d8af1806a475020aeb7e9fdc5a26600 Mon Sep 17 00:00:00 2001 From: GammaC0de <GammaC0de@users.noreply.github.com> Date: Tue, 5 May 2015 01:33:17 +0300 Subject: Update ExtractArchive.py --- module/plugins/hooks/ExtractArchive.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 62eb36714..bd8153a73 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -110,7 +110,7 @@ class ArchiveQueue(object): class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.42" + __version__ = "1.43" __config__ = [("activated" , "bool" , "Activated" , True ), ("fullpath" , "bool" , "Extract with full paths" , True ), -- cgit v1.2.3 From 430630fc3158e5dc5412824095f058a0be295edb Mon Sep 17 00:00:00 2001 From: GammaC0de <GammaC0de@users.noreply.github.com> Date: Tue, 5 May 2015 20:50:50 +0300 Subject: Update ExtractArchive.py --- module/plugins/hooks/ExtractArchive.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 07a2ba228..5b9e3f30b 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -110,7 +110,7 @@ class ArchiveQueue(object): class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.43" + __version__ = "1.44" __config__ = [("activated" , "bool" , "Activated" , True ), ("fullpath" , "bool" , "Extract with full paths" , True ), -- cgit v1.2.3 From 78e87559dd0afd48528d599c5c7b79d5c154b718 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Wed, 6 May 2015 02:08:16 +0200 Subject: [LinkdecrypterComHook] Fix https://github.com/pyload/pyload/issues/1397 --- module/plugins/hooks/LinkdecrypterComHook.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/LinkdecrypterComHook.py b/module/plugins/hooks/LinkdecrypterComHook.py index 596a397a4..d0ec83c0b 100644 --- a/module/plugins/hooks/LinkdecrypterComHook.py +++ b/module/plugins/hooks/LinkdecrypterComHook.py @@ -8,7 +8,7 @@ from module.plugins.internal.MultiHook import MultiHook class LinkdecrypterComHook(MultiHook): __name__ = "LinkdecrypterComHook" __type__ = "hook" - __version__ = "1.04" + __version__ = "1.05" __config__ = [("activated" , "bool" , "Activated" , True ), ("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), @@ -22,5 +22,11 @@ class LinkdecrypterComHook(MultiHook): def getCrypters(self): - return re.search(r'>Supported\(\d+\)</b>: <i>(.[\w.\-, ]+)', + list = re.search(r'>Supported\(\d+\)</b>: <i>(.[\w.\-, ]+)', self.getURL("http://linkdecrypter.com/", decode=True).replace("(g)", "")).group(1).split(', ') + try: + list.remove("download.serienjunkies.org") + except ValueError: + pass + + return list -- cgit v1.2.3 From d52ddee1d43b4be610b265fbe87911494d1364ad Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Sat, 9 May 2015 03:29:27 +0200 Subject: [MultiHook] Remove unbound method 'getCrypters' --- module/plugins/hooks/LinkdecrypterComHook.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/LinkdecrypterComHook.py b/module/plugins/hooks/LinkdecrypterComHook.py index d0ec83c0b..b2eaece62 100644 --- a/module/plugins/hooks/LinkdecrypterComHook.py +++ b/module/plugins/hooks/LinkdecrypterComHook.py @@ -8,7 +8,7 @@ from module.plugins.internal.MultiHook import MultiHook class LinkdecrypterComHook(MultiHook): __name__ = "LinkdecrypterComHook" __type__ = "hook" - __version__ = "1.05" + __version__ = "1.06" __config__ = [("activated" , "bool" , "Activated" , True ), ("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), @@ -21,7 +21,7 @@ class LinkdecrypterComHook(MultiHook): __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - def getCrypters(self): + def getHosters(self): list = re.search(r'>Supported\(\d+\)</b>: <i>(.[\w.\-, ]+)', self.getURL("http://linkdecrypter.com/", decode=True).replace("(g)", "")).group(1).split(', ') try: -- cgit v1.2.3 From c4810d1dbf367c4859a00c18b640fdb86a18ff8f Mon Sep 17 00:00:00 2001 From: GammaC0de <GammaC0de@users.noreply.github.com> Date: Sat, 9 May 2015 22:38:09 +0300 Subject: [ClickAndLoad] fix bug when webinterface uses SSL --- module/plugins/hooks/ClickAndLoad.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 2ddd66daa..1fa89840b 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -3,6 +3,11 @@ import socket import time +try: + import ssl +except ImportError: + pass + from threading import Lock from module.plugins.Hook import Hook, threaded @@ -24,7 +29,7 @@ def forward(source, destination): class ClickAndLoad(Hook): __name__ = "ClickAndLoad" __type__ = "hook" - __version__ = "0.41" + __version__ = "0.42" __config__ = [("activated", "bool", "Activated" , True), ("port" , "int" , "Port" , 9666), @@ -79,6 +84,21 @@ class ClickAndLoad(Hook): self.logDebug("Connection from %s:%s" % client_addr) server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + + if self.config['webinterface']['https']: + try: + server_socket = ssl.wrap_socket(server_socket) + + except NameError: + self.logError(_("pyLoad's webinterface is configured to use HTTPS, Please install python's ssl lib or + client_socket.close() #: reset the connection. + continue + + except Exception, e: + self.logError(_("SSL error: %s") % e.message) + client_socket.close() #: reset the connection. + continue + server_socket.connect(("127.0.0.1", webport)) self.manager.startThread(forward, client_socket, server_socket) -- cgit v1.2.3 From d5cee0bbabfd60e020cd2cd9248c41b913e438c3 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Sat, 9 May 2015 22:27:11 +0200 Subject: [UnrestrictLi] Mark as dead --- module/plugins/hooks/UnrestrictLiHook.py | 28 ---------------------------- 1 file changed, 28 deletions(-) delete mode 100644 module/plugins/hooks/UnrestrictLiHook.py (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/UnrestrictLiHook.py b/module/plugins/hooks/UnrestrictLiHook.py deleted file mode 100644 index f1ffd1886..000000000 --- a/module/plugins/hooks/UnrestrictLiHook.py +++ /dev/null @@ -1,28 +0,0 @@ -# -*- coding: utf-8 -*- - -from module.common.json_layer import json_loads -from module.plugins.internal.MultiHook import MultiHook - - -class UnrestrictLiHook(MultiHook): - __name__ = "UnrestrictLiHook" - __type__ = "hook" - __version__ = "0.05" - - __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), - ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), - ("revertfailed" , "bool" , "Revert to standard download if fails", True ), - ("reload" , "bool" , "Reload plugin list" , True ), - ("reloadinterval", "int" , "Reload interval in hours" , 12 ), - ("history" , "bool" , "Delete History" , False)] - - __description__ = """Unrestrict.li hook plugin""" - __license__ = "GPLv3" - __authors__ = [("stickell", "l.stickell@yahoo.it")] - - - def getHosters(self): - json_data = self.getURL("http://unrestrict.li/api/jdownloader/hosts.php", get={'format': "json"}) - json_data = json_loads(json_data) - - return [element['host'] for element in json_data['result']] -- cgit v1.2.3 From 1582e816a8cb9a67f420cc9bf69cf2bba6dfbd04 Mon Sep 17 00:00:00 2001 From: GammaC0de <GammaC0de@users.noreply.github.com> Date: Sat, 9 May 2015 23:46:47 +0300 Subject: Update ClickAndLoad.py --- module/plugins/hooks/ClickAndLoad.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 1fa89840b..eb242de1f 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -90,7 +90,7 @@ class ClickAndLoad(Hook): server_socket = ssl.wrap_socket(server_socket) except NameError: - self.logError(_("pyLoad's webinterface is configured to use HTTPS, Please install python's ssl lib or + self.logError(_("pyLoad's webinterface is configured to use HTTPS, Please install python's ssl lib or disable HTTPS")) client_socket.close() #: reset the connection. continue -- cgit v1.2.3 From f22a5c784adcaf3e434fca78fb7eb0141b51c694 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Sat, 9 May 2015 22:53:31 +0200 Subject: [ClickAndLoad] Version up --- module/plugins/hooks/ClickAndLoad.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index eb242de1f..a7862045e 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -29,7 +29,7 @@ def forward(source, destination): class ClickAndLoad(Hook): __name__ = "ClickAndLoad" __type__ = "hook" - __version__ = "0.42" + __version__ = "0.43" __config__ = [("activated", "bool", "Activated" , True), ("port" , "int" , "Port" , 9666), -- cgit v1.2.3 From 41faf73af4deb8dcd73e0c2e55073f1ef7656a7f Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Mon, 18 May 2015 09:48:07 +0200 Subject: [XFSHoster] Fix https://github.com/pyload/pyload/issues/1296 --- module/plugins/hooks/UserAgentSwitcher.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/UserAgentSwitcher.py b/module/plugins/hooks/UserAgentSwitcher.py index 912c2ef09..0b36e38ec 100644 --- a/module/plugins/hooks/UserAgentSwitcher.py +++ b/module/plugins/hooks/UserAgentSwitcher.py @@ -15,10 +15,10 @@ class UserAgentSwitcher(Hook): __type__ = "hook" __version__ = "0.04" - __config__ = [("activated", "bool", "Activated" , True ), - ("uaf" , "file", "Random user-agents file" , "" ), - ("uar" , "bool", "Random user-agent" , False ), - ("uas" , "str" , "Custom user-agent string", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:37.0) Gecko/20100101 Firefox/37.0")] + __config__ = [("activated", "bool", "Activated" , True ), + ("uaf" , "file", "Random user-agent by file" , "" ), + ("uar" , "bool", "Random user-agent" , False ), + ("uas" , "str" , "Custom user-agent string" , "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:37.0) Gecko/20100101 Firefox/37.0")] __description__ = """Custom user-agent""" __license__ = "GPLv3" -- cgit v1.2.3 From 339b2e07d78b15ca014ee12f1501cdb235d9b064 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Mon, 18 May 2015 11:50:43 +0200 Subject: [SimpleHoster] Fix create_getInfo --- module/plugins/hooks/UserAgentSwitcher.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/UserAgentSwitcher.py b/module/plugins/hooks/UserAgentSwitcher.py index 0b36e38ec..6915fc0f4 100644 --- a/module/plugins/hooks/UserAgentSwitcher.py +++ b/module/plugins/hooks/UserAgentSwitcher.py @@ -15,10 +15,10 @@ class UserAgentSwitcher(Hook): __type__ = "hook" __version__ = "0.04" - __config__ = [("activated", "bool", "Activated" , True ), - ("uaf" , "file", "Random user-agent by file" , "" ), - ("uar" , "bool", "Random user-agent" , False ), - ("uas" , "str" , "Custom user-agent string" , "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:37.0) Gecko/20100101 Firefox/37.0")] + __config__ = [("activated", "bool", "Activated" , True ), + ("uaf" , "file", "Random user-agent by file", "" ), + ("uar" , "bool", "Random user-agent" , False ), + ("uas" , "str" , "Custom user-agent string" , "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0")] __description__ = """Custom user-agent""" __license__ = "GPLv3" -- cgit v1.2.3 From c3f05a91cb522e7dabc9dbbc4dd7a32d2cd766b3 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Sat, 23 May 2015 05:45:09 +0200 Subject: [UserAgentSwitcher] Fixup --- module/plugins/hooks/UserAgentSwitcher.py | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/UserAgentSwitcher.py b/module/plugins/hooks/UserAgentSwitcher.py index 6915fc0f4..0a0072e63 100644 --- a/module/plugins/hooks/UserAgentSwitcher.py +++ b/module/plugins/hooks/UserAgentSwitcher.py @@ -1,24 +1,18 @@ # -*- coding: utf-8 -*- -from __future__ import with_statement - -import os import pycurl -import random from module.plugins.Hook import Hook -from module.utils import fs_encode +from module.utils import encode class UserAgentSwitcher(Hook): __name__ = "UserAgentSwitcher" __type__ = "hook" - __version__ = "0.04" + __version__ = "0.05" __config__ = [("activated", "bool", "Activated" , True ), - ("uaf" , "file", "Random user-agent by file", "" ), - ("uar" , "bool", "Random user-agent" , False ), - ("uas" , "str" , "Custom user-agent string" , "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0")] + ("useragent", "str" , "Custom user-agent string" , "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0")] __description__ = """Custom user-agent""" __license__ = "GPLv3" @@ -33,15 +27,7 @@ class UserAgentSwitcher(Hook): def downloadPreparing(self, pyfile): - uar = self.getConfig('uar') - uaf = fs_encode(self.getConfig('uaf')) - - if uar and os.path.isfile(uaf): - with open(uaf) as f: - uas = random.choice([ua for ua in f.read().splitlines()]) - else: - uas = self.getConfig('uas') - - if uas: - self.logDebug("Use custom user-agent string: " + uas) - pyfile.plugin.req.http.c.setopt(pycurl.USERAGENT, uas.encode('utf-8')) + useragent = encode(self.getConfig('useragent')) + if useragent: + self.logDebug("Use custom user-agent string: " + useragent) + pyfile.plugin.req.http.c.setopt(pycurl.USERAGENT, useragent) -- cgit v1.2.3 From fac22f3f706f247536ee11c15ae63b0988a2cc6b Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Mon, 25 May 2015 14:06:56 +0200 Subject: [UserAgentSwitcher] Fixup (2) --- module/plugins/hooks/UserAgentSwitcher.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/UserAgentSwitcher.py b/module/plugins/hooks/UserAgentSwitcher.py index 0a0072e63..16d38d2cc 100644 --- a/module/plugins/hooks/UserAgentSwitcher.py +++ b/module/plugins/hooks/UserAgentSwitcher.py @@ -9,7 +9,7 @@ from module.utils import encode class UserAgentSwitcher(Hook): __name__ = "UserAgentSwitcher" __type__ = "hook" - __version__ = "0.05" + __version__ = "0.06" __config__ = [("activated", "bool", "Activated" , True ), ("useragent", "str" , "Custom user-agent string" , "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0")] @@ -27,7 +27,7 @@ class UserAgentSwitcher(Hook): def downloadPreparing(self, pyfile): - useragent = encode(self.getConfig('useragent')) + useragent = self.getConfig('useragent').encode("utf8", "replace") #@TODO: Remove `encode` in 0.4.10 if useragent: self.logDebug("Use custom user-agent string: " + useragent) pyfile.plugin.req.http.c.setopt(pycurl.USERAGENT, useragent) -- cgit v1.2.3 From 8fdf78569ba68c8ee4849cbfc144a9fbdac263f5 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Mon, 25 May 2015 17:04:49 +0200 Subject: [UserAgentSwitcher] Fixup (3) --- module/plugins/hooks/UserAgentSwitcher.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/UserAgentSwitcher.py b/module/plugins/hooks/UserAgentSwitcher.py index 16d38d2cc..5f9fd5212 100644 --- a/module/plugins/hooks/UserAgentSwitcher.py +++ b/module/plugins/hooks/UserAgentSwitcher.py @@ -3,13 +3,12 @@ import pycurl from module.plugins.Hook import Hook -from module.utils import encode class UserAgentSwitcher(Hook): __name__ = "UserAgentSwitcher" __type__ = "hook" - __version__ = "0.06" + __version__ = "0.07" __config__ = [("activated", "bool", "Activated" , True ), ("useragent", "str" , "Custom user-agent string" , "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0")] -- cgit v1.2.3 From 9d0fef4d50c9f46daf00e50814a57b3000097ac8 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Wed, 27 May 2015 23:17:33 +0200 Subject: Fix https://github.com/pyload/pyload/issues/1428 --- module/plugins/hooks/AndroidPhoneNotify.py | 12 +++++++++--- module/plugins/hooks/WindowsPhoneNotify.py | 18 +++++++++++------- 2 files changed, 20 insertions(+), 10 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/AndroidPhoneNotify.py b/module/plugins/hooks/AndroidPhoneNotify.py index 67a0ea4f0..9fea0b8e6 100644 --- a/module/plugins/hooks/AndroidPhoneNotify.py +++ b/module/plugins/hooks/AndroidPhoneNotify.py @@ -9,7 +9,7 @@ from module.plugins.Hook import Hook, Expose class AndroidPhoneNotify(Hook): __name__ = "AndroidPhoneNotify" __type__ = "hook" - __version__ = "0.07" + __version__ = "0.08" __config__ = [("apikey" , "str" , "API key" , "" ), ("notifycaptcha" , "bool", "Notify captcha request" , True ), @@ -44,6 +44,10 @@ class AndroidPhoneNotify(Hook): self.notify(_("Plugins updated"), str(type_plugins)) + def coreReady(self): + self.key = self.getConfig('apikey') + + def coreExiting(self): if not self.getConfig('notifyexit'): return @@ -80,8 +84,9 @@ class AndroidPhoneNotify(Hook): def notify(self, event, msg="", - key=self.getConfig('apikey')): + key=None): + key = key or self.key if not key: return @@ -99,7 +104,6 @@ class AndroidPhoneNotify(Hook): elif self.notifications >= self.getConf("sendpermin"): return - getURL("http://www.notifymyandroid.com/publicapi/notify", get={'apikey' : key, 'application': "pyLoad", @@ -108,3 +112,5 @@ class AndroidPhoneNotify(Hook): self.last_notify = time.time() self.notifications += 1 + + return True diff --git a/module/plugins/hooks/WindowsPhoneNotify.py b/module/plugins/hooks/WindowsPhoneNotify.py index e61057f9f..da960591c 100644 --- a/module/plugins/hooks/WindowsPhoneNotify.py +++ b/module/plugins/hooks/WindowsPhoneNotify.py @@ -9,10 +9,10 @@ from module.plugins.Hook import Hook, Expose class WindowsPhoneNotify(Hook): __name__ = "WindowsPhoneNotify" __type__ = "hook" - __version__ = "0.09" + __version__ = "0.10" - __config__ = [("id" , "str" , "Push ID" , "" ), - ("url" , "str" , "Push url" , "" ), + __config__ = [("push-id" , "str" , "Push ID" , "" ), + ("push-url" , "str" , "Push url" , "" ), ("notifycaptcha" , "bool", "Notify captcha request" , True ), ("notifypackage" , "bool", "Notify package finished" , True ), ("notifyprocessed", "bool", "Notify packages processed" , True ), @@ -45,6 +45,10 @@ class WindowsPhoneNotify(Hook): self.notify(_("Plugins updated"), str(type_plugins)) + def coreReady(self): + self.key = (self.getConfig('push-id'), self.getConfig('push-url')) + + def coreExiting(self): if not self.getConfig('notifyexit'): return @@ -87,10 +91,9 @@ class WindowsPhoneNotify(Hook): def notify(self, event, msg="", - key=(self.getConfig('id'), self.getConfig('url'))): - - id, url = key + key=(None, None)): + id, url = key or self.key if not id or not url: return @@ -108,7 +111,6 @@ class WindowsPhoneNotify(Hook): elif self.notifications >= self.getConf("sendpermin"): return - request = self.getXmlData("%s: %s" % (event, msg) if msg else event) webservice = httplib.HTTP(url) @@ -124,3 +126,5 @@ class WindowsPhoneNotify(Hook): self.last_notify = time.time() self.notifications += 1 + + return True -- cgit v1.2.3 From 9f3ab57ec994deb24cd31a1dfbd338eb71bffc8c Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Wed, 27 May 2015 23:46:29 +0200 Subject: Spare code cosmetics --- module/plugins/hooks/AndroidPhoneNotify.py | 6 ++++-- module/plugins/hooks/DeleteFinished.py | 5 ++--- module/plugins/hooks/ExternalScripts.py | 11 ++++++----- module/plugins/hooks/ExtractArchive.py | 3 +-- module/plugins/hooks/JustPremium.py | 2 +- module/plugins/hooks/RestartFailed.py | 5 ++--- module/plugins/hooks/UpdateManager.py | 7 ++++--- module/plugins/hooks/WindowsPhoneNotify.py | 6 ++++-- module/plugins/hooks/XFileSharingPro.py | 2 +- 9 files changed, 25 insertions(+), 22 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/AndroidPhoneNotify.py b/module/plugins/hooks/AndroidPhoneNotify.py index 9fea0b8e6..a8a1cff72 100644 --- a/module/plugins/hooks/AndroidPhoneNotify.py +++ b/module/plugins/hooks/AndroidPhoneNotify.py @@ -27,12 +27,14 @@ class AndroidPhoneNotify(Hook): ("Walter Purcaro", "vuolter@gmail.com" )] - event_list = ["allDownloadsProcessed", "plugin_updated"] interval = 0 #@TODO: Remove in 0.4.10 def setup(self): - self.info = {} #@TODO: Remove in 0.4.10 + self.info = {} #@TODO: Remove in 0.4.10 + + self.event_list = ["allDownloadsProcessed", "plugin_updated"] + self.last_notify = 0 self.notifications = 0 diff --git a/module/plugins/hooks/DeleteFinished.py b/module/plugins/hooks/DeleteFinished.py index bde4ca259..be17c3c0f 100644 --- a/module/plugins/hooks/DeleteFinished.py +++ b/module/plugins/hooks/DeleteFinished.py @@ -17,14 +17,13 @@ class DeleteFinished(Hook): __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - # event_list = ["pluginConfigChanged"] - MIN_CHECK_INTERVAL = 1 * 60 * 60 #: 1 hour ## overwritten methods ## def setup(self): - self.info = {} #@TODO: Remove in 0.4.10 + self.info = {} #@TODO: Remove in 0.4.10 + # self.event_list = ["pluginConfigChanged"] self.interval = self.MIN_CHECK_INTERVAL diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index be0857009..a0815499b 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -23,11 +23,6 @@ class ExternalScripts(Hook): ("Walter Purcaro", "vuolter@gmail.com")] - event_list = ["archive_extract_failed", "archive_extracted" , - "package_extract_failed", "package_extracted" , - "all_archives_extracted", "all_archives_processed", - "allDownloadsFinished" , "allDownloadsProcessed" , - "packageDeleted"] interval = 0 #@TODO: Remove in 0.4.10 @@ -35,6 +30,12 @@ class ExternalScripts(Hook): self.info = {'oldip': None} self.scripts = {} + self.event_list = ["archive_extract_failed", "archive_extracted" , + "package_extract_failed", "package_extracted" , + "all_archives_extracted", "all_archives_processed", + "allDownloadsFinished" , "allDownloadsProcessed" , + "packageDeleted"] + folders = ["pyload_start", "pyload_restart", "pyload_stop", "before_reconnect", "after_reconnect", "download_preparing", "download_failed", "download_finished", diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 5b9e3f30b..3e371ec2b 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -136,13 +136,12 @@ class ExtractArchive(Hook): ("Immenz" , "immenz@gmx.net" )] - event_list = ["allDownloadsProcessed","packageDeleted"] - NAME_REPLACEMENTS = [(r'\.part\d+\.rar$', ".part.rar")] def setup(self): self.info = {} #@TODO: Remove in 0.4.10 + self.event_list = ["allDownloadsProcessed","packageDeleted"] self.queue = ArchiveQueue(self, "Queue") self.failed = ArchiveQueue(self, "Failed") diff --git a/module/plugins/hooks/JustPremium.py b/module/plugins/hooks/JustPremium.py index d18afc524..f66747f82 100644 --- a/module/plugins/hooks/JustPremium.py +++ b/module/plugins/hooks/JustPremium.py @@ -20,12 +20,12 @@ class JustPremium(Hook): ("immenz" , "immenz@gmx.net" )] - event_list = ["linksAdded"] interval = 0 #@TODO: Remove in 0.4.10 def setup(self): self.info = {} #@TODO: Remove in 0.4.10 + self.event_list = ["linksAdded"] def linksAdded(self, links, pid): diff --git a/module/plugins/hooks/RestartFailed.py b/module/plugins/hooks/RestartFailed.py index cab986d9e..865af2a6b 100644 --- a/module/plugins/hooks/RestartFailed.py +++ b/module/plugins/hooks/RestartFailed.py @@ -15,8 +15,6 @@ class RestartFailed(Hook): __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - # event_list = ["pluginConfigChanged"] - MIN_CHECK_INTERVAL = 15 * 60 #: 15 minutes @@ -37,7 +35,8 @@ class RestartFailed(Hook): def setup(self): - self.info = {} #@TODO: Remove in 0.4.10 + self.info = {} #@TODO: Remove in 0.4.10 + # self.event_list = ["pluginConfigChanged"] self.interval = self.MIN_CHECK_INTERVAL diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index 5779e7c80..ceba8e792 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -49,8 +49,6 @@ class UpdateManager(Hook): SERVER_URL = "http://updatemanager.pyload.org" MIN_CHECK_INTERVAL = 3 * 60 * 60 #: 3 hours - event_list = ["allDownloadsProcessed"] - def coreReady(self): if self.checkonstart: @@ -60,10 +58,13 @@ class UpdateManager(Hook): def setup(self): - self.interval = 10 self.info = {'pyload': False, 'version': None, 'plugins': False, 'last_check': time.time()} self.mtimes = {} #: store modification time for each plugin + self.event_list = ["allDownloadsProcessed"] + + self.interval = 10 + if self.getConfig('checkonstart'): self.core.api.pauseServer() self.checkonstart = True diff --git a/module/plugins/hooks/WindowsPhoneNotify.py b/module/plugins/hooks/WindowsPhoneNotify.py index da960591c..8f66761f6 100644 --- a/module/plugins/hooks/WindowsPhoneNotify.py +++ b/module/plugins/hooks/WindowsPhoneNotify.py @@ -28,12 +28,14 @@ class WindowsPhoneNotify(Hook): ("Walter Purcaro", "vuolter@gmail.com" )] - event_list = ["allDownloadsProcessed", "plugin_updated"] interval = 0 #@TODO: Remove in 0.4.10 def setup(self): - self.info = {} #@TODO: Remove in 0.4.10 + self.info = {} #@TODO: Remove in 0.4.10 + + self.event_list = ["allDownloadsProcessed", "plugin_updated"] + self.last_notify = 0 self.notifications = 0 diff --git a/module/plugins/hooks/XFileSharingPro.py b/module/plugins/hooks/XFileSharingPro.py index d80515a22..7443266b3 100644 --- a/module/plugins/hooks/XFileSharingPro.py +++ b/module/plugins/hooks/XFileSharingPro.py @@ -22,7 +22,6 @@ class XFileSharingPro(Hook): __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - # event_list = ["pluginConfigChanged"] interval = 0 #@TODO: Remove in 0.4.10 regexp = {'hoster' : (r'https?://(?:www\.)?(?P<DOMAIN>[\w\-.^_]{3,63}(?:\.[a-zA-Z]{2,})(?:\:\d+)?)/(?:embed-)?\w{12}(?:\W|$)', r'https?://(?:[^/]+\.)?(?P<DOMAIN>%s)/(?:embed-)?\w+'), @@ -48,6 +47,7 @@ class XFileSharingPro(Hook): def setup(self): self.info = {} #@TODO: Remove in 0.4.10 + # self.event_list = ["pluginConfigChanged"] def coreReady(self): -- cgit v1.2.3 From 2b484935a076b0323bfcfeaac2935247ba2bfd35 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@users.noreply.github.com> Date: Thu, 28 May 2015 00:21:26 +0200 Subject: [UpdateManager] Fix https://github.com/pyload/pyload/issues/1432 --- module/plugins/hooks/UpdateManager.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'module/plugins/hooks') diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index ceba8e792..98d602226 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -29,7 +29,7 @@ def exists(path): class UpdateManager(Hook): __name__ = "UpdateManager" __type__ = "hook" - __version__ = "0.51" + __version__ = "0.52" __config__ = [("activated" , "bool", "Activated" , True ), ("checkinterval", "int" , "Check interval in hours" , 8 ), @@ -52,7 +52,10 @@ class UpdateManager(Hook): def coreReady(self): if self.checkonstart: + self.core.api.pauseServer() self.update() + if self.do_restart is False: + self.core.api.unpauseServer() self.initPeriodical() @@ -136,16 +139,13 @@ class UpdateManager(Hook): def update(self): """ check for updates """ - self.core.api.pauseServer() - if self._update() is 2 and self.getConfig('autorestart'): if not self.core.api.statusDownloads(): self.core.api.restart() else: self.do_restart = True self.logWarning(_("Downloads are active, will restart once the download is done")) - else: - self.core.api.unpauseServer() + self.core.api.pauseServer() def _update(self): -- cgit v1.2.3