From 6c653c5eb10a4b77f2e63ad1e745ba612a46ae03 Mon Sep 17 00:00:00 2001 From: zoidberg10 Date: Sun, 8 Jan 2012 10:48:53 +0100 Subject: add premium4.me --- module/plugins/accounts/Premium4Me.py | 23 ++++++++++++++++++ module/plugins/hooks/Premium4Me.py | 46 +++++++++++++++++++++++++++++++++++ module/plugins/hoster/Premium4Me.py | 32 ++++++++++++++++++++++++ 3 files changed, 101 insertions(+) create mode 100644 module/plugins/accounts/Premium4Me.py create mode 100644 module/plugins/hooks/Premium4Me.py create mode 100644 module/plugins/hoster/Premium4Me.py (limited to 'module') diff --git a/module/plugins/accounts/Premium4Me.py b/module/plugins/accounts/Premium4Me.py new file mode 100644 index 000000000..c8c4064ef --- /dev/null +++ b/module/plugins/accounts/Premium4Me.py @@ -0,0 +1,23 @@ +from module.plugins.Account import Account + +class Premium4Me(Account): + __name__ = "Premium4Me" + __version__ = "0.01" + __type__ = "account" + __description__ = """Premium4.me account plugin""" + __author_name__ = ("RaNaN", "zoidberg") + __author_mail__ = ("RaNaN@pyload.org", "zoidberg@mujmail.cz") + + def loadAccountInfo(self, user, req): + traffic = req.load("http://premium4.me/api/traffic.php?authcode=%s" % self.authcode) + + account_info = {"trafficleft": int(traffic) / 1024, + "validuntil": -1} + + return account_info + + def login(self, user, data, req): + self.authcode = req.load("http://premium4.me/api/getauthcode.php?username=%s&password=%s" % (user, data["password"]))[:-1] + + if "wrong username" in self.authcode: + self.wrongPassword() \ No newline at end of file diff --git a/module/plugins/hooks/Premium4Me.py b/module/plugins/hooks/Premium4Me.py new file mode 100644 index 000000000..fc3ce2343 --- /dev/null +++ b/module/plugins/hooks/Premium4Me.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- + +from module.network.RequestFactory import getURL +from module.plugins.internal.MultiHoster import MultiHoster + +class Premium4Me(MultiHoster): + __name__ = "Premium4Me" + __version__ = "0.02" + __type__ = "hook" + + __config__ = [("activated", "bool", "Activated", "False"), + ("hosterListMode", "all;listed;unlisted", "Use for downloads from supported hosters:", "all"), + ("hosterList", "str", "Hoster list (comma separated)", "")] + __description__ = """premium4.me hook plugin""" + __author_name__ = ("RaNaN", "zoidberg") + __author_mail__ = ("RaNaN@pyload.org", "zoidberg@mujmail.cz") + + replacements = [("freakshare.net", "freakshare.com")] + + def getHoster(self): + + page = getURL("http://premium4.me/api/hosters.php?authcode=%s" % self.account.authcode) + hosters = set([x.strip() for x in page.replace("\"", "").split(";")]) + + configMode = self.getConfig('hosterListMode') + if configMode in ("listed", "unlisted"): + configList = set(self.getConfig('hosterList').strip().lower().replace(',','|').split('|')) + configList.discard(u'') + if configMode == "listed": + hosters &= configList + elif configMode == "unlisted": + hosters -= configList + + return list(hosters) + + def coreReady(self): + + self.account = self.core.accountManager.getAccountPlugin("Premium4Me") + + user = self.account.selectAccount()[0] + + if not user: + self.logError(_("Please add your premium4.me account first and restart pyLoad")) + return + + return MultiHoster.coreReady(self) \ No newline at end of file diff --git a/module/plugins/hoster/Premium4Me.py b/module/plugins/hoster/Premium4Me.py new file mode 100644 index 000000000..1d97e21b1 --- /dev/null +++ b/module/plugins/hoster/Premium4Me.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +from urllib import quote +from module.plugins.Hoster import Hoster + +class Premium4Me(Hoster): + __name__ = "Premium4Me" + __version__ = "0.01" + __type__ = "hoster" + + __pattern__ = r"http://premium4.me/.*" + __description__ = """premium4.me hoster plugin""" + __author_name__ = ("RaNaN", "zoidberg") + __author_mail__ = ("RaNaN@pyload.org", "zoidberg@mujmail.cz") + + def setup(self): + self.chunkLimit = 3 + self.resumeDownload = True + + 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.log.debug("premium4.me: Old URL: %s" % pyfile.url) + new_url = "http://premium4.me/api/getfile.php?authcode=%s&link=%s" % (self.account.authcode, quote(pyfile.url, "")) + + #raise timeout to 2min + self.req.setOption("timeout", 120) + + self.download(new_url, disposition=True) \ No newline at end of file -- cgit v1.2.3