diff options
author | Florian Franzen <FlorianFranzen@gmail.com> | 2012-04-09 18:30:54 +0200 |
---|---|---|
committer | Florian Franzen <FlorianFranzen@gmail.com> | 2012-04-09 18:30:54 +0200 |
commit | 3be8d531ce7c6500170bde8b8dbe49e7dc59ad39 (patch) | |
tree | a53ed551df68110ee398945c1a88a5da7cf83b4d /module/plugins/hoster | |
parent | icyfiles, bayfiles by godofdream, alldebrid json api, zevera python 2.5 compat. (diff) | |
download | pyload-3be8d531ce7c6500170bde8b8dbe49e7dc59ad39.tar.xz |
Added premiumize.me support, using their new API (https://secure.premiumize.me/?show=api). This fixes #416.
Diffstat (limited to 'module/plugins/hoster')
-rw-r--r-- | module/plugins/hoster/PremiumizeMe.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/module/plugins/hoster/PremiumizeMe.py b/module/plugins/hoster/PremiumizeMe.py new file mode 100644 index 000000000..2b1306820 --- /dev/null +++ b/module/plugins/hoster/PremiumizeMe.py @@ -0,0 +1,41 @@ +from module.plugins.Hoster import Hoster
+
+from module.common.json_layer import json_loads
+
+class PremiumizeMe(Hoster):
+ __name__ = "PremiumizeMe"
+ __version__ = "0.1"
+ __type__ = "hoster"
+ __description__ = """Premiumize.Me hoster plugin"""
+
+ # Since we want to allow the user to specify the list of hoster to use we let MultiHoster.coreReady create the regex patterns for us using getHosters in our PremiumizeMe hook.
+ __pattern__ = ""
+
+ __author_name__ = ("Florian Franzen")
+ __author_mail__ = ("FlorianFranzen@gmail.com")
+
+ def process(self, pyfile):
+ # Check account
+ if not self.account or not self.account.canUse():
+ self.logError(_("Please enter a valid premiumize.me account or deactivate this plugin"))
+ self.fail("No valid premiumize.me account provided")
+
+ # Get account data
+ (user, data) = self.account.selectAccount()
+
+ # Get rewritten link using the premiumize.me api v1 (see https://secure.premiumize.me/?show=api)
+ answer = self.load("https://api.premiumize.me/pm-api/v1.php?method=directdownloadlink¶ms[login]=%s¶ms[pass]=%s¶ms[link]=%s" % (user, data['password'], pyfile.url))
+ data = json_loads(answer)
+
+ # Check status and decide what to do
+ status = data['status']
+ if status == 200:
+ self.download(data['result']['location'])
+ elif status == 400:
+ self.fail("Invalid link")
+ elif status == 404:
+ self.offline()
+ elif status >= 500:
+ self.tempOffline()
+ else:
+ self.fail(data['statusmessage'])
\ No newline at end of file |