diff options
Diffstat (limited to 'module/plugins')
-rw-r--r-- | module/plugins/hooks/ZeveraCom.py | 2 | ||||
-rw-r--r-- | module/plugins/hoster/AlldebridCom.py | 9 | ||||
-rw-r--r-- | module/plugins/hoster/DebridItaliaCom.py | 31 | ||||
-rw-r--r-- | module/plugins/hoster/FastixRu.py | 9 | ||||
-rw-r--r-- | module/plugins/hoster/FreeWayMe.py | 9 | ||||
-rw-r--r-- | module/plugins/hoster/LinksnappyCom.py | 8 | ||||
-rw-r--r-- | module/plugins/hoster/MegaDebridEu.py | 8 | ||||
-rw-r--r-- | module/plugins/hoster/MyfastfileCom.py | 9 | ||||
-rw-r--r-- | module/plugins/hoster/OverLoadMe.py | 9 | ||||
-rw-r--r-- | module/plugins/hoster/PremiumTo.py | 9 | ||||
-rw-r--r-- | module/plugins/hoster/PremiumizeMe.py | 9 | ||||
-rw-r--r-- | module/plugins/hoster/RPNetBiz.py | 9 | ||||
-rw-r--r-- | module/plugins/hoster/RealdebridCom.py | 9 | ||||
-rw-r--r-- | module/plugins/hoster/RehostTo.py | 9 | ||||
-rw-r--r-- | module/plugins/hoster/SimplyPremiumCom.py | 9 | ||||
-rw-r--r-- | module/plugins/hoster/SimplydebridCom.py | 9 | ||||
-rw-r--r-- | module/plugins/hoster/UnrestrictLi.py | 9 | ||||
-rw-r--r-- | module/plugins/hoster/ZeveraCom.py | 9 | ||||
-rw-r--r-- | module/plugins/internal/MultiHoster.py | 226 |
19 files changed, 105 insertions, 296 deletions
diff --git a/module/plugins/hooks/ZeveraCom.py b/module/plugins/hooks/ZeveraCom.py index ef1c128f3..6ca696f38 100644 --- a/module/plugins/hooks/ZeveraCom.py +++ b/module/plugins/hooks/ZeveraCom.py @@ -7,7 +7,7 @@ from module.plugins.internal.MultiHook import MultiHook class ZeveraCom(MultiHook): __name__ = "ZeveraCom" __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/hoster/AlldebridCom.py b/module/plugins/hoster/AlldebridCom.py index 2f4b8cd73..3cc8e3c75 100644 --- a/module/plugins/hoster/AlldebridCom.py +++ b/module/plugins/hoster/AlldebridCom.py @@ -6,14 +6,14 @@ from random import randrange from urllib import unquote from module.common.json_layer import json_loads -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo +from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo from module.utils import parseFileSize -class AlldebridCom(SimpleHoster): +class AlldebridCom(MultiHoster): __name__ = "AlldebridCom" __type__ = "hoster" - __version__ = "0.37" + __version__ = "0.38" __pattern__ = r'https?://(?:[^/]*\.)?alldebrid\..*' @@ -22,9 +22,6 @@ class AlldebridCom(SimpleHoster): __authors__ = [("Andy Voigt", "spamsales@online.de")] - MULTI_HOSTER = True - - def getFilename(self, url): try: name = unquote(url.rsplit("/", 1)[1]) diff --git a/module/plugins/hoster/DebridItaliaCom.py b/module/plugins/hoster/DebridItaliaCom.py index 4dbbe32aa..21b6917d9 100644 --- a/module/plugins/hoster/DebridItaliaCom.py +++ b/module/plugins/hoster/DebridItaliaCom.py @@ -2,13 +2,13 @@ import re -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo +from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo -class DebridItaliaCom(SimpleHoster): +class DebridItaliaCom(MultiHoster): __name__ = "DebridItaliaCom" __type__ = "hoster" - __version__ = "0.11" + __version__ = "0.12" __pattern__ = r'http://s\d+\.debriditalia\.com/dl/\d+' @@ -18,7 +18,7 @@ class DebridItaliaCom(SimpleHoster): ("Walter Purcaro", "vuolter@gmail.com")] - MULTI_HOSTER = True + URL_REPLACEMENTS = [("https://", "http://")] def setup(self): @@ -27,13 +27,22 @@ class DebridItaliaCom(SimpleHoster): def handleMulti(self): - html = self.load("http://www.debriditalia.com/api.php", - get={'generate': "on", 'link': self.pyfile.url, 'p': self.getPassword()}) - - if "ERROR:" in html: - self.fail(re.search(r'ERROR:(.*)', html).group(1).strip()) - - self.link = html.strip() + self.html = self.load("http://www.debriditalia.com/api.php", + get={'generate': "on", 'link': self.pyfile.url, 'p': self.getPassword()}) + + if "ERROR:" not in self.html: + self.link = self.html.strip() + else: + errmsg = re.search(r'ERROR:(.*)', self.html).group(1).strip() + + self.html = self.load("http://debriditalia.com/linkgen2.php", + post={'xjxfun' : "convertiLink", + 'xjxargs[]': "S<![CDATA[%s]]>" % self.pyfile.url}) + + self.link = re.search(r'<a href="(.+?)"', self.html).group(1) + + if not self.link: + self.fail(errmsg) getInfo = create_getInfo(DebridItaliaCom) diff --git a/module/plugins/hoster/FastixRu.py b/module/plugins/hoster/FastixRu.py index 8778d770e..196b8479c 100644 --- a/module/plugins/hoster/FastixRu.py +++ b/module/plugins/hoster/FastixRu.py @@ -6,13 +6,13 @@ from random import randrange from urllib import unquote from module.common.json_layer import json_loads -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo +from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo -class FastixRu(SimpleHoster): +class FastixRu(MultiHoster): __name__ = "FastixRu" __type__ = "hoster" - __version__ = "0.06" + __version__ = "0.07" __pattern__ = r'http://(?:www\.)?fastix\.(ru|it)/file/(?P<ID>\w{24})' @@ -21,9 +21,6 @@ class FastixRu(SimpleHoster): __authors__ = [("Massimo Rosamilia", "max@spiritix.eu")] - MULTI_HOSTER = True - - def getFilename(self, url): try: name = unquote(url.rsplit("/", 1)[1]) diff --git a/module/plugins/hoster/FreeWayMe.py b/module/plugins/hoster/FreeWayMe.py index 9c7344f95..b08098915 100644 --- a/module/plugins/hoster/FreeWayMe.py +++ b/module/plugins/hoster/FreeWayMe.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo +from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo -class FreeWayMe(SimpleHoster): +class FreeWayMe(MultiHoster): __name__ = "FreeWayMe" __type__ = "hoster" - __version__ = "0.12" + __version__ = "0.13" __pattern__ = r'https://(?:www\.)?free-way\.me/.*' @@ -15,9 +15,6 @@ class FreeWayMe(SimpleHoster): __authors__ = [("Nicolas Giese", "james@free-way.me")] - MULTI_HOSTER = True - - def setup(self): self.resumeDownload = False self.multiDL = self.premium diff --git a/module/plugins/hoster/LinksnappyCom.py b/module/plugins/hoster/LinksnappyCom.py index 376b6d093..ff63f2c32 100644 --- a/module/plugins/hoster/LinksnappyCom.py +++ b/module/plugins/hoster/LinksnappyCom.py @@ -5,13 +5,13 @@ import re from urlparse import urlsplit from module.common.json_layer import json_loads, json_dumps -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo +from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo -class LinksnappyCom(SimpleHoster): +class LinksnappyCom(MultiHoster): __name__ = "LinksnappyCom" __type__ = "hoster" - __version__ = "0.04" + __version__ = "0.05" __pattern__ = r'https?://(?:[^/]*\.)?linksnappy\.com' @@ -20,8 +20,6 @@ class LinksnappyCom(SimpleHoster): __authors__ = [("stickell", "l.stickell@yahoo.it")] - MULTI_HOSTER = True - SINGLE_CHUNK_HOSTERS = ('easybytez.com') diff --git a/module/plugins/hoster/MegaDebridEu.py b/module/plugins/hoster/MegaDebridEu.py index 8feab4b24..fd0a41960 100644 --- a/module/plugins/hoster/MegaDebridEu.py +++ b/module/plugins/hoster/MegaDebridEu.py @@ -5,13 +5,13 @@ import re from urllib import unquote_plus from module.common.json_layer import json_loads -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo +from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo -class MegaDebridEu(SimpleHoster): +class MegaDebridEu(MultiHoster): __name__ = "MegaDebridEu" __type__ = "hoster" - __version__ = "0.41" + __version__ = "0.42" __pattern__ = r'^https?://(?:w{3}\d+\.mega-debrid\.eu|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/download/file/[^/]+/.+$' @@ -20,8 +20,6 @@ class MegaDebridEu(SimpleHoster): __authors__ = [("D.Ducatel", "dducatel@je-geek.fr")] - MULTI_HOSTER = True - API_URL = "https://www.mega-debrid.eu/api.php" diff --git a/module/plugins/hoster/MyfastfileCom.py b/module/plugins/hoster/MyfastfileCom.py index 2b9200d4b..2f3b5bd91 100644 --- a/module/plugins/hoster/MyfastfileCom.py +++ b/module/plugins/hoster/MyfastfileCom.py @@ -3,13 +3,13 @@ import re from module.common.json_layer import json_loads -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo +from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo -class MyfastfileCom(SimpleHoster): +class MyfastfileCom(MultiHoster): __name__ = "MyfastfileCom" __type__ = "hoster" - __version__ = "0.05" + __version__ = "0.06" __pattern__ = r'http://(?:www\.)?\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/dl/' @@ -18,9 +18,6 @@ class MyfastfileCom(SimpleHoster): __authors__ = [("stickell", "l.stickell@yahoo.it")] - MULTI_HOSTER = True - - def setup(self): self.chunkLimit = -1 self.resumeDownload = True diff --git a/module/plugins/hoster/OverLoadMe.py b/module/plugins/hoster/OverLoadMe.py index 2ac1d755b..0675787ac 100644 --- a/module/plugins/hoster/OverLoadMe.py +++ b/module/plugins/hoster/OverLoadMe.py @@ -6,14 +6,14 @@ from random import randrange from urllib import unquote from module.common.json_layer import json_loads -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo +from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo from module.utils import parseFileSize -class OverLoadMe(SimpleHoster): +class OverLoadMe(MultiHoster): __name__ = "OverLoadMe" __type__ = "hoster" - __version__ = "0.04" + __version__ = "0.05" __pattern__ = r'https?://.*overload\.me.*' @@ -22,9 +22,6 @@ class OverLoadMe(SimpleHoster): __authors__ = [("marley", "marley@over-load.me")] - MULTI_HOSTER = True - - def getFilename(self, url): try: name = unquote(url.rsplit("/", 1)[1]) diff --git a/module/plugins/hoster/PremiumTo.py b/module/plugins/hoster/PremiumTo.py index cb880d6c1..d593cec3e 100644 --- a/module/plugins/hoster/PremiumTo.py +++ b/module/plugins/hoster/PremiumTo.py @@ -6,14 +6,14 @@ from os import remove from os.path import exists from urllib import quote -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo +from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo from module.utils import fs_encode -class PremiumTo(SimpleHoster): +class PremiumTo(MultiHoster): __name__ = "PremiumTo" __type__ = "hoster" - __version__ = "0.13" + __version__ = "0.14" __pattern__ = r'https?://(?:www\.)?premium\.to/.*' @@ -24,9 +24,6 @@ class PremiumTo(SimpleHoster): ("stickell", "l.stickell@yahoo.it")] - MULTI_HOSTER = True - - def setup(self): self.resumeDownload = True self.chunkLimit = 1 diff --git a/module/plugins/hoster/PremiumizeMe.py b/module/plugins/hoster/PremiumizeMe.py index b3da7dca1..5716b3dd4 100644 --- a/module/plugins/hoster/PremiumizeMe.py +++ b/module/plugins/hoster/PremiumizeMe.py @@ -1,13 +1,13 @@ # -*- coding: utf-8 -*- from module.common.json_layer import json_loads -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo +from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo -class PremiumizeMe(SimpleHoster): +class PremiumizeMe(MultiHoster): __name__ = "PremiumizeMe" __type__ = "hoster" - __version__ = "0.13" + __version__ = "0.14" __pattern__ = r'^unmatchable$' #: Since we want to allow the user to specify the list of hoster to use we let MultiHoster.coreReady @@ -16,9 +16,6 @@ class PremiumizeMe(SimpleHoster): __authors__ = [("Florian Franzen", "FlorianFranzen@gmail.com")] - MULTI_HOSTER = True - - def handleMulti(self): # In some cases hostsers do not supply us with a filename at download, so we # are going to set a fall back filename (e.g. for freakshare or xfileshare) diff --git a/module/plugins/hoster/RPNetBiz.py b/module/plugins/hoster/RPNetBiz.py index a7bc3ea71..b731973c6 100644 --- a/module/plugins/hoster/RPNetBiz.py +++ b/module/plugins/hoster/RPNetBiz.py @@ -2,14 +2,14 @@ import re -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo +from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo from module.common.json_layer import json_loads -class RPNetBiz(SimpleHoster): +class RPNetBiz(MultiHoster): __name__ = "RPNetBiz" __type__ = "hoster" - __version__ = "0.11" + __version__ = "0.12" __description__ = """RPNet.biz hoster plugin""" __license__ = "GPLv3" @@ -18,9 +18,6 @@ class RPNetBiz(SimpleHoster): __authors__ = [("Dman", "dmanugm@gmail.com")] - MULTI_HOSTER = True - - def setup(self): self.chunkLimit = -1 self.resumeDownload = True diff --git a/module/plugins/hoster/RealdebridCom.py b/module/plugins/hoster/RealdebridCom.py index bec0b820c..6c4fe58a9 100644 --- a/module/plugins/hoster/RealdebridCom.py +++ b/module/plugins/hoster/RealdebridCom.py @@ -7,14 +7,14 @@ from urllib import quote, unquote from time import time from module.common.json_layer import json_loads -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo +from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo from module.utils import parseFileSize -class RealdebridCom(SimpleHoster): +class RealdebridCom(MultiHoster): __name__ = "RealdebridCom" __type__ = "hoster" - __version__ = "0.56" + __version__ = "0.57" __pattern__ = r'https?://(?:[^/]*\.)?real-debrid\..*' @@ -23,9 +23,6 @@ class RealdebridCom(SimpleHoster): __authors__ = [("Devirex Hazzard", "naibaf_11@yahoo.de")] - MULTI_HOSTER = True - - def getFilename(self, url): try: name = unquote(url.rsplit("/", 1)[1]) diff --git a/module/plugins/hoster/RehostTo.py b/module/plugins/hoster/RehostTo.py index dbd943d37..da0baf913 100644 --- a/module/plugins/hoster/RehostTo.py +++ b/module/plugins/hoster/RehostTo.py @@ -2,13 +2,13 @@ from urllib import quote, unquote -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo +from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo -class RehostTo(SimpleHoster): +class RehostTo(MultiHoster): __name__ = "RehostTo" __type__ = "hoster" - __version__ = "0.14" + __version__ = "0.15" __pattern__ = r'https?://.*rehost\.to\..*' @@ -17,9 +17,6 @@ class RehostTo(SimpleHoster): __authors__ = [("RaNaN", "RaNaN@pyload.org")] - MULTI_HOSTER = True - - def getFilename(self, url): return unquote(url.rsplit("/", 1)[1]) diff --git a/module/plugins/hoster/SimplyPremiumCom.py b/module/plugins/hoster/SimplyPremiumCom.py index 9857f514a..98233b292 100644 --- a/module/plugins/hoster/SimplyPremiumCom.py +++ b/module/plugins/hoster/SimplyPremiumCom.py @@ -4,14 +4,14 @@ import re from datetime import datetime, timedelta -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo +from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo from module.plugins.hoster.UnrestrictLi import secondsToMidnight -class SimplyPremiumCom(SimpleHoster): +class SimplyPremiumCom(MultiHoster): __name__ = "SimplyPremiumCom" __type__ = "hoster" - __version__ = "0.04" + __version__ = "0.05" __pattern__ = r'https?://.*(simply-premium)\.com' @@ -20,9 +20,6 @@ class SimplyPremiumCom(SimpleHoster): __authors__ = [("EvolutionClip", "evolutionclip@live.de")] - MULTI_HOSTER = True - - def setup(self): self.chunkLimit = 16 self.resumeDownload = False diff --git a/module/plugins/hoster/SimplydebridCom.py b/module/plugins/hoster/SimplydebridCom.py index 8fa756606..e17ee41de 100644 --- a/module/plugins/hoster/SimplydebridCom.py +++ b/module/plugins/hoster/SimplydebridCom.py @@ -2,13 +2,13 @@ import re -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo +from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo -class SimplydebridCom(SimpleHoster): +class SimplydebridCom(MultiHoster): __name__ = "SimplydebridCom" __type__ = "hoster" - __version__ = "0.12" + __version__ = "0.13" __pattern__ = r'http://(?:www\.)?\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/sd\.php/*' @@ -17,9 +17,6 @@ class SimplydebridCom(SimpleHoster): __authors__ = [("Kagenoshin", "kagenoshin@gmx.ch")] - MULTI_HOSTER = True - - def setup(self): self.resumeDownload = True self.multiDL = True diff --git a/module/plugins/hoster/UnrestrictLi.py b/module/plugins/hoster/UnrestrictLi.py index 911061f24..36d866613 100644 --- a/module/plugins/hoster/UnrestrictLi.py +++ b/module/plugins/hoster/UnrestrictLi.py @@ -5,7 +5,7 @@ import re from datetime import datetime, timedelta from module.common.json_layer import json_loads -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo +from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo def secondsToMidnight(gmt=0): @@ -26,10 +26,10 @@ def secondsToMidnight(gmt=0): return int(res) -class UnrestrictLi(SimpleHoster): +class UnrestrictLi(MultiHoster): __name__ = "UnrestrictLi" __type__ = "hoster" - __version__ = "0.15" + __version__ = "0.16" __pattern__ = r'https?://(?:[^/]*\.)?(unrestrict|unr)\.li' @@ -38,9 +38,6 @@ class UnrestrictLi(SimpleHoster): __authors__ = [("stickell", "l.stickell@yahoo.it")] - MULTI_HOSTER = True - - def setup(self): self.chunkLimit = 16 self.resumeDownload = True diff --git a/module/plugins/hoster/ZeveraCom.py b/module/plugins/hoster/ZeveraCom.py index d337dac9d..34aa6aacf 100644 --- a/module/plugins/hoster/ZeveraCom.py +++ b/module/plugins/hoster/ZeveraCom.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo +from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo -class ZeveraCom(SimpleHoster): +class ZeveraCom(MultiHoster): __name__ = "ZeveraCom" __type__ = "hoster" - __version__ = "0.23" + __version__ = "0.24" __pattern__ = r'http://(?:www\.)?zevera\.com/.*' @@ -15,9 +15,6 @@ class ZeveraCom(SimpleHoster): __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] - MULTI_HOSTER = True - - def setup(self): self.resumeDownload = True self.multiDL = True diff --git a/module/plugins/internal/MultiHoster.py b/module/plugins/internal/MultiHoster.py index 68550a4dd..4425cfce0 100644 --- a/module/plugins/internal/MultiHoster.py +++ b/module/plugins/internal/MultiHoster.py @@ -2,216 +2,62 @@ import re -from module.plugins.Hook import Hook -from module.utils import remove_chars +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo, replace_patterns, set_cookies -class MultiHoster(Hook): +class MultiHoster(SimpleHoster): __name__ = "MultiHoster" - __type__ = "hook" - __version__ = "0.22" + __type__ = "hoster" + __version__ = "0.23" - __description__ = """Generic MultiHoster plugin""" - __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 + __pattern__ = r'^unmatchable$' - 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]) + __description__ = """Multi hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - hosters.discard('') - return hosters + DIRECT_LINK = True + MULTI_HOSTER = True + LOGIN_ACCOUNT = True + LOGIN_PREMIUM = False - def getHoster(self): - """Load list of supported hoster - :return: List of domain names - """ - raise NotImplementedError + def setup(self): + self.chunkLimit = 1 + self.multiDL = self.premium - def coreReady(self): - if self.cb: - self.core.scheduler.removeJob(self.cb) + def prepare(self): + self.info = {} + self.link = "" + self.multihost = False - self.setConfig("activated", True) #: config not in sync after plugin reload + self.req.setOption("timeout", 120) - cfg_interval = self.getConfig("interval", None) #: reload interval in hours - if cfg_interval is not None: - self.interval = cfg_interval * 60 * 60 + if isinstance(self.COOKIES, list): + set_cookies(self.req.cj, self.COOKIES) - if self.interval: - self._periodical() + if self.DIRECT_LINK is None: + self.directDL = bool(self.account) else: - self.periodical() - - - def initPeriodical(self): - pass + self.directDL = self.DIRECT_LINK + if (self.__pattern__ != self.core.pluginManager.hosterPlugins[self.__name__]['pattern'] + or re.match(self.__pattern__, self.pyfile.url) is None): - def periodical(self): - """reload hoster list periodically""" - self.logInfo(_("Reloading supported hoster list")) + if self.LOGIN_ACCOUNT and not self.account: + self.logError(_("Required account not found")) - old_supported = self.supported - self.supported = [] - self.new_supported = [] - self.hosters = [] + elif self.LOGIN_PREMIUM and not self.premium: + self.logError(_("Required premium account not found")) - 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.multihost = True - self.logDebug("New Hosters", ", ".join(hosters)) + self.pyfile.url = replace_patterns(self.pyfile.url, + self.FILE_URL_REPLACEMENTS if hasattr(self, "FILE_URL_REPLACEMENTS") else self.URL_REPLACEMENTS) #@TODO: Remove FILE_URL_REPLACEMENTS check in 0.4.10 - # 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 MultiHoster", pyfile.pluginname, hdict) - self.unloadHoster(pyfile.pluginname) - pyfile.setStatus("queued") + def handleMulti(self): + raise NotImplementedError |