From b81d202ab0eeb692a85ee4dda946810fb9886f59 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 6 Jun 2015 03:33:26 +0200 Subject: [HighWayMe] Cleanup --- module/plugins/hoster/HighWayMe.py | 151 +++++++++++++++++++------------------ 1 file changed, 76 insertions(+), 75 deletions(-) (limited to 'module/plugins/hoster/HighWayMe.py') diff --git a/module/plugins/hoster/HighWayMe.py b/module/plugins/hoster/HighWayMe.py index e7b3fd739..eacf7a47e 100644 --- a/module/plugins/hoster/HighWayMe.py +++ b/module/plugins/hoster/HighWayMe.py @@ -1,75 +1,76 @@ -+# -*- coding: utf-8 -*- -+ -+import re -+ -+from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo -+from module.plugins.internal.SimpleHoster import secondsToMidnight -+ -+ -+class HighWayMe(MultiHoster): -+ __name__ = "HighWayMe" -+ __type__ = "hoster" -+ __version__ = "0.08" -+ -+ __pattern__ = r'https?://.+high-way\.my' -+ __config__ = [("use_premium", "bool", "Use premium account if available", True)] -+ -+ __description__ = """High-Way.Me multi-hoster plugin""" -+ __license__ = "GPLv3" -+ __authors__ = [("EvolutionClip", "evolutionclip@live.de")] -+ -+ -+ def setup(self): -+ self.chunkLimit = 4 -+ -+ -+ def checkErrors(self): -+ if '0' in self.html: #This is not working. It should by if 302 Moved Temporarily then ... But I don't now how to implement it. -+ self.account.relogin(self.user) -+ self.retry() -+ -+ elif "9" in self.html: -+ self.offline() -+ -+ elif "downloadlimit" in self.html: -+ self.logWarning(_("Reached maximum connctions")) -+ self.retry(5, 60, _("Reached maximum connctions")) -+ -+ elif "trafficlimit" in self.html: -+ self.logWarning(_("Reached daily limit")) -+ self.retry(wait_time=secondsToMidnight(gmt=2), reason="Daily limit for this host reached") -+ -+ elif "8" in self.html: -+ self.logWarning(_("Hoster temporarily unavailable, waiting 1 minute and retry")) -+ self.retry(5, 60, _("Hoster is temporarily unavailable")) -+ -+ -+ def handlePremium(self, pyfile): -+ for i in xrange(5): -+ self.html = self.load("https://high-way.me/load.php", get={'link': self.pyfile.url}) -+ -+ if self.html: -+ self.logDebug("JSON data: " + self.html) -+ break -+ else: -+ self.logInfo(_("Unable to get API data, waiting 1 minute and retry")) -+ self.retry(5, 60, _("Unable to get API data")) -+ -+ self.checkErrors() -+ -+ try: -+ self.pyfile.name = re.search(r'([^<]+)', self.html).group(1) -+ -+ except AttributeError: -+ self.pyfile.name = "" -+ -+ try: -+ self.pyfile.size = re.search(r'(\d+)', self.html).group(1) -+ -+ except AttributeError: -+ self.pyfile.size = 0 -+ -+ self.link = re.search(r'([^<]+)', self.html).group(1) -+ -+ -+getInfo = create_getInfo(HighWayMe) +# -*- coding: utf-8 -*- + +import re + +from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo +from module.plugins.internal.SimpleHoster import secondsToMidnight + + +class HighWayMe(MultiHoster): + __name__ = "HighWayMe" + __type__ = "hoster" + __version__ = "0.09" + + __pattern__ = r'https?://.+high-way\.my' + __config__ = [("use_premium", "bool", "Use premium account if available", True)] + + __description__ = """High-Way.me multi-hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("EvolutionClip", "evolutionclip@live.de")] + + + def setup(self): + self.chunkLimit = 4 + + + def checkErrors(self): + if '0' in self.html: #@NOTE: This is not working. It should by if 302 Moved Temporarily then ... But I don't now how to implement it. + self.account.relogin(self.user) + self.retry() + + elif "9" in self.html: + self.offline() + + elif "downloadlimit" in self.html: + self.logWarning(_("Reached maximum connctions")) + self.retry(5, 60, _("Reached maximum connctions")) + + elif "trafficlimit" in self.html: + self.logWarning(_("Reached daily limit")) + self.retry(wait_time=secondsToMidnight(gmt=2), reason="Daily limit for this host reached") + + elif "8" in self.html: + self.logWarning(_("Hoster temporarily unavailable, waiting 1 minute and retry")) + self.retry(5, 60, _("Hoster is temporarily unavailable")) + + + def handlePremium(self, pyfile): + for _i in xrange(5): + self.html = self.load("https://high-way.me/load.php", + get={'link': self.pyfile.url}) + + if self.html: + self.logDebug("JSON data: " + self.html) + break + else: + self.logInfo(_("Unable to get API data, waiting 1 minute and retry")) + self.retry(5, 60, _("Unable to get API data")) + + self.checkErrors() + + try: + self.pyfile.name = re.search(r'([^<]+)', self.html).group(1) + + except AttributeError: + self.pyfile.name = "" + + try: + self.pyfile.size = re.search(r'(\d+)', self.html).group(1) + + except AttributeError: + self.pyfile.size = 0 + + self.link = re.search(r'([^<]+)', self.html).group(1) + + +getInfo = create_getInfo(HighWayMe) -- cgit v1.2.3