diff options
Diffstat (limited to 'module/plugins/accounts')
-rw-r--r-- | module/plugins/accounts/FshareVn.py | 59 | ||||
-rw-r--r-- | module/plugins/accounts/HellspyCz.py | 19 |
2 files changed, 64 insertions, 14 deletions
diff --git a/module/plugins/accounts/FshareVn.py b/module/plugins/accounts/FshareVn.py new file mode 100644 index 000000000..46d2d5166 --- /dev/null +++ b/module/plugins/accounts/FshareVn.py @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- + +""" + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, + or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, see <http://www.gnu.org/licenses/>. + + @author: zoidberg +""" + +from module.plugins.Account import Account +from time import mktime, strptime +from pycurl import REFERER +import re + +class FshareVn(Account): + __name__ = "FshareVn" + __version__ = "0.01" + __type__ = "account" + __description__ = """fshare.vn account plugin""" + __author_name__ = ("zoidberg") + __author_mail__ = ("zoidberg@mujmail.cz") + + VALID_UNTIL_PATTERN = ur'<dt>Thời hạn dùng:</dt>\s*<dd>([^<]+)</dd>' + TRAFFIC_LEFT_PATTERN = ur'<dt>Bandwidth Còn Lại</dt>\s*<dd[^>]*>([0-9.]+) ([kKMG])B</dd>' + DIRECT_DOWNLOAD_PATTERN = ur'<input type="checkbox"\s*([^=>]*)[^>]*/>Kích hoạt download trực tiếp</dt>' + + def loadAccountInfo(self, user, req): + #self.relogin(user) + html = req.load("http://www.fshare.vn/account_info.php", decode = True) + + found = re.search(self.VALID_UNTIL_PATTERN, html) + validuntil = mktime(strptime(found.group(1), '%I:%M:%S %p %d-%m-%Y')) if found else 0 + + found = re.search(self.TRAFFIC_LEFT_PATTERN, html) + trafficleft = float(found.group(1)) * 1024 ** {'k': 0, 'K': 0, 'M': 1, 'G': 2}[found.group(2)] if found else 0 + + return {"validuntil": validuntil, "trafficleft": trafficleft} + + def login(self, user, data, req): + req.http.c.setopt(REFERER, "http://www.fshare.vn/login.php") + + html = req.load('http://www.fshare.vn/login.php', post = { + "login_password" : data['password'], + "login_useremail" : user, + "url_refe" : "http://www.fshare.vn/login.php" + }, referer = True, decode = True) + + if not '<img alt="VIP"' in html: + self.wrongPassword()
\ No newline at end of file diff --git a/module/plugins/accounts/HellspyCz.py b/module/plugins/accounts/HellspyCz.py index c07fd748a..5f14a093e 100644 --- a/module/plugins/accounts/HellspyCz.py +++ b/module/plugins/accounts/HellspyCz.py @@ -29,8 +29,7 @@ class HellspyCz(Account): __author_name__ = ("zoidberg") __author_mail__ = ("zoidberg@mujmail.cz") - ACTION_PATTERN = r'<div id="snippet--loginBoxSn"><form[^>]*action="([^"]+user_hash=([^"]+))">' - CREDIT_LEFT_PATTERN = r'<strong class="text-credits">(\d+)</strong>' + CREDIT_LEFT_PATTERN = r'<strong>Credits: </strong>\s*(\d+)' WRONG_PASSWORD_PATTERN = r'<p class="block-error-3 marg-tb-050">\s*Wrong user or password was entered<br />' phpsessid = '' @@ -50,16 +49,13 @@ class HellspyCz(Account): return {"validuntil": -1, "trafficleft": credits} def login(self, user, data,req): - html = req.load('http://www.hellspy.com/') - found = re.search(self.ACTION_PATTERN, html) - if found is None: - self.logError('Parse error (FORM)') - action, self.phpsessid = found.group(1).replace('&','&'), found.group(2) - + header = req.load('http://www.hellspy.com/', just_header = True) + self.phpsessid = re.search(r'PHPSESSID=(\w+)', header).group(1) self.logDebug("PHPSESSID:" + self.phpsessid) + html = req.load("http://www.hellspy.com/--%s-" % self.phpsessid) - html = req.load(action, post={ + html = req.load("http://www.hell-share.com/user/login/?do=apiLoginForm-submit&api_hash=hellspy_iq&user_hash=%s" % self.phpsessid, post={ "login": "1", "password": data["password"], "username": user, @@ -70,10 +66,5 @@ class HellspyCz(Account): cj = self.getAccountCookies(user) cj.setCookie(".hellspy.com", "PHPSESSID", self.phpsessid) - self.logDebug(req.lastURL) - self.logDebug(req.lastEffectiveURL) - - html = req.load("http://www.hellspy.com/", get = {"do":"loginBox-login"}) - if not re.search(self.CREDIT_LEFT_PATTERN, html): self.wrongPassword()
\ No newline at end of file |