summaryrefslogtreecommitdiffstats
path: root/module/plugins
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@gmail.com> 2014-12-23 13:13:42 +0100
committerGravatar Walter Purcaro <vuolter@gmail.com> 2014-12-23 13:13:42 +0100
commit57a319563651a07bf8265ab52da0d7375191319c (patch)
tree1a65efc0eefc444ba102eeab2cd04112349368d5 /module/plugins
parent[ExpertDecoders] Fix typo (thx DKeppi) (diff)
downloadpyload-57a319563651a07bf8265ab52da0d7375191319c.tar.xz
Rename MultiHoster plugin to MultiHook
Diffstat (limited to 'module/plugins')
-rw-r--r--module/plugins/hooks/AlldebridCom.py6
-rw-r--r--module/plugins/hooks/DebridItaliaCom.py6
-rw-r--r--module/plugins/hooks/EasybytezCom.py6
-rw-r--r--module/plugins/hooks/FastixRu.py6
-rw-r--r--module/plugins/hooks/FreeWayMe.py6
-rw-r--r--module/plugins/hooks/LinksnappyCom.py6
-rw-r--r--module/plugins/hooks/MegaDebridEu.py6
-rw-r--r--module/plugins/hooks/MultishareCz.py6
-rw-r--r--module/plugins/hooks/MyfastfileCom.py6
-rw-r--r--module/plugins/hooks/OverLoadMe.py6
-rw-r--r--module/plugins/hooks/PremiumTo.py8
-rw-r--r--module/plugins/hooks/PremiumizeMe.py8
-rw-r--r--module/plugins/hooks/RPNetBiz.py8
-rw-r--r--module/plugins/hooks/RealdebridCom.py6
-rw-r--r--module/plugins/hooks/RehostTo.py8
-rw-r--r--module/plugins/hooks/SimplyPremiumCom.py6
-rw-r--r--module/plugins/hooks/SimplydebridCom.py6
-rw-r--r--module/plugins/hooks/UnrestrictLi.py6
-rw-r--r--module/plugins/hooks/XFileSharingPro.py12
-rw-r--r--module/plugins/hooks/ZeveraCom.py4
-rw-r--r--module/plugins/internal/MultiHook.py217
21 files changed, 283 insertions, 66 deletions
diff --git a/module/plugins/hooks/AlldebridCom.py b/module/plugins/hooks/AlldebridCom.py
index 2d3c8aad7..d5986053f 100644
--- a/module/plugins/hooks/AlldebridCom.py
+++ b/module/plugins/hooks/AlldebridCom.py
@@ -1,13 +1,13 @@
# -*- coding: utf-8 -*-
from module.network.RequestFactory import getURL
-from module.plugins.internal.MultiHoster import MultiHoster
+from module.plugins.internal.MultiHook import MultiHook
-class AlldebridCom(MultiHoster):
+class AlldebridCom(MultiHook):
__name__ = "AlldebridCom"
__type__ = "hook"
- __version__ = "0.13"
+ __version__ = "0.14"
__config__ = [("https", "bool", "Enable HTTPS", False),
("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"),
diff --git a/module/plugins/hooks/DebridItaliaCom.py b/module/plugins/hooks/DebridItaliaCom.py
index 43e910a4b..e31bc98d7 100644
--- a/module/plugins/hooks/DebridItaliaCom.py
+++ b/module/plugins/hooks/DebridItaliaCom.py
@@ -3,13 +3,13 @@
import re
from module.network.RequestFactory import getURL
-from module.plugins.internal.MultiHoster import MultiHoster
+from module.plugins.internal.MultiHook import MultiHook
-class DebridItaliaCom(MultiHoster):
+class DebridItaliaCom(MultiHook):
__name__ = "DebridItaliaCom"
__type__ = "hook"
- __version__ = "0.09"
+ __version__ = "0.10"
__config__ = [("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"),
("hosterList", "str", "Hoster list (comma separated)", ""),
diff --git a/module/plugins/hooks/EasybytezCom.py b/module/plugins/hooks/EasybytezCom.py
index 3faa4fa1a..0dab2a7fe 100644
--- a/module/plugins/hooks/EasybytezCom.py
+++ b/module/plugins/hooks/EasybytezCom.py
@@ -2,13 +2,13 @@
import re
-from module.plugins.internal.MultiHoster import MultiHoster
+from module.plugins.internal.MultiHook import MultiHook
-class EasybytezCom(MultiHoster):
+class EasybytezCom(MultiHook):
__name__ = "EasybytezCom"
__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)", "")]
diff --git a/module/plugins/hooks/FastixRu.py b/module/plugins/hooks/FastixRu.py
index cec6c6f1f..73297eb23 100644
--- a/module/plugins/hooks/FastixRu.py
+++ b/module/plugins/hooks/FastixRu.py
@@ -2,13 +2,13 @@
from module.common.json_layer import json_loads
from module.network.RequestFactory import getURL
-from module.plugins.internal.MultiHoster import MultiHoster
+from module.plugins.internal.MultiHook import MultiHook
-class FastixRu(MultiHoster):
+class FastixRu(MultiHook):
__name__ = "FastixRu"
__type__ = "hook"
- __version__ = "0.02"
+ __version__ = "0.03"
__config__ = [("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"),
("unloadFailing", "bool", "Revert to standard download if download fails", False),
diff --git a/module/plugins/hooks/FreeWayMe.py b/module/plugins/hooks/FreeWayMe.py
index 5abec29ba..0b71fc35b 100644
--- a/module/plugins/hooks/FreeWayMe.py
+++ b/module/plugins/hooks/FreeWayMe.py
@@ -1,13 +1,13 @@
# -*- coding: utf-8 -*-
from module.network.RequestFactory import getURL
-from module.plugins.internal.MultiHoster import MultiHoster
+from module.plugins.internal.MultiHook import MultiHook
-class FreeWayMe(MultiHoster):
+class FreeWayMe(MultiHook):
__name__ = "FreeWayMe"
__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)", ""),
diff --git a/module/plugins/hooks/LinksnappyCom.py b/module/plugins/hooks/LinksnappyCom.py
index 82edc30fd..96bf1c0d1 100644
--- a/module/plugins/hooks/LinksnappyCom.py
+++ b/module/plugins/hooks/LinksnappyCom.py
@@ -2,13 +2,13 @@
from module.common.json_layer import json_loads
from module.network.RequestFactory import getURL
-from module.plugins.internal.MultiHoster import MultiHoster
+from module.plugins.internal.MultiHook import MultiHook
-class LinksnappyCom(MultiHoster):
+class LinksnappyCom(MultiHook):
__name__ = "LinksnappyCom"
__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)", ""),
diff --git a/module/plugins/hooks/MegaDebridEu.py b/module/plugins/hooks/MegaDebridEu.py
index 4f627b7e9..f3a0c31ea 100644
--- a/module/plugins/hooks/MegaDebridEu.py
+++ b/module/plugins/hooks/MegaDebridEu.py
@@ -2,13 +2,13 @@
from module.common.json_layer import json_loads
from module.network.RequestFactory import getURL
-from module.plugins.internal.MultiHoster import MultiHoster
+from module.plugins.internal.MultiHook import MultiHook
-class MegaDebridEu(MultiHoster):
+class MegaDebridEu(MultiHook):
__name__ = "MegaDebridEu"
__type__ = "hook"
- __version__ = "0.02"
+ __version__ = "0.03"
__config__ = [("unloadFailing", "bool", "Revert to standard download if download fails", False)]
diff --git a/module/plugins/hooks/MultishareCz.py b/module/plugins/hooks/MultishareCz.py
index 0e651393d..5ec5b63b6 100644
--- a/module/plugins/hooks/MultishareCz.py
+++ b/module/plugins/hooks/MultishareCz.py
@@ -3,13 +3,13 @@
import re
from module.network.RequestFactory import getURL
-from module.plugins.internal.MultiHoster import MultiHoster
+from module.plugins.internal.MultiHook import MultiHook
-class MultishareCz(MultiHoster):
+class MultishareCz(MultiHook):
__name__ = "MultishareCz"
__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)", "uloz.to")]
diff --git a/module/plugins/hooks/MyfastfileCom.py b/module/plugins/hooks/MyfastfileCom.py
index 0cf2c6c22..ec7c4e55b 100644
--- a/module/plugins/hooks/MyfastfileCom.py
+++ b/module/plugins/hooks/MyfastfileCom.py
@@ -2,13 +2,13 @@
from module.common.json_layer import json_loads
from module.network.RequestFactory import getURL
-from module.plugins.internal.MultiHoster import MultiHoster
+from module.plugins.internal.MultiHook import MultiHook
-class MyfastfileCom(MultiHoster):
+class MyfastfileCom(MultiHook):
__name__ = "MyfastfileCom"
__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)", ""),
diff --git a/module/plugins/hooks/OverLoadMe.py b/module/plugins/hooks/OverLoadMe.py
index baa9b0e0a..378ce0a65 100644
--- a/module/plugins/hooks/OverLoadMe.py
+++ b/module/plugins/hooks/OverLoadMe.py
@@ -1,13 +1,13 @@
# -*- coding: utf-8 -*-
from module.network.RequestFactory import getURL
-from module.plugins.internal.MultiHoster import MultiHoster
+from module.plugins.internal.MultiHook import MultiHook
-class OverLoadMe(MultiHoster):
+class OverLoadMe(MultiHook):
__name__ = "OverLoadMe"
__type__ = "hook"
- __version__ = "0.01"
+ __version__ = "0.02"
__config__ = [("https", "bool", "Enable HTTPS", True),
("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported):", "all"),
diff --git a/module/plugins/hooks/PremiumTo.py b/module/plugins/hooks/PremiumTo.py
index 7be46945f..3087db552 100644
--- a/module/plugins/hooks/PremiumTo.py
+++ b/module/plugins/hooks/PremiumTo.py
@@ -1,13 +1,13 @@
# -*- coding: utf-8 -*-
from module.network.RequestFactory import getURL
-from module.plugins.internal.MultiHoster import MultiHoster
+from module.plugins.internal.MultiHook import MultiHook
-class PremiumTo(MultiHoster):
+class PremiumTo(MultiHook):
__name__ = "PremiumTo"
__type__ = "hook"
- __version__ = "0.04"
+ __version__ = "0.05"
__config__ = [("hosterListMode", "all;listed;unlisted", "Use for downloads from supported hosters:", "all"),
("hosterList", "str", "Hoster list (comma separated)", "")]
@@ -34,4 +34,4 @@ class PremiumTo(MultiHoster):
self.logError(_("Please add your premium.to account first and restart pyLoad"))
return
- return MultiHoster.coreReady(self)
+ return MultiHook.coreReady(self)
diff --git a/module/plugins/hooks/PremiumizeMe.py b/module/plugins/hooks/PremiumizeMe.py
index c18e8cf8e..4ebf96451 100644
--- a/module/plugins/hooks/PremiumizeMe.py
+++ b/module/plugins/hooks/PremiumizeMe.py
@@ -2,13 +2,13 @@
from module.common.json_layer import json_loads
from module.network.RequestFactory import getURL
-from module.plugins.internal.MultiHoster import MultiHoster
+from module.plugins.internal.MultiHook import MultiHook
-class PremiumizeMe(MultiHoster):
+class PremiumizeMe(MultiHook):
__name__ = "PremiumizeMe"
__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)", ""),
@@ -51,4 +51,4 @@ class PremiumizeMe(MultiHoster):
return
# Run the overwriten core ready which actually enables the multihoster hook
- return MultiHoster.coreReady(self)
+ return MultiHook.coreReady(self)
diff --git a/module/plugins/hooks/RPNetBiz.py b/module/plugins/hooks/RPNetBiz.py
index 917cd02de..c54f7d445 100644
--- a/module/plugins/hooks/RPNetBiz.py
+++ b/module/plugins/hooks/RPNetBiz.py
@@ -2,13 +2,13 @@
from module.common.json_layer import json_loads
from module.network.RequestFactory import getURL
-from module.plugins.internal.MultiHoster import MultiHoster
+from module.plugins.internal.MultiHook import MultiHook
-class RPNetBiz(MultiHoster):
+class RPNetBiz(MultiHook):
__name__ = "RPNetBiz"
__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)", ""),
@@ -49,4 +49,4 @@ class RPNetBiz(MultiHoster):
return
# Run the overwriten core ready which actually enables the multihoster hook
- return MultiHoster.coreReady(self)
+ return MultiHook.coreReady(self)
diff --git a/module/plugins/hooks/RealdebridCom.py b/module/plugins/hooks/RealdebridCom.py
index 50cc81f0c..066aa52c4 100644
--- a/module/plugins/hooks/RealdebridCom.py
+++ b/module/plugins/hooks/RealdebridCom.py
@@ -1,13 +1,13 @@
# -*- coding: utf-8 -*-
from module.network.RequestFactory import getURL
-from module.plugins.internal.MultiHoster import MultiHoster
+from module.plugins.internal.MultiHook import MultiHook
-class RealdebridCom(MultiHoster):
+class RealdebridCom(MultiHook):
__name__ = "RealdebridCom"
__type__ = "hook"
- __version__ = "0.43"
+ __version__ = "0.44"
__config__ = [("https", "bool", "Enable HTTPS", False),
("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported):", "all"),
diff --git a/module/plugins/hooks/RehostTo.py b/module/plugins/hooks/RehostTo.py
index 1bf7d2555..48afa2342 100644
--- a/module/plugins/hooks/RehostTo.py
+++ b/module/plugins/hooks/RehostTo.py
@@ -1,13 +1,13 @@
# -*- coding: utf-8 -*-
from module.network.RequestFactory import getURL
-from module.plugins.internal.MultiHoster import MultiHoster
+from module.plugins.internal.MultiHook import MultiHook
-class RehostTo(MultiHoster):
+class RehostTo(MultiHook):
__name__ = "RehostTo"
__type__ = "hook"
- __version__ = "0.43"
+ __version__ = "0.44"
__config__ = [("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"),
("hosterList", "str", "Hoster list (comma separated)", ""),
@@ -38,4 +38,4 @@ class RehostTo(MultiHoster):
self.ses = data['ses']
self.long_ses = data['long_ses']
- return MultiHoster.coreReady(self)
+ return MultiHook.coreReady(self)
diff --git a/module/plugins/hooks/SimplyPremiumCom.py b/module/plugins/hooks/SimplyPremiumCom.py
index cc7e9183c..10a1655c2 100644
--- a/module/plugins/hooks/SimplyPremiumCom.py
+++ b/module/plugins/hooks/SimplyPremiumCom.py
@@ -2,13 +2,13 @@
from module.common.json_layer import json_loads
from module.network.RequestFactory import getURL
-from module.plugins.internal.MultiHoster import MultiHoster
+from module.plugins.internal.MultiHook import MultiHook
-class SimplyPremiumCom(MultiHoster):
+class SimplyPremiumCom(MultiHook):
__name__ = "SimplyPremiumCom"
__type__ = "hook"
- __version__ = "0.02"
+ __version__ = "0.03"
__config__ = [("activated", "bool", "Activated", "False"),
("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"),
diff --git a/module/plugins/hooks/SimplydebridCom.py b/module/plugins/hooks/SimplydebridCom.py
index 173206e75..48568f870 100644
--- a/module/plugins/hooks/SimplydebridCom.py
+++ b/module/plugins/hooks/SimplydebridCom.py
@@ -1,13 +1,13 @@
# -*- coding: utf-8 -*-
from module.network.RequestFactory import getURL
-from module.plugins.internal.MultiHoster import MultiHoster
+from module.plugins.internal.MultiHook import MultiHook
-class SimplydebridCom(MultiHoster):
+class SimplydebridCom(MultiHook):
__name__ = "SimplydebridCom"
__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)", "")]
diff --git a/module/plugins/hooks/UnrestrictLi.py b/module/plugins/hooks/UnrestrictLi.py
index d87265ef4..245264d44 100644
--- a/module/plugins/hooks/UnrestrictLi.py
+++ b/module/plugins/hooks/UnrestrictLi.py
@@ -2,13 +2,13 @@
from module.common.json_layer import json_loads
from module.network.RequestFactory import getURL
-from module.plugins.internal.MultiHoster import MultiHoster
+from module.plugins.internal.MultiHook import MultiHook
-class UnrestrictLi(MultiHoster):
+class UnrestrictLi(MultiHook):
__name__ = "UnrestrictLi"
__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)", ""),
diff --git a/module/plugins/hooks/XFileSharingPro.py b/module/plugins/hooks/XFileSharingPro.py
index 946838e47..589143547 100644
--- a/module/plugins/hooks/XFileSharingPro.py
+++ b/module/plugins/hooks/XFileSharingPro.py
@@ -10,12 +10,12 @@ class XFileSharingPro(Hook):
__type__ = "hook"
__version__ = "0.28"
- __config__ = [("activated", "bool", "Activated", True),
- ("use_hoster_list", "bool", "Load listed hosters only", False),
- ("use_crypter_list", "bool", "Load listed crypters only", False),
- ("use_builtin_list", "bool", "Load built-in plugin list", True),
- ("hoster_list", "str", "Hoster list (comma separated)", ""),
- ("crypter_list", "str", "Crypter list (comma separated)", "")]
+ __config__ = [("activated" , "bool", "Activated" , True ),
+ ("use_hoster_list" , "bool", "Load listed hosters only" , False),
+ ("use_crypter_list", "bool", "Load listed crypters only" , False),
+ ("use_builtin_list", "bool", "Load built-in plugin list" , True ),
+ ("hoster_list" , "str" , "Hoster list (comma separated)" , "" ),
+ ("crypter_list" , "str" , "Crypter list (comma separated)", "" )]
__description__ = """Load XFileSharingPro based hosters and crypter which don't need a own plugin to run"""
__license__ = "GPLv3"
diff --git a/module/plugins/hooks/ZeveraCom.py b/module/plugins/hooks/ZeveraCom.py
index 6fafb9666..ef1c128f3 100644
--- a/module/plugins/hooks/ZeveraCom.py
+++ b/module/plugins/hooks/ZeveraCom.py
@@ -1,10 +1,10 @@
# -*- coding: utf-8 -*-
from module.network.RequestFactory import getURL
-from module.plugins.internal.MultiHoster import MultiHoster
+from module.plugins.internal.MultiHook import MultiHook
-class ZeveraCom(MultiHoster):
+class ZeveraCom(MultiHook):
__name__ = "ZeveraCom"
__type__ = "hook"
__version__ = "0.02"
diff --git a/module/plugins/internal/MultiHook.py b/module/plugins/internal/MultiHook.py
new file mode 100644
index 000000000..dcf1c3383
--- /dev/null
+++ b/module/plugins/internal/MultiHook.py
@@ -0,0 +1,217 @@
+# -*- coding: utf-8 -*-
+
+import re
+
+from module.plugins.Hook import Hook
+from module.utils import remove_chars
+
+
+class MultiHook(Hook):
+ __name__ = "MultiHook"
+ __type__ = "hook"
+ __version__ = "0.22"
+
+ __description__ = """Hook plugin for MultiHoster"""
+ __license__ = "GPLv3"
+ __authors__ = [("pyLoad Team", "admin@pyload.org")]
+
+
+ interval = 12 * 60 * 60 #: reload hosters every 12h
+
+ HOSTER_REPLACEMENTS = [("1fichier.com" , "onefichier.com"),
+ ("2shared.com" , "twoshared.com" ),
+ ("4shared.com" , "fourshared.com"),
+ ("cloudnator.com" , "shragle.com" ),
+ ("easy-share.com" , "crocko.com" ),
+ ("fileparadox.com", "fileparadox.in"),
+ ("freakshare.net" , "freakshare.com"),
+ ("hellshare.com" , "hellshare.cz" ),
+ ("ifile.it" , "filecloud.io" ),
+ ("nowdownload.ch" , "nowdownload.sx"),
+ ("nowvideo.co" , "nowvideo.sx" ),
+ ("putlocker.com" , "firedrive.com" ),
+ ("share-rapid.cz" , "multishare.cz" ),
+ ("sharerapid.cz" , "multishare.cz" ),
+ ("ul.to" , "uploaded.to" ),
+ ("uploaded.net" , "uploaded.to" )]
+ HOSTER_EXCLUDED = []
+
+
+ def setup(self):
+ self.hosters = []
+ self.supported = []
+ self.new_supported = []
+
+
+ def getConfig(self, option, default=''):
+ """getConfig with default value - sublass may not implements all config options"""
+ try:
+ return self.getConf(option)
+ except KeyError:
+ return default
+
+
+ def getHosterCached(self):
+ if not self.hosters:
+ try:
+ hosterSet = self.toHosterSet(self.getHoster()) - set(self.HOSTER_EXCLUDED)
+ except Exception, e:
+ self.logError(e)
+ return []
+
+ try:
+ configMode = self.getConfig('hosterListMode', 'all')
+ if configMode in ("listed", "unlisted"):
+ configSet = self.toHosterSet(self.getConfig('hosterList', '').replace('|', ',').replace(';', ',').split(','))
+
+ if configMode == "listed":
+ hosterSet &= configSet
+ else:
+ hosterSet -= configSet
+
+ except Exception, e:
+ self.logError(e)
+
+ self.hosters = list(hosterSet)
+
+ return self.hosters
+
+
+ def toHosterSet(self, hosters):
+ hosters = set((str(x).strip().lower() for x in hosters))
+
+ for rep in self.HOSTER_REPLACEMENTS:
+ if rep[0] in hosters:
+ hosters.remove(rep[0])
+ hosters.add(rep[1])
+
+ hosters.discard('')
+ return hosters
+
+
+ def getHoster(self):
+ """Load list of supported hoster
+
+ :return: List of domain names
+ """
+ raise NotImplementedError
+
+
+ def coreReady(self):
+ if self.cb:
+ self.core.scheduler.removeJob(self.cb)
+
+ self.setConfig("activated", True) #: config not in sync after plugin reload
+
+ cfg_interval = self.getConfig("interval", None) #: reload interval in hours
+ if cfg_interval is not None:
+ self.interval = cfg_interval * 60 * 60
+
+ if self.interval:
+ self._periodical()
+ else:
+ self.periodical()
+
+
+ def initPeriodical(self):
+ pass
+
+
+ def periodical(self):
+ """reload hoster list periodically"""
+ self.logInfo(_("Reloading supported hoster list"))
+
+ old_supported = self.supported
+ self.supported = []
+ self.new_supported = []
+ self.hosters = []
+
+ self.overridePlugins()
+
+ old_supported = [hoster for hoster in old_supported if hoster not in self.supported]
+ if old_supported:
+ self.logDebug("UNLOAD", ", ".join(old_supported))
+ for hoster in old_supported:
+ self.unloadHoster(hoster)
+
+
+ def overridePlugins(self):
+ pluginMap = dict((name.lower(), name) for name in self.core.pluginManager.hosterPlugins.iterkeys())
+ accountList = [name.lower() for name, data in self.core.accountManager.accounts.iteritems() if data]
+ excludedList = []
+
+ for hoster in self.getHosterCached():
+ name = remove_chars(hoster, "-.")
+
+ if name in accountList:
+ excludedList.append(hoster)
+ else:
+ if name in pluginMap:
+ self.supported.append(pluginMap[name])
+ else:
+ self.new_supported.append(hoster)
+
+ if not self.supported and not self.new_supported:
+ self.logError(_("No Hoster loaded"))
+ return
+
+ module = self.core.pluginManager.getPlugin(self.__name__)
+ klass = getattr(module, self.__name__)
+
+ # inject plugin plugin
+ self.logDebug("Overwritten Hosters", ", ".join(sorted(self.supported)))
+ for hoster in self.supported:
+ hdict = self.core.pluginManager.hosterPlugins[hoster]
+ hdict['new_module'] = module
+ hdict['new_name'] = self.__name__
+
+ if excludedList:
+ self.logInfo(_("The following hosters were not overwritten - account exists"), ", ".join(sorted(excludedList)))
+
+ if self.new_supported:
+ hosters = sorted(self.new_supported)
+
+ self.logDebug("New Hosters", ", ".join(hosters))
+
+ # create new regexp
+ regexp = r'.*(%s).*' % "|".join([x.replace(".", "\.") for x in hosters])
+ if hasattr(klass, "__pattern__") and isinstance(klass.__pattern__, basestring) and '://' in klass.__pattern__:
+ regexp = r'%s|%s' % (klass.__pattern__, regexp)
+
+ self.logDebug("Regexp", regexp)
+
+ hdict = self.core.pluginManager.hosterPlugins[self.__name__]
+ hdict['pattern'] = regexp
+ hdict['re'] = re.compile(regexp)
+
+
+ def unloadHoster(self, hoster):
+ hdict = self.core.pluginManager.hosterPlugins[hoster]
+ if "module" in hdict:
+ del hdict['module']
+
+ if "new_module" in hdict:
+ del hdict['new_module']
+ del hdict['new_name']
+
+
+ def unload(self):
+ """Remove override for all hosters. Scheduler job is removed by hookmanager"""
+ for hoster in self.supported:
+ self.unloadHoster(hoster)
+
+ # reset pattern
+ klass = getattr(self.core.pluginManager.getPlugin(self.__name__), self.__name__)
+ hdict = self.core.pluginManager.hosterPlugins[self.__name__]
+ hdict['pattern'] = getattr(klass, "__pattern__", r'^unmatchable$')
+ hdict['re'] = re.compile(hdict['pattern'])
+
+
+ def downloadFailed(self, pyfile):
+ """remove plugin override if download fails but not if file is offline/temp.offline"""
+ if pyfile.hasStatus("failed") and self.getConfig("unloadFailing", True):
+ hdict = self.core.pluginManager.hosterPlugins[pyfile.pluginname]
+ if "new_name" in hdict and hdict['new_name'] == self.__name__:
+ self.logDebug("Unload MultiHook", pyfile.pluginname, hdict)
+ self.unloadHoster(pyfile.pluginname)
+ pyfile.setStatus("queued")