diff options
author | Pedro Algarvio <pedro@algarvio.me> | 2012-01-22 18:31:46 +0100 |
---|---|---|
committer | Pedro Algarvio <pedro@algarvio.me> | 2012-01-22 18:31:46 +0100 |
commit | 4741b4f8816bff7b0c803ac057c60b35e9909ad4 (patch) | |
tree | 775293bbd0453cae01b73d3c6bcef88bd26a6900 /module/plugins/accounts | |
parent | Merge branches. (diff) | |
parent | undelete DlFreeFr (diff) | |
download | pyload-4741b4f8816bff7b0c803ac057c60b35e9909ad4.tar.xz |
Merge stable.
Diffstat (limited to 'module/plugins/accounts')
-rw-r--r-- | module/plugins/accounts/MegasharesCom.py | 42 | ||||
-rw-r--r-- | module/plugins/accounts/UlozTo.py | 34 |
2 files changed, 76 insertions, 0 deletions
diff --git a/module/plugins/accounts/MegasharesCom.py b/module/plugins/accounts/MegasharesCom.py new file mode 100644 index 000000000..91601fc95 --- /dev/null +++ b/module/plugins/accounts/MegasharesCom.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- + +from module.plugins.Account import Account +import re +from time import mktime, strptime + +class MegasharesCom(Account): + __name__ = "MegasharesCom" + __version__ = "0.02" + __type__ = "account" + __description__ = """megashares.com account plugin""" + __author_name__ = ("zoidberg") + __author_mail__ = ("zoidberg@mujmail.cz") + + VALID_UNTIL_PATTERN = r'<p class="premium_info_box">Period Ends: (\w{3} \d{1,2}, \d{4})</p>' + + def loadAccountInfo(self, user, req): + #self.relogin(user) + html = req.load("http://d01.megashares.com/myms.php", decode = True) + + premium = False if '>Premium Upgrade<' in html else True + + validuntil = trafficleft = -1 + try: + timestr = re.search(self.VALID_UNTIL_PATTERN, html).group(1) + self.logDebug(timestr) + validuntil = mktime(strptime(timestr, "%b %d, %Y")) + except Exception, e: + self.logError(e) + + return {"validuntil": validuntil, "trafficleft": -1, "premium": premium} + + def login(self, user, data, req): + html = req.load('http://d01.megashares.com/myms_login.php', post = { + "httpref": "", + "myms_login": "Login", + "mymslogin_name": user, + "mymspassword": data['password'] + }, decode = True) + + if not '<span class="b ml">%s</span>' % user in html: + self.wrongPassword()
\ No newline at end of file diff --git a/module/plugins/accounts/UlozTo.py b/module/plugins/accounts/UlozTo.py new file mode 100644 index 000000000..36e1ae342 --- /dev/null +++ b/module/plugins/accounts/UlozTo.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- + +from module.plugins.Account import Account +import re + +class UlozTo(Account): + __name__ = "UlozTo" + __version__ = "0.01" + __type__ = "account" + __description__ = """uloz.to account plugin""" + __author_name__ = ("zoidberg") + __author_mail__ = ("zoidberg@mujmail.cz") + + TRAFFIC_LEFT_PATTERN = r'<li class="credit"><a href="/kredit/" class="coins" title="[^"]* GB = ([^"]+) MB">' + + def loadAccountInfo(self, user, req): + html = req.load("http://www.uloz.to/statistiky/", decode = True) + + found = re.search(self.TRAFFIC_LEFT_PATTERN, html) + trafficleft = int(float(found.group(1).replace(' ','').replace(',','.')) * 1000 / 1.024) if found else 0 + self.premium = True if trafficleft else False + + return {"validuntil": -1, "trafficleft": trafficleft} + + def login(self, user, data, req): + html = req.load('http://www.uloz.to/?do=authForm-submit', post = { + "login": "Přihlásit", + "password": data['password'], + "trvale": "on", + "username": user + }, decode = True) + + if '<ul class="error">' in html: + self.wrongPassword()
\ No newline at end of file |