summaryrefslogtreecommitdiffstats
path: root/pyload/plugin/hoster/PremiumTo.py
diff options
context:
space:
mode:
Diffstat (limited to 'pyload/plugin/hoster/PremiumTo.py')
-rw-r--r--pyload/plugin/hoster/PremiumTo.py53
1 files changed, 53 insertions, 0 deletions
diff --git a/pyload/plugin/hoster/PremiumTo.py b/pyload/plugin/hoster/PremiumTo.py
new file mode 100644
index 000000000..c7ee09565
--- /dev/null
+++ b/pyload/plugin/hoster/PremiumTo.py
@@ -0,0 +1,53 @@
+# -*- coding: utf-8 -*-
+
+from __future__ import with_statement
+
+from os import remove
+
+from pyload.plugin.internal.MultiHoster import MultiHoster
+from pyload.utils import fs_encode
+
+
+class PremiumTo(MultiHoster):
+ __name = "PremiumTo"
+ __type = "hoster"
+ __version = "0.22"
+
+ __pattern = r'^unmatchable$'
+ __config = [("use_premium", "bool", "Use premium account if available", True)]
+
+ __description = """Premium.to multi-hoster plugin"""
+ __license = "GPLv3"
+ __authors = [("RaNaN", "RaNaN@pyload.org"),
+ ("zoidberg", "zoidberg@mujmail.cz"),
+ ("stickell", "l.stickell@yahoo.it")]
+
+
+ CHECK_TRAFFIC = True
+
+
+ def handlePremium(self, pyfile):
+ #raise timeout to 2min
+ self.download("http://premium.to/api/getfile.php",
+ get={'username': self.account.username,
+ 'password': self.account.password,
+ 'link' : pyfile.url},
+ disposition=True)
+
+
+ def checkFile(self, rules={}):
+ if self.checkDownload({'nopremium': "No premium account available"}):
+ self.retry(60, 5 * 60, "No premium account available")
+
+ err = ''
+ if self.req.http.code == '420':
+ # Custom error code send - fail
+ file = fs_encode(self.lastDownload)
+ with open(file, "rb") as f:
+ err = f.read(256).strip()
+ remove(file)
+
+ if err:
+ self.fail(err)
+
+ return super(PremiumTo, self).checkFile(rules)