summaryrefslogtreecommitdiffstats
path: root/module/plugins/hoster/PremiumizeMe.py
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@gmail.com> 2014-12-17 20:02:20 +0100
committerGravatar Walter Purcaro <vuolter@gmail.com> 2014-12-17 20:02:20 +0100
commit57300575fa97107d172e0c9909b244c8c8ae6c12 (patch)
tree86dcbc38175e55c3ac077ff9a894fe74bb3d54ea /module/plugins/hoster/PremiumizeMe.py
parent[FilerNet] Typo (diff)
downloadpyload-57300575fa97107d172e0c9909b244c8c8ae6c12.tar.xz
Extend SimpleHoster in multi-hoster plugins
Diffstat (limited to 'module/plugins/hoster/PremiumizeMe.py')
-rw-r--r--module/plugins/hoster/PremiumizeMe.py32
1 files changed, 18 insertions, 14 deletions
diff --git a/module/plugins/hoster/PremiumizeMe.py b/module/plugins/hoster/PremiumizeMe.py
index bf00325d9..f4a778897 100644
--- a/module/plugins/hoster/PremiumizeMe.py
+++ b/module/plugins/hoster/PremiumizeMe.py
@@ -1,10 +1,10 @@
# -*- coding: utf-8 -*-
from module.common.json_layer import json_loads
-from module.plugins.Hoster import Hoster
+from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo
-class PremiumizeMe(Hoster):
+class PremiumizeMe(SimpleHoster):
__name__ = "PremiumizeMe"
__type__ = "hoster"
__version__ = "0.12"
@@ -16,41 +16,45 @@ class PremiumizeMe(Hoster):
__authors__ = [("Florian Franzen", "FlorianFranzen@gmail.com")]
- 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") % "premiumize.me")
- self.fail(_("No valid premiumize.me account provided"))
-
+ def handleMulti(self):
# 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
+ self.pyfile.name = self.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 = self.pyfile.name.split('.')
if temp.pop() in suffix_to_remove:
- pyfile.name = ".".join(temp)
+ self.pyfile.name = ".".join(temp)
# Get account data
- (user, data) = self.account.selectAccount()
+ user, data = self.account.selectAccount()
# Get rewritten link using the premiumize.me api v1 (see https://secure.premiumize.me/?show=api)
data = json_loads(self.load("https://api.premiumize.me/pm-api/v1.php",
get={'method' : "directdownloadlink",
'params[login]': user,
'params[pass]' : data['password'],
- 'params[link]' : pyfile.url}))
+ 'params[link]' : self.pyfile.url}))
# Check status and decide what to do
status = data['status']
+
if status == 200:
- self.download(data['result']['location'], disposition=True)
+ self.link = data['result']['location']
+ return
+
elif status == 400:
self.fail(_("Invalid link"))
+
elif status == 404:
self.offline()
+
elif status >= 500:
self.tempOffline()
+
else:
self.fail(data['statusmessage'])
+
+
+getInfo = create_getInfo(PremiumizeMe)