From e8d1f1e6083dd7caa30dce97eeb5c6005c9f79f9 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 4 Nov 2014 13:03:24 +0100 Subject: [OneFichierCom] Fixed account plugin --- module/plugins/accounts/OneFichierCom.py | 43 +++++++++++++++++++------------- 1 file changed, 25 insertions(+), 18 deletions(-) (limited to 'module/plugins/accounts') diff --git a/module/plugins/accounts/OneFichierCom.py b/module/plugins/accounts/OneFichierCom.py index a95e4df34..dae892c05 100644 --- a/module/plugins/accounts/OneFichierCom.py +++ b/module/plugins/accounts/OneFichierCom.py @@ -1,7 +1,9 @@ # -*- coding: utf-8 -*- import re + from time import strptime, mktime + from pycurl import REFERER from module.plugins.Account import Account @@ -10,39 +12,44 @@ from module.plugins.Account import Account class OneFichierCom(Account): __name__ = "OneFichierCom" __type__ = "account" - __version__ = "0.1" + __version__ = "0.11" __description__ = """1fichier.com account plugin""" __license__ = "GPLv3" - __authors__ = [("Elrick69", "elrick69[AT]rocketmail[DOT]com")] + __authors__ = [("Elrick69", "elrick69[AT]rocketmail[DOT]com"), + ("Walter Purcaro", "vuolter@gmail.com")] - VALID_UNTIL_PATTERN = r'You are a premium user until (?P\d{2})/(?P\d{2})/(?P\d{4})' + VALID_UNTIL_PATTERN = r'Your Premium Status will end the (\d+/\d+/\d+)' def loadAccountInfo(self, user, req): - html = req.load("http://1fichier.com/console/abo.pl") + validuntil = None + trafficleft = -1 + premium = None - m = re.search(self.VALID_UNTIL_PATTERN, html) + html = req.load("https://1fichier.com/console/abo.pl") + m = re.search(self.VALID_UNTIL_PATTERN, html) if m: - premium = True - validuntil = re.sub(self.VALID_UNTIL_PATTERN, '\g/\g/\g', m.group(0)) - validuntil = int(mktime(strptime(validuntil, "%d/%m/%Y"))) - else: - premium = False - validuntil = -1 + expiredate = m.group(1) + self.logDebug("Expire date: " + expiredate) + + try: + validuntil = mktime(strptime(expiredate, "%d/%m/%Y")) + except Exception, e: + self.logError(str(e)) + else: + premium = True - return {"premium": premium, "trafficleft": -1, "validuntil": validuntil} + return {'validuntil': validuntil, 'trafficleft': trafficleft, 'premium': premium or False} def login(self, user, data, req): - req.http.c.setopt(REFERER, "http://1fichier.com/login.pl?lg=en") + req.http.c.setopt(REFERER, "https://1fichier.com/login.pl?lg=en") - html = req.load("http://1fichier.com/login.pl?lg=en", post={ - "mail": user, - "pass": data['password'], - "Login": "Login"}) + html = req.load("https://1fichier.com/login.pl?lg=en", + post={'mail': user, 'pass': data['password'], 'It': "on", 'purge': "off", 'valider': "Send"}) - if r'
Invalid username or password.
' in html: + if '>Invalid email address' in html or '>Invalid password' in html: self.wrongPassword() -- cgit v1.2.3