summaryrefslogtreecommitdiffstats
path: root/module/plugins/hoster/SmoozedCom.py
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@gmail.com> 2015-01-09 00:35:51 +0100
committerGravatar Walter Purcaro <vuolter@gmail.com> 2015-01-09 00:35:51 +0100
commitfd105f8e51768ec1943cda2375bdfdbe5b0a3951 (patch)
treeccbdbe3cd23c606e8102f11ae4e0722f7e7a3227 /module/plugins/hoster/SmoozedCom.py
parent"New Year" Update: hook plugins (diff)
downloadpyload-fd105f8e51768ec1943cda2375bdfdbe5b0a3951.tar.xz
"New Year" Update: hoster plugins
Diffstat (limited to 'module/plugins/hoster/SmoozedCom.py')
-rw-r--r--module/plugins/hoster/SmoozedCom.py57
1 files changed, 25 insertions, 32 deletions
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()