diff options
| author | 2014-12-27 14:46:23 +0100 | |
|---|---|---|
| committer | 2014-12-27 14:46:23 +0100 | |
| commit | d93d7de59b219ef55aea98f0da00690753fe7afe (patch) | |
| tree | 0b59bc1de0e90c9bf2c56c71f6b92deea0cee699 /module/plugins/accounts | |
| parent | Merge pull request #683 from synweap15/nopremium (diff) | |
| parent | Added support for Multihosters.com multihoster. (diff) | |
| download | pyload-d93d7de59b219ef55aea98f0da00690753fe7afe.tar.xz | |
Merge pull request #698 from tjeh/stable
Added support for Multihosters.com multihoster.
Diffstat (limited to 'module/plugins/accounts')
| -rw-r--r-- | module/plugins/accounts/MultihostersCom.py | 50 | 
1 files changed, 50 insertions, 0 deletions
| diff --git a/module/plugins/accounts/MultihostersCom.py b/module/plugins/accounts/MultihostersCom.py new file mode 100644 index 000000000..3f96fdf41 --- /dev/null +++ b/module/plugins/accounts/MultihostersCom.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- + +from time import mktime, strptime +from module.plugins.Account import Account + +class MultihostersCom(Account): +    __name__ = "MultihostersCom" +    __version__ = "0.01" +    __type__ = "account" +    __description__ = """Multihosters.com account plugin""" +    __author_name__ = "tjeh" +    __author_mail__ = "tjeh@gmx.net" + +    def loadAccountInfo(self, user, req): +        data = self.getAPIData(req) +        if data == "No traffic": +            account_info = {"trafficleft": 0, "validuntil": 0, "premium": False} +        else: +            account_info = { +                "trafficleft": int(data['availabletodaytraffic']) * 1024, +                "validuntil": mktime(strptime(data['endsubscriptiondate'], "%Y/%m/%d %H:%M:%S")), +                "premium": True +            } +        return account_info + +    def login(self, user, data, req): +        self.loginname = user +        self.password = data['password'] +        if self.getAPIData(req) == "No traffic": +            self.wrongPassword() + +    def getAPIData(self, req, just_header=False, **kwargs): +        get_data = { +            'cmd': 'accountinfo', +            'login': self.loginname, +            'pass': self.password +        } +        get_data.update(kwargs) + +        response = req.load("http://www.multihosters.com/jDownloader.ashx", get=get_data, +                            decode=True, just_header=just_header) +        self.logDebug(response) + +        if ':' in response: +            if not just_header: +                response = response.replace(',', '\n') +            return dict((y.strip().lower(), z.strip()) for (y, z) in +                        [x.split(':', 1) for x in response.splitlines() if ':' in x]) +        else: +            return response | 
