summaryrefslogtreecommitdiffstats
path: root/module/plugins
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-06-06 03:33:26 +0200
committerGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-06-06 03:33:26 +0200
commitb81d202ab0eeb692a85ee4dda946810fb9886f59 (patch)
tree2f73c35cffd246bc1b4a4af0eb2e6b7f1a81b459 /module/plugins
parentMerge pull request #1455 from EvolutionClip/stable (diff)
downloadpyload-b81d202ab0eeb692a85ee4dda946810fb9886f59.tar.xz
[HighWayMe] Cleanup
Diffstat (limited to 'module/plugins')
-rw-r--r--module/plugins/accounts/HighWayMe.py7
-rw-r--r--module/plugins/hooks/HighWayMe.py55
-rw-r--r--module/plugins/hoster/HighWayMe.py151
3 files changed, 106 insertions, 107 deletions
diff --git a/module/plugins/accounts/HighWayMe.py b/module/plugins/accounts/HighWayMe.py
index 76330a3d1..d09c53c63 100644
--- a/module/plugins/accounts/HighWayMe.py
+++ b/module/plugins/accounts/HighWayMe.py
@@ -9,7 +9,7 @@ class HighWayMe.py(Account):
__type__ = "account"
__version__ = "0.01"
- __description__ = """High-Way.Me account plugin"""
+ __description__ = """High-Way.me account plugin"""
__license__ = "GPLv3"
__authors__ = [("EvolutionClip", "evolutionclip@live.de")]
@@ -34,11 +34,12 @@ class HighWayMe.py(Account):
if 'premium_traffic' in json_data['user'] and json_data['user']['premium_traffic']:
trafficleft = float(json_data['user']['premium_traffic']) / 1024 #@TODO: Remove `/ 1024` in 0.4.10
- return {"premium": premium, "validuntil": validuntil, "trafficleft": trafficleft}
+ return {'premium' : premium,
+ 'validuntil' : validuntil,
+ 'trafficleft': trafficleft}
def login(self, user, data, req):
-
html = req.load("https://high-way.me/api.php?login",
post={'login': '1', 'user': user, 'pass': data['password']},
decode=True)
diff --git a/module/plugins/hooks/HighWayMe.py b/module/plugins/hooks/HighWayMe.py
index 2a1ff2991..7d5c88ecc 100644
--- a/module/plugins/hooks/HighWayMe.py
+++ b/module/plugins/hooks/HighWayMe.py
@@ -1,29 +1,26 @@
-+# -*- coding: utf-8 -*-
-+
-+from module.common.json_layer import json_loads
-+from module.plugins.internal.MultiHook import MultiHook
-+
-+
-+class HighWayMeHook(MultiHook):
-+ __name__ = "HighWayMeHook"
-+ __type__ = "hook"
-+ __version__ = "0.01"
-+
-+ __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"),
-+ ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ),
-+ ("revertfailed" , "bool" , "Revert to standard download if fails", True ),
-+ ("reload" , "bool" , "Reload plugin list" , True ),
-+ ("reloadinterval", "int" , "Reload interval in hours" , 12 )]
-+
-+ __description__ = """High-Way.Me hook plugin"""
-+ __license__ = "GPLv3"
-+ __authors__ = [("EvolutionClip", "evolutionclip@live.de")]
-+
-+
-+ def getHosters(self):
-+ json_data = self.getURL("https://high-way.me/api.php", get={'hoster': 1})
-+ json_data = json_loads(json_data)
-+
-+ host_list = [element['name'] for element in json_data['hoster']]
-+
-+ return host_list
+# -*- coding: utf-8 -*-
+
+from module.common.json_layer import json_loads
+from module.plugins.internal.MultiHook import MultiHook
+
+
+class HighWayMeHook(MultiHook):
+ __name__ = "HighWayMeHook"
+ __type__ = "hook"
+ __version__ = "0.02"
+
+ __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"),
+ ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ),
+ ("revertfailed" , "bool" , "Revert to standard download if fails", True ),
+ ("reload" , "bool" , "Reload plugin list" , True ),
+ ("reloadinterval", "int" , "Reload interval in hours" , 12 )]
+
+ __description__ = """High-Way.me hook plugin"""
+ __license__ = "GPLv3"
+ __authors__ = [("EvolutionClip", "evolutionclip@live.de")]
+
+
+ def getHosters(self):
+ json_data = json_loads(self.getURL("https://high-way.me/api.php",
+ get={'hoster': 1}))
+ return [element['name'] for element in json_data['hoster']]
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 '<valid>0</valid>' 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 "<code>9</code>" 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 "<code>8</code>" 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'<name>([^<]+)</name>', self.html).group(1)
-+
-+ except AttributeError:
-+ self.pyfile.name = ""
-+
-+ try:
-+ self.pyfile.size = re.search(r'<size>(\d+)</size>', self.html).group(1)
-+
-+ except AttributeError:
-+ self.pyfile.size = 0
-+
-+ self.link = re.search(r'<download>([^<]+)</download>', 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 '<valid>0</valid>' 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 "<code>9</code>" 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 "<code>8</code>" 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'<name>([^<]+)</name>', self.html).group(1)
+
+ except AttributeError:
+ self.pyfile.name = ""
+
+ try:
+ self.pyfile.size = re.search(r'<size>(\d+)</size>', self.html).group(1)
+
+ except AttributeError:
+ self.pyfile.size = 0
+
+ self.link = re.search(r'<download>([^<]+)</download>', self.html).group(1)
+
+
+getInfo = create_getInfo(HighWayMe)