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/JustPremium.py') 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/JustPremium.py') 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 f23019b934446275b97f0c5fecf7709c19e557f9 Mon Sep 17 00:00:00 2001 From: Walter Purcaro 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/JustPremium.py') 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 . - @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 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/JustPremium.py') 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 a206e9103c6d791caf780be3de6ce6ceda13b793 Mon Sep 17 00:00:00 2001 From: Walter Purcaro 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/JustPremium.py') 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 63651d0c9b32c85c1a55dbf6b5299881170dccff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20H=C3=B6rnlein?= 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/JustPremium.py') 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 e265a18ec18c4260531f977c98ebb13d2074380b Mon Sep 17 00:00:00 2001 From: Walter Purcaro 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/JustPremium.py') 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