diff options
Diffstat (limited to 'module/plugins/hoster/PremiumTo.py')
-rw-r--r-- | module/plugins/hoster/PremiumTo.py | 51 |
1 files changed, 14 insertions, 37 deletions
diff --git a/module/plugins/hoster/PremiumTo.py b/module/plugins/hoster/PremiumTo.py index b6194ef73..ab5016673 100644 --- a/module/plugins/hoster/PremiumTo.py +++ b/module/plugins/hoster/PremiumTo.py @@ -2,9 +2,7 @@ from __future__ import with_statement -from os import remove -from os.path import exists -from urllib import quote +import os from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo from module.utils import fs_encode @@ -13,67 +11,46 @@ from module.utils import fs_encode class PremiumTo(MultiHoster): __name__ = "PremiumTo" __type__ = "hoster" - __version__ = "0.15" + __version__ = "0.22" - __pattern__ = r'https?://(?:www\.)?premium\.to/.*' + __pattern__ = r'^unmatchable$' + __config__ = [("use_premium", "bool", "Use premium account if available", True)] - __description__ = """Premium.to hoster plugin""" + __description__ = """Premium.to multi-hoster plugin""" __license__ = "GPLv3" __authors__ = [("RaNaN", "RaNaN@pyload.org"), ("zoidberg", "zoidberg@mujmail.cz"), ("stickell", "l.stickell@yahoo.it")] - def setup(self): - self.resumeDownload = True - self.chunkLimit = 1 + CHECK_TRAFFIC = True - def handlePremium(self): - tra = self.getTraffic() - + def handlePremium(self, pyfile): #raise timeout to 2min - self.req.setOption("timeout", 120) - - self.link = True self.download("http://premium.to/api/getfile.php", get={'username': self.account.username, 'password': self.account.password, - 'link' : quote(self.pyfile.url, "")}, + 'link' : pyfile.url}, disposition=True) - def checkFile(self): - super(PremiumTo, self).checkFile() - - check = self.checkDownload({"nopremium": "No premium account available"}) - - if check == "nopremium": + def checkFile(self, rules={}): + if self.checkDownload({'nopremium': "No premium account available"}): self.retry(60, 5 * 60, "No premium account available") err = '' if self.req.http.code == '420': # Custom error code send - fail - lastDownload = fs_encode(self.lastDownload) - with open(lastDownload, "rb") as f: + file = fs_encode(self.lastDownload) + with open(file, "rb") as f: err = f.read(256).strip() - remove(lastDownload) - - trb = self.getTraffic() - self.logInfo(_("Filesize: %d, Traffic used %d, traffic left %d") % (self.pyfile.size, tra - trb, trb)) + os.remove(file) if err: self.fail(err) - - def getTraffic(self): - try: - api_r = self.load("http://premium.to/api/straffic.php", - get={'username': self.account.username, 'password': self.account.password}) - traffic = sum(map(int, api_r.split(';'))) - except: - traffic = 0 - return traffic + return super(PremiumTo, self).checkFile(rules) getInfo = create_getInfo(PremiumTo) |