From 5fce9b9761537b1e171d137fe32239d5ea38566f Mon Sep 17 00:00:00 2001 From: Stefano Date: Mon, 20 May 2013 12:41:16 +0200 Subject: Premium4Me: error handled http://forum.pyload.org/viewtopic.php?f=12&t=2587 --- module/plugins/hoster/Premium4Me.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'module/plugins/hoster/Premium4Me.py') diff --git a/module/plugins/hoster/Premium4Me.py b/module/plugins/hoster/Premium4Me.py index 2679916e9..1c65a85a4 100644 --- a/module/plugins/hoster/Premium4Me.py +++ b/module/plugins/hoster/Premium4Me.py @@ -9,13 +9,13 @@ from os import remove class Premium4Me(Hoster): __name__ = "Premium4Me" - __version__ = "0.04" + __version__ = "0.05" __type__ = "hoster" __pattern__ = r"http://premium4.me/.*" __description__ = """premium4.me hoster plugin""" - __author_name__ = ("RaNaN", "zoidberg") - __author_mail__ = ("RaNaN@pyload.org", "zoidberg@mujmail.cz") + __author_name__ = ("RaNaN", "zoidberg", "stickell") + __author_mail__ = ("RaNaN@pyload.org", "zoidberg@mujmail.cz", "l.stickell@yahoo.it") def setup(self): self.resumeDownload = True @@ -34,7 +34,12 @@ class Premium4Me(Hoster): self.req.setOption("timeout", 120) self.download("http://premium4.me/api/getfile.php?authcode=%s&link=%s" % (self.account.authcode, quote(pyfile.url, "")), disposition=True) - + + check = self.checkDownload({"nopremium": "No premium account available"}) + + if check == "nopremium": + self.retry(3, 60, 'No premium account available') + err = '' if self.req.http.code == '420': # Custom error code send - fail -- cgit v1.2.3 From e1cc6e81cbdd17b79fba3511aa47d3dd2893ccf7 Mon Sep 17 00:00:00 2001 From: Stefano Date: Mon, 20 May 2013 12:42:03 +0200 Subject: Premium4Me: code cleanup --- module/plugins/hoster/Premium4Me.py | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'module/plugins/hoster/Premium4Me.py') diff --git a/module/plugins/hoster/Premium4Me.py b/module/plugins/hoster/Premium4Me.py index 1c65a85a4..5dd907b9f 100644 --- a/module/plugins/hoster/Premium4Me.py +++ b/module/plugins/hoster/Premium4Me.py @@ -2,11 +2,13 @@ # -*- coding: utf-8 -*- from urllib import quote -from module.plugins.Hoster import Hoster -from module.utils import fs_encode from os.path import exists from os import remove +from module.plugins.Hoster import Hoster +from module.utils import fs_encode + + class Premium4Me(Hoster): __name__ = "Premium4Me" __version__ = "0.05" @@ -29,38 +31,40 @@ class Premium4Me(Hoster): self.logDebug("premium4.me: Old URL: %s" % pyfile.url) tra = self.getTraffic() - + #raise timeout to 2min self.req.setOption("timeout", 120) - - self.download("http://premium4.me/api/getfile.php?authcode=%s&link=%s" % (self.account.authcode, quote(pyfile.url, "")), disposition=True) + + self.download( + "http://premium4.me/api/getfile.php?authcode=%s&link=%s" % (self.account.authcode, quote(pyfile.url, "")), + disposition=True) check = self.checkDownload({"nopremium": "No premium account available"}) if check == "nopremium": self.retry(3, 60, 'No premium account available') - err = '' + err = '' if self.req.http.code == '420': # Custom error code send - fail lastDownload = fs_encode(self.lastDownload) - - if exists(lastDownload): + + if exists(lastDownload): f = open(lastDownload, "rb") err = f.read(256).strip() f.close() remove(lastDownload) else: err = 'File does not exist' - + trb = self.getTraffic() - self.logInfo("Filesize: %d, Traffic used %d, traffic left %d" % (pyfile.size, tra-trb, trb)) - + self.logInfo("Filesize: %d, Traffic used %d, traffic left %d" % (pyfile.size, tra - trb, trb)) + if err: self.fail(err) - + def getTraffic(self): try: - traffic = int(self.load ("http://premium4.me/api/traffic.php?authcode=%s" % self.account.authcode)) + traffic = int(self.load("http://premium4.me/api/traffic.php?authcode=%s" % self.account.authcode)) except: - traffic = 0 + traffic = 0 return traffic -- cgit v1.2.3