diff options
-rw-r--r-- | module/plugins/accounts/MultihostersCom.py | 50 | ||||
-rw-r--r-- | module/plugins/hooks/MultihostersCom.py | 22 | ||||
-rw-r--r-- | module/plugins/hoster/MultihostersCom.py | 41 |
3 files changed, 113 insertions, 0 deletions
diff --git a/module/plugins/accounts/MultihostersCom.py b/module/plugins/accounts/MultihostersCom.py new file mode 100644 index 000000000..3f96fdf41 --- /dev/null +++ b/module/plugins/accounts/MultihostersCom.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- + +from time import mktime, strptime +from module.plugins.Account import Account + +class MultihostersCom(Account): + __name__ = "MultihostersCom" + __version__ = "0.01" + __type__ = "account" + __description__ = """Multihosters.com account plugin""" + __author_name__ = "tjeh" + __author_mail__ = "tjeh@gmx.net" + + def loadAccountInfo(self, user, req): + data = self.getAPIData(req) + if data == "No traffic": + account_info = {"trafficleft": 0, "validuntil": 0, "premium": False} + else: + account_info = { + "trafficleft": int(data['availabletodaytraffic']) * 1024, + "validuntil": mktime(strptime(data['endsubscriptiondate'], "%Y/%m/%d %H:%M:%S")), + "premium": True + } + return account_info + + def login(self, user, data, req): + self.loginname = user + self.password = data['password'] + if self.getAPIData(req) == "No traffic": + self.wrongPassword() + + def getAPIData(self, req, just_header=False, **kwargs): + get_data = { + 'cmd': 'accountinfo', + 'login': self.loginname, + 'pass': self.password + } + get_data.update(kwargs) + + response = req.load("http://www.multihosters.com/jDownloader.ashx", get=get_data, + decode=True, just_header=just_header) + self.logDebug(response) + + if ':' in response: + if not just_header: + response = response.replace(',', '\n') + return dict((y.strip().lower(), z.strip()) for (y, z) in + [x.split(':', 1) for x in response.splitlines() if ':' in x]) + else: + return response 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 diff --git a/module/plugins/hoster/MultihostersCom.py b/module/plugins/hoster/MultihostersCom.py new file mode 100644 index 000000000..04192cd8e --- /dev/null +++ b/module/plugins/hoster/MultihostersCom.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- + +import re +from module.plugins.Hoster import Hoster + +class MultihostersCom(Hoster): + __name__ = "MultihostersCom" + __version__ = "0.01" + __type__ = "hoster" + __pattern__ = r'http://(?:www\.)?multihosters.com/.*' + __description__ = """Multihosters.com hoster plugin""" + __author_name__ = "tjeh" + __author_mail__ = "tjeh@gmx.net" + + def setup(self): + self.resumeDownload = self.multiDL = True + self.chunkLimit = 1 + + def process(self, pyfile): + if re.match(self.__pattern__, pyfile.url): + new_url = pyfile.url + elif not self.account: + self.logError(("Please enter your %s account or deactivate this plugin") % "multihosters.com") + self.fail("No multihosters.com account provided") + else: + self.logDebug("Old URL: %s" % pyfile.url) + new_url = "http://multihosters.com/getFiles.aspx?ourl=" + pyfile.url + pyfile.url = new_url + self.logDebug("New URL: %s" % new_url) + + if self.account.getAPIData(self.req, cmd="checklink", olink=pyfile.url) != "Alive": + self.fail("Offline or not downloadable - contact Multihosters support") + + header = self.account.getAPIData(self.req, just_header=True, cmd="generatedownloaddirect", olink=pyfile.url) + if not "location" in header: + self.fail("Unable to initialize download - contact Multihosters support") + self.download(header['location'], disposition=True) + + check = self.checkDownload({"error": 'action="ErrorDownload.aspx'}) + if check == "error": + self.fail("Error response received - contact Multihosters support") |