From a64c0d41a27da58dc004f97bc934c8b3018a1de9 Mon Sep 17 00:00:00 2001 From: stickell Date: Fri, 12 Sep 2014 17:54:39 +0200 Subject: [Premium4Me] Renamed to PremiumTo + partial rewrite + special traffic support --- module/plugins/accounts/Premium4Me.py | 29 -------------- module/plugins/accounts/PremiumTo.py | 28 ++++++++++++++ module/plugins/hooks/Premium4Me.py | 34 ----------------- module/plugins/hooks/PremiumTo.py | 32 ++++++++++++++++ module/plugins/hoster/Premium4Me.py | 72 ----------------------------------- module/plugins/hoster/PremiumTo.py | 72 +++++++++++++++++++++++++++++++++++ 6 files changed, 132 insertions(+), 135 deletions(-) delete mode 100644 module/plugins/accounts/Premium4Me.py create mode 100644 module/plugins/accounts/PremiumTo.py delete mode 100644 module/plugins/hooks/Premium4Me.py create mode 100644 module/plugins/hooks/PremiumTo.py delete mode 100644 module/plugins/hoster/Premium4Me.py create mode 100644 module/plugins/hoster/PremiumTo.py (limited to 'module/plugins') diff --git a/module/plugins/accounts/Premium4Me.py b/module/plugins/accounts/Premium4Me.py deleted file mode 100644 index 9f66af414..000000000 --- a/module/plugins/accounts/Premium4Me.py +++ /dev/null @@ -1,29 +0,0 @@ -# -*- coding: utf-8 -*- - -from module.plugins.Account import Account - - -class Premium4Me(Account): - __name__ = "Premium4Me" - __type__ = "account" - __version__ = "0.03" - - __description__ = """Premium.to account plugin""" - __author_name__ = ("RaNaN", "zoidberg", "stickell") - __author_mail__ = ("RaNaN@pyload.org", "zoidberg@mujmail.cz", "l.stickell@yahoo.it") - - - def loadAccountInfo(self, user, req): - traffic = req.load("http://premium.to/api/traffic.php?authcode=%s" % self.authcode) - - account_info = {"trafficleft": int(traffic) / 1024, - "validuntil": -1} - - return account_info - - def login(self, user, data, req): - self.authcode = req.load("http://premium.to/api/getauthcode.php?username=%s&password=%s" % ( - user, data['password'])).strip() - - if "wrong username" in self.authcode: - self.wrongPassword() diff --git a/module/plugins/accounts/PremiumTo.py b/module/plugins/accounts/PremiumTo.py new file mode 100644 index 000000000..5678f8210 --- /dev/null +++ b/module/plugins/accounts/PremiumTo.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- + +from module.plugins.Account import Account + + +class PremiumTo(Account): + __name__ = "PremiumTo" + __type__ = "account" + __version__ = "0.04" + __description__ = """Premium.to account plugin""" + __author_name__ = ("RaNaN", "zoidberg", "stickell") + __author_mail__ = ("RaNaN@pyload.org", "zoidberg@mujmail.cz", "l.stickell@yahoo.it") + + def loadAccountInfo(self, user, req): + api_r = req.load("http://premium.to/api/straffic.php", + get={'username': self.username, 'password': self.password}) + traffic = sum(map(int, api_r.split(';'))) + + return {"trafficleft": int(traffic) / 1024, "validuntil": -1} + + def login(self, user, data, req): + self.username = user + self.password = data['password'] + authcode = req.load("http://premium.to/api/getauthcode.php?username=%s&password=%s" % ( + user, self.password)).strip() + + if "wrong username" in authcode: + self.wrongPassword() diff --git a/module/plugins/hooks/Premium4Me.py b/module/plugins/hooks/Premium4Me.py deleted file mode 100644 index 9c6701b06..000000000 --- a/module/plugins/hooks/Premium4Me.py +++ /dev/null @@ -1,34 +0,0 @@ -# -*- coding: utf-8 -*- - -from module.network.RequestFactory import getURL -from module.plugins.internal.MultiHoster import MultiHoster - - -class Premium4Me(MultiHoster): - __name__ = "Premium4Me" - __type__ = "hook" - __version__ = "0.03" - - __config__ = [("activated", "bool", "Activated", False), - ("hosterListMode", "all;listed;unlisted", "Use for downloads from supported hosters:", "all"), - ("hosterList", "str", "Hoster list (comma separated)", "")] - - __description__ = """Premium.to hook plugin""" - __author_name__ = ("RaNaN", "zoidberg", "stickell") - __author_mail__ = ("RaNaN@pyload.org", "zoidberg@mujmail.cz", "l.stickell@yahoo.it") - - - def getHoster(self): - page = getURL("http://premium.to/api/hosters.php?authcode=%s" % self.account.authcode) - return [x.strip() for x in page.replace("\"", "").split(";")] - - def coreReady(self): - self.account = self.core.accountManager.getAccountPlugin("Premium4Me") - - user = self.account.selectAccount()[0] - - if not user: - self.logError(_("Please add your premium.to account first and restart pyLoad")) - return - - return MultiHoster.coreReady(self) diff --git a/module/plugins/hooks/PremiumTo.py b/module/plugins/hooks/PremiumTo.py new file mode 100644 index 000000000..0572dab34 --- /dev/null +++ b/module/plugins/hooks/PremiumTo.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- + +from module.network.RequestFactory import getURL +from module.plugins.internal.MultiHoster import MultiHoster + + +class PremiumTo(MultiHoster): + __name__ = "PremiumTo" + __type__ = "hook" + __version__ = "0.04" + __config__ = [("activated", "bool", "Activated", False), + ("hosterListMode", "all;listed;unlisted", "Use for downloads from supported hosters:", "all"), + ("hosterList", "str", "Hoster list (comma separated)", "")] + __description__ = """Premium.to hook plugin""" + __author_name__ = ("RaNaN", "zoidberg", "stickell") + __author_mail__ = ("RaNaN@pyload.org", "zoidberg@mujmail.cz", "l.stickell@yahoo.it") + + def getHoster(self): + page = getURL("http://premium.to/api/hosters.php", + get={'username': self.account.username, 'password': self.account.password}) + return [x.strip() for x in page.replace("\"", "").split(";")] + + def coreReady(self): + self.account = self.core.accountManager.getAccountPlugin("PremiumTo") + + user = self.account.selectAccount()[0] + + if not user: + self.logError(_("Please add your premium.to account first and restart pyLoad")) + return + + return MultiHoster.coreReady(self) diff --git a/module/plugins/hoster/Premium4Me.py b/module/plugins/hoster/Premium4Me.py deleted file mode 100644 index ea841338a..000000000 --- a/module/plugins/hoster/Premium4Me.py +++ /dev/null @@ -1,72 +0,0 @@ -# -*- coding: utf-8 -*- - -from os import remove -from os.path import exists -from urllib import quote - -from module.plugins.Hoster import Hoster -from module.utils import fs_encode - - -class Premium4Me(Hoster): - __name__ = "Premium4Me" - __type__ = "hoster" - __version__ = "0.08" - - __pattern__ = r'http://(?:www\.)?premium.to/.*' - - __description__ = """Premium.to hoster plugin""" - __author_name__ = ("RaNaN", "zoidberg", "stickell") - __author_mail__ = ("RaNaN@pyload.org", "zoidberg@mujmail.cz", "l.stickell@yahoo.it") - - - def setup(self): - self.resumeDownload = True - self.chunkLimit = 1 - - def process(self, pyfile): - if not self.account: - self.logError(_("Please enter your %s account or deactivate this plugin") % "premium.to") - self.fail("No premium.to account provided") - - self.logDebug("premium.to: Old URL: %s" % pyfile.url) - - tra = self.getTraffic() - - #raise timeout to 2min - self.req.setOption("timeout", 120) - - self.download( - "http://premium.to/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(60, 5 * 60, "No premium account available") - - err = '' - if self.req.http.code == '420': - # Custom error code send - fail - lastDownload = fs_encode(self.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)) - - if err: - self.fail(err) - - def getTraffic(self): - try: - traffic = int(self.load("http://premium.to/api/traffic.php?authcode=%s" % self.account.authcode)) - except: - traffic = 0 - return traffic diff --git a/module/plugins/hoster/PremiumTo.py b/module/plugins/hoster/PremiumTo.py new file mode 100644 index 000000000..3ab7e34ac --- /dev/null +++ b/module/plugins/hoster/PremiumTo.py @@ -0,0 +1,72 @@ +# -*- coding: utf-8 -*- + +from os import remove +from os.path import exists +from urllib import quote + +from module.plugins.Hoster import Hoster +from module.utils import fs_encode + + +class PremiumTo(Hoster): + __name__ = "PremiumTo" + __type__ = "hoster" + __version__ = "0.09" + __pattern__ = r'https?://(?:www\.)?premium.to/.*' + __description__ = """Premium.to hoster plugin""" + __author_name__ = ("RaNaN", "zoidberg", "stickell") + __author_mail__ = ("RaNaN@pyload.org", "zoidberg@mujmail.cz", "l.stickell@yahoo.it") + + def setup(self): + self.resumeDownload = True + self.chunkLimit = 1 + + def process(self, pyfile): + if not self.account: + self.logError(_("Please enter your %s account or deactivate this plugin") % "premium.to") + self.fail("No premium.to account provided") + + self.logDebug("Old URL: %s" % pyfile.url) + + tra = self.getTraffic() + + #raise timeout to 2min + self.req.setOption("timeout", 120) + + self.download( + "http://premium.to/api/getfile.php", + get={"username": self.account.username, "password": self.account.password, "link": quote(pyfile.url, "")}, + disposition=True) + + check = self.checkDownload({"nopremium": "No premium account available"}) + + if check == "nopremium": + 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) + + 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)) + + 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 -- cgit v1.2.3