diff options
author | EvolutionClip <evolutionclip@live.de> | 2014-03-31 14:28:48 +0200 |
---|---|---|
committer | Stefano <l.stickell@yahoo.it> | 2014-04-21 17:12:09 +0200 |
commit | ed5aca31300b69df095a74b8e80ad706bce1e265 (patch) | |
tree | dbb6efe033b5aa1d7e2b141ee7c2647fc6b6a131 | |
parent | Unrar 5.x Support (diff) | |
download | pyload-ed5aca31300b69df095a74b8e80ad706bce1e265.tar.xz |
New multihoster: SimplyPremiumCom
Merges #531
(cherry picked from commit bb22924d2863c4100da3ddde4297f5da94484d8d)
-rw-r--r-- | module/plugins/accounts/SimplyPremiumCom.py | 58 | ||||
-rw-r--r-- | module/plugins/hooks/SimplyPremiumCom.py | 42 | ||||
-rw-r--r-- | module/plugins/hoster/SimplyPremiumCom.py | 103 |
3 files changed, 203 insertions, 0 deletions
diff --git a/module/plugins/accounts/SimplyPremiumCom.py b/module/plugins/accounts/SimplyPremiumCom.py new file mode 100644 index 000000000..1e6d66806 --- /dev/null +++ b/module/plugins/accounts/SimplyPremiumCom.py @@ -0,0 +1,58 @@ +# -*- coding: utf-8 -*- + +############################################################################ +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU Affero General Public License as # +# published by the Free Software Foundation, either version 3 of the # +# License, or (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU Affero General Public License for more details. # +# # +# You should have received a copy of the GNU Affero General Public License # +# along with this program. If not, see <http://www.gnu.org/licenses/>. # +############################################################################ + +from module.plugins.Account import Account +from module.common.json_layer import json_loads + + +class SimplyPremiumCom(Account): + __name__ = "SimplyPremiumCom" + __version__ = "0.01" + __type__ = "account" + __description__ = """Simply-Premium.Com account plugin""" + __author_name__ = ("EvolutionClip") + __author_mail__ = ("evolutionclip@live.de") + + def loadAccountInfo(self, user, req): + json_data = req.load('http://www.simply-premium.com/api/user.php?format=json') + self.logDebug("JSON data: " + json_data) + json_data = json_loads(json_data) + + if 'vip' in json_data['result'] and json_data['result']['vip'] == 0: + return {"premium": False} + + #Time package + validuntil = float(json_data['result']['timeend']) + #Traffic package + # {"trafficleft": int(traffic) / 1024, "validuntil": -1} + #trafficleft = int(json_data['result']['traffic'] / 1024) + + #return {"premium": True, "validuntil": validuntil, "trafficleft": trafficleft} + return {"premium": True, "validuntil": validuntil} + + def login(self, user, data, req): + req.cj.setCookie("simply-premium.com", "lang", "EN") + + if data['password'] == '' or data['password'] == '0': + post_data = {"key": user} + else: + post_data = {"login_name": user, "login_pass": data["password"]} + + self.html = req.load("http://www.simply-premium.com/login.php", post=post_data) + + if 'logout' not in self.html: + self.wrongPassword() diff --git a/module/plugins/hooks/SimplyPremiumCom.py b/module/plugins/hooks/SimplyPremiumCom.py new file mode 100644 index 000000000..ca1122e45 --- /dev/null +++ b/module/plugins/hooks/SimplyPremiumCom.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- + +############################################################################ +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU Affero General Public License as # +# published by the Free Software Foundation, either version 3 of the # +# License, or (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU Affero General Public License for more details. # +# # +# You should have received a copy of the GNU Affero General Public License # +# along with this program. If not, see <http://www.gnu.org/licenses/>. # +############################################################################ + +from module.plugins.internal.MultiHoster import MultiHoster +from module.network.RequestFactory import getURL +from module.common.json_layer import json_loads + + +class SimplyPremiumCom(MultiHoster): + __name__ = "SimplyPremiumCom" + __version__ = "0.01" + __type__ = "hook" + __config__ = [("activated", "bool", "Activated", "False"), + ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), + ("hosterList", "str", "Hoster list (comma separated)", ""), + ("unloadFailing", "bool", "Revert to standard download if download fails", "False"), + ("interval", "int", "Reload interval in hours (0 to disable)", "24")] + __description__ = """Simply-Premium.Com hook plugin""" + __author_name__ = ("EvolutionClip") + __author_mail__ = ("evolutionclip@live.de") + + def getHoster(self): + json_data = getURL('http://www.simply-premium.com/api/hosts.php?format=json&online=1') + json_data = json_loads(json_data) + + host_list = [element['host'] for element in json_data['result']] + + return host_list diff --git a/module/plugins/hoster/SimplyPremiumCom.py b/module/plugins/hoster/SimplyPremiumCom.py new file mode 100644 index 000000000..c9fbf2ff1 --- /dev/null +++ b/module/plugins/hoster/SimplyPremiumCom.py @@ -0,0 +1,103 @@ +# -*- coding: utf-8 -*- + +############################################################################ +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU Affero General Public License as # +# published by the Free Software Foundation, either version 3 of the # +# License, or (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU Affero General Public License for more details. # +# # +# You should have received a copy of the GNU Affero General Public License # +# along with this program. If not, see <http://www.gnu.org/licenses/>. # +############################################################################ + +import re +from datetime import datetime, timedelta + +from module.plugins.Hoster import Hoster + + +def secondsToMidnight(): + # Seconds until 00:10 GMT+2 + now = datetime.utcnow() + timedelta(hours=2) + if now.hour is 0 and now.minute < 10: + midnight = now + else: + midnight = now + timedelta(days=1) + midnight = midnight.replace(hour=0, minute=10, second=0, microsecond=0) + return int((midnight - now).total_seconds()) + + +class SimplyPremiumCom(Hoster): + __name__ = "SimplyPremiumCom" + __version__ = "0.01" + __type__ = "hoster" + __pattern__ = r"https?://.*(simply-premium)\.com" + __description__ = """Simply-Premium.Com hoster plugin""" + __author_name__ = ("EvolutionClip") + __author_mail__ = ("evolutionclip@live.de") + + def setup(self): + self.chunkLimit = 16 + self.resumeDownload = False + + def process(self, pyfile): + if re.match(self.__pattern__, pyfile.url): + new_url = pyfile.url + elif not self.account: + self.logError(_("Please enter your %s account or deactivate this plugin") % "Simply-Premium.com") + self.fail("No Simply-Premium.com account provided") + else: + self.logDebug("Old URL: %s" % pyfile.url) + for i in xrange(5): + page = self.load('http://www.simply-premium.com/premium.php?info&link=' + pyfile.url) + self.logDebug("JSON data: " + page) + if page != '': + break + else: + self.logInfo("Unable to get API data, waiting 1 minute and retry") + self.retry(5, 60, "Unable to get API data") + + if '<valid>0</valid>' in page or ( + "You are not allowed to download from this host" in page and self.premium): + self.account.relogin(self.user) + self.retry() + elif "NOTFOUND" in page: + self.offline() + elif "downloadlimit" in page: + self.logInfo("Reached maximum connctions") + self.retry(5, 60, "Reached maximum connctions") + elif "trafficlimit" in page: + self.logInfo("Reached daily limit for this host. Waiting until 00:10 GMT+2") + self.retry(5, secondsToMidnight(), "Daily limit for this host reached") + elif "hostererror" in page: + self.logInfo("Hoster temporarily unavailable, waiting 1 minute and retry") + self.retry(5, 60, "Hoster is temporarily unavailable") + #page = json_loads(page) + #new_url = page.keys()[0] + #self.api_data = page[new_url] + + try: + start = page.index('<name>') + len('<name>') + end = page.index('</name>', start) + self.pyfile.name = page[start:end] + except ValueError: + self.pyfile.name = "" + + try: + start = page.index('<size>') + len('<size>') + end = page.index('</size>', start) + self.pyfile.size = int(float(page[start:end])) + except ValueError: + self.pyfile.size = 0 + + new_url = 'http://www.simply-premium.com/premium.php?link=' + pyfile.url + + if new_url != pyfile.url: + self.logDebug("New URL: " + new_url) + + self.download(new_url, disposition=True) |