summaryrefslogtreecommitdiffstats
path: root/pyload/plugins/hoster/Premium4Me.py
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-06-09 18:10:22 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-06-09 18:10:23 +0200
commit16af85004c84d0d6c626b4f8424ce9647669a0c1 (patch)
tree025d479862d376dbc17e934f4ed20031c8cd97d1 /pyload/plugins/hoster/Premium4Me.py
parentadapted to jshint config (diff)
downloadpyload-16af85004c84d0d6c626b4f8424ce9647669a0c1.tar.xz
moved everything from module to pyload
Diffstat (limited to 'pyload/plugins/hoster/Premium4Me.py')
-rw-r--r--pyload/plugins/hoster/Premium4Me.py70
1 files changed, 70 insertions, 0 deletions
diff --git a/pyload/plugins/hoster/Premium4Me.py b/pyload/plugins/hoster/Premium4Me.py
new file mode 100644
index 000000000..c93084d5d
--- /dev/null
+++ b/pyload/plugins/hoster/Premium4Me.py
@@ -0,0 +1,70 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+from urllib import quote
+from os.path import exists
+from os import remove
+
+from module.plugins.Hoster import Hoster
+from module.utils import fs_encode
+
+
+class Premium4Me(Hoster):
+ __name__ = "Premium4Me"
+ __version__ = "0.05"
+ __type__ = "hoster"
+
+ __pattern__ = r"http://premium4.me/.*"
+ __description__ = """premium4.me hoster plugin"""
+ __author_name__ = ("RaNaN", "zoidberg", "stickell")
+ __author_mail__ = ("RaNaN@pyload.org", "zoidberg@mujmail.cz", "l.stickell@yahoo.it")
+
+ def setup(self):
+ self.resumeDownload = True
+ self.chunkLimit = 1
+
+ def process(self, pyfile):
+ if not self.account:
+ self.logError(_("Please enter your premium4.me account or deactivate this plugin"))
+ self.fail("No premium4.me account provided")
+
+ self.logDebug("premium4.me: Old URL: %s" % pyfile.url)
+
+ tra = self.getTraffic()
+
+ #raise timeout to 2min
+ self.req.setOption("timeout", 120)
+
+ self.download(
+ "http://premium4.me/api/getfile.php?authcode=%s&link=%s" % (self.account.authcode, quote(pyfile.url, "")),
+ disposition=True)
+
+ check = self.checkDownload({"nopremium": "No premium account available"})
+
+ if check == "nopremium":
+ self.retry(3, 60, 'No premium account available')
+
+ err = ''
+ if self.req.http.code == '420':
+ # Custom error code send - fail
+ lastDownload = fs_encode(self.lastDownload)
+
+ if exists(lastDownload):
+ f = open(lastDownload, "rb")
+ err = f.read(256).strip()
+ f.close()
+ remove(lastDownload)
+ else:
+ err = 'File does not exist'
+
+ trb = self.getTraffic()
+ self.logInfo("Filesize: %d, Traffic used %d, traffic left %d" % (pyfile.size, tra - trb, trb))
+
+ if err: self.fail(err)
+
+ def getTraffic(self):
+ try:
+ traffic = int(self.load("http://premium4.me/api/traffic.php?authcode=%s" % self.account.authcode))
+ except:
+ traffic = 0
+ return traffic