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 From 1f8ae39acba53cebb46331692515f2ed42f8e12d Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 10 Mar 2015 22:42:32 +0100 Subject: Update plugins after SimpleHoster changes --- module/plugins/hoster/SmoozedCom.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'module/plugins/hoster/SmoozedCom.py') diff --git a/module/plugins/hoster/SmoozedCom.py b/module/plugins/hoster/SmoozedCom.py index bd653ff59..fdb764151 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.03" + __version__ = "0.04" __pattern__ = r'^unmatchable$' #: Since we want to allow the user to specify the list of hoster to use we let MultiHoster.coreReady @@ -55,9 +55,9 @@ class SmoozedCom(MultiHoster): self.link = header["location"][-1] if isinstance(header["location"], list) else header["location"] - def checkFile(self): + def checkFile(self, rules={}): if self.checkDownload({'error': '{"state":"error"}', 'retry': '{"state":"retry"}'}): self.fail(_("Error response received")) - return super(SmoozedCom, self).checkFile() + return super(SmoozedCom, self).checkFile(rules) -- cgit v1.2.3 From 7d90803262ccbb4fc5296a4dc3ce30fe98f55631 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 25 Mar 2015 23:10:07 +0100 Subject: __config__ cosmetics --- module/plugins/hoster/SmoozedCom.py | 1 + 1 file changed, 1 insertion(+) (limited to 'module/plugins/hoster/SmoozedCom.py') diff --git a/module/plugins/hoster/SmoozedCom.py b/module/plugins/hoster/SmoozedCom.py index fdb764151..5d453cf57 100644 --- a/module/plugins/hoster/SmoozedCom.py +++ b/module/plugins/hoster/SmoozedCom.py @@ -10,6 +10,7 @@ class SmoozedCom(MultiHoster): __version__ = "0.04" __pattern__ = r'^unmatchable$' #: Since we want to allow the user to specify the list of hoster to use we let MultiHoster.coreReady + __config__ = [("use_premium", "bool", "Use premium account if available", True)] __description__ = """Smoozed.com hoster plugin""" __license__ = "GPLv3" -- cgit v1.2.3 From ac3211e9d24e474a6b46c2b8b63f09d8ac928fca Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 11 May 2015 23:29:23 +0200 Subject: [SmoozedCom] Fix https://github.com/pyload/pyload/issues/1399 (2) --- 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 5d453cf57..9ae12f145 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.04" + __version__ = "0.05" __pattern__ = r'^unmatchable$' #: Since we want to allow the user to specify the list of hoster to use we let MultiHoster.coreReady __config__ = [("use_premium", "bool", "Use premium account if available", True)] @@ -17,7 +17,7 @@ class SmoozedCom(MultiHoster): __authors__ = [("", "")] - def handlePremium(self, pyfile): + def handleFree(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 -- cgit v1.2.3