From 75b6540be746d66d3fba3ab364c78addbc50c485 Mon Sep 17 00:00:00 2001 From: Smoozed Date: Mon, 5 Jan 2015 16:49:39 +0100 Subject: Added multihoster smoozed.com --- module/plugins/hoster/SmoozedCom.py | 70 +++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 module/plugins/hoster/SmoozedCom.py (limited to 'module/plugins/hoster/SmoozedCom.py') diff --git a/module/plugins/hoster/SmoozedCom.py b/module/plugins/hoster/SmoozedCom.py new file mode 100644 index 000000000..ce0eeedda --- /dev/null +++ b/module/plugins/hoster/SmoozedCom.py @@ -0,0 +1,70 @@ +# -*- coding: utf-8 -*- + +from module.plugins.Hoster import Hoster + +from module.common.json_layer import json_loads + + +class SmoozedCom(Hoster): + __name__ = "SmoozedCom" + __type__ = "hoster" + __version__ = "0.01" + + __pattern__ = r'^unmatchable$' #: Since we want to allow the user to specify the list of hoster to use we let MultiHoster.coreReady + + __description__ = """Smoozed.com hoster plugin""" + __license__ = "GPLv3" + __authors__ = [] + + + def process(self, pyfile): + # Check account + if not self.account or not self.account.canUse(): + self.logError(_("Please enter your %s account or deactivate this plugin") % "smoozed.com") + self.fail(_("No valid smoozed.com account provided")) + + # In some cases hostsers do not supply us with a filename at download, so we + # are going to set a fall back filename (e.g. for freakshare or xfileshare) + pyfile.name = pyfile.name.split('/').pop() # Remove everthing before last slash + + # Correction for automatic assigned filename: Removing html at end if needed + suffix_to_remove = ["html", "htm", "php", "php3", "asp", "shtm", "shtml", "cfml", "cfm"] + temp = pyfile.name.split('.') + if temp.pop() in suffix_to_remove: + pyfile.name = ".".join(temp) + + # Get account data + (user, data) = self.account.selectAccount() + account_info = self.account.getAccountInfo(user, True) + + # Check the link + get_data = { + "session_key": account_info['session_key'], + "url": pyfile.url + } + answer = self.load("http://www2.smoozed.com/api/check", get=get_data) + data = json_loads(answer) + if data["state"] != "ok": + self.fail(_(data["message"])) + if data["data"].get("state", "ok") != "ok": + if data["data"] == "Offline": + self.offline() + else: + self.fail(_(data["data"]["message"])) + pyfile.name = data["data"]["name"] + pyfile.size = int(data["data"]["size"]) + + # Start the download + header = self.load("http://www2.smoozed.com/api/download", get=get_data, just_header=True) + if not "location" in header: + self.fail(_("Unable to initialize download")) + + if isinstance(header["location"], list): + url = header["location"][-1] + else: + url = header["location"] + self.download(url, disposition=True) + + check = self.checkDownload({"error": '{"state":"error"}', "retry": '{"state":"retry"}'}) + if check == "error" or check == "retry": + self.fail(_("Error response received - contact Smoozed support")) -- cgit v1.2.3 From fd105f8e51768ec1943cda2375bdfdbe5b0a3951 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 9 Jan 2015 00:35:51 +0100 Subject: "New Year" Update: hoster plugins --- module/plugins/hoster/SmoozedCom.py | 57 ++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 32 deletions(-) (limited to 'module/plugins/hoster/SmoozedCom.py') diff --git a/module/plugins/hoster/SmoozedCom.py b/module/plugins/hoster/SmoozedCom.py index ce0eeedda..a5116db16 100644 --- a/module/plugins/hoster/SmoozedCom.py +++ b/module/plugins/hoster/SmoozedCom.py @@ -1,70 +1,63 @@ # -*- coding: utf-8 -*- -from module.plugins.Hoster import Hoster - from module.common.json_layer import json_loads +from module.plugins.internal.MultiHoster import MultiHoster -class SmoozedCom(Hoster): +class SmoozedCom(MultiHoster): __name__ = "SmoozedCom" __type__ = "hoster" - __version__ = "0.01" + __version__ = "0.02" __pattern__ = r'^unmatchable$' #: Since we want to allow the user to specify the list of hoster to use we let MultiHoster.coreReady __description__ = """Smoozed.com hoster plugin""" __license__ = "GPLv3" - __authors__ = [] - + __authors__ = [("", "")] - def process(self, pyfile): - # Check account - if not self.account or not self.account.canUse(): - self.logError(_("Please enter your %s account or deactivate this plugin") % "smoozed.com") - self.fail(_("No valid smoozed.com account provided")) + def handlePremium(self, pyfile): # In some cases hostsers do not supply us with a filename at download, so we # are going to set a fall back filename (e.g. for freakshare or xfileshare) pyfile.name = pyfile.name.split('/').pop() # Remove everthing before last slash # Correction for automatic assigned filename: Removing html at end if needed suffix_to_remove = ["html", "htm", "php", "php3", "asp", "shtm", "shtml", "cfml", "cfm"] - temp = pyfile.name.split('.') + temp = pyfile.name.split('.') + if temp.pop() in suffix_to_remove: pyfile.name = ".".join(temp) - # Get account data - (user, data) = self.account.selectAccount() - account_info = self.account.getAccountInfo(user, True) - # Check the link - get_data = { - "session_key": account_info['session_key'], - "url": pyfile.url - } - answer = self.load("http://www2.smoozed.com/api/check", get=get_data) - data = json_loads(answer) + get_data = {'session_key': self.account.getAccountData(self.user)['session_key'], + 'url' : pyfile.url} + + data = json_loads(self.load("http://www2.smoozed.com/api/check", get=get_data)) + if data["state"] != "ok": - self.fail(_(data["message"])) + self.fail(data["message"]) + if data["data"].get("state", "ok") != "ok": if data["data"] == "Offline": self.offline() else: - self.fail(_(data["data"]["message"])) + self.fail(data["data"]["message"]) + pyfile.name = data["data"]["name"] pyfile.size = int(data["data"]["size"]) # Start the download header = self.load("http://www2.smoozed.com/api/download", get=get_data, just_header=True) + if not "location" in header: self.fail(_("Unable to initialize download")) - - if isinstance(header["location"], list): - url = header["location"][-1] else: - url = header["location"] - self.download(url, disposition=True) + self.link = header["location"][-1] if isinstance(header["location"], list) else header["location"] + + + def checkFile(self): + if self.checkDownload({'error': '{"state":"error"}', + 'retry': '{"state":"retry"}'}): + self.fail(_("Error response received")) - check = self.checkDownload({"error": '{"state":"error"}', "retry": '{"state":"retry"}'}) - if check == "error" or check == "retry": - self.fail(_("Error response received - contact Smoozed support")) + return super(SmoozedCom, self).checkFile() -- cgit v1.2.3 From 187586c77f750340c2d8c84781c82a3e612f17c3 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 11 Jan 2015 20:20:43 +0100 Subject: Fix getAccount in some plugins --- module/plugins/hoster/SmoozedCom.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hoster/SmoozedCom.py') diff --git a/module/plugins/hoster/SmoozedCom.py b/module/plugins/hoster/SmoozedCom.py index a5116db16..bd653ff59 100644 --- a/module/plugins/hoster/SmoozedCom.py +++ b/module/plugins/hoster/SmoozedCom.py @@ -7,7 +7,7 @@ from module.plugins.internal.MultiHoster import MultiHoster class SmoozedCom(MultiHoster): __name__ = "SmoozedCom" __type__ = "hoster" - __version__ = "0.02" + __version__ = "0.03" __pattern__ = r'^unmatchable$' #: Since we want to allow the user to specify the list of hoster to use we let MultiHoster.coreReady @@ -29,7 +29,7 @@ class SmoozedCom(MultiHoster): pyfile.name = ".".join(temp) # Check the link - get_data = {'session_key': self.account.getAccountData(self.user)['session_key'], + get_data = {'session_key': self.account.getAccountInfo(self.user)['session'], 'url' : pyfile.url} data = json_loads(self.load("http://www2.smoozed.com/api/check", get=get_data)) -- cgit v1.2.3