summaryrefslogtreecommitdiffstats
path: root/module/plugins/accounts
diff options
context:
space:
mode:
authorGravatar Elrick69 <elrick69@rocketmail.com> 2014-04-30 11:36:24 +0200
committerGravatar Stefano <l.stickell@yahoo.it> 2014-04-30 11:36:24 +0200
commit530f6a9c5e9977e11d6b673909dedfacf27d55ec (patch)
tree9ba5d3186c9f10faf8fc7dde2bd32514ccfb5c85 /module/plugins/accounts
parentUptobox: fixed #588 (diff)
downloadpyload-530f6a9c5e9977e11d6b673909dedfacf27d55ec.tar.xz
1Fichier: premium support
Merges #594 and #595
Diffstat (limited to 'module/plugins/accounts')
-rw-r--r--module/plugins/accounts/OneFichierCom.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/module/plugins/accounts/OneFichierCom.py b/module/plugins/accounts/OneFichierCom.py
new file mode 100644
index 000000000..b10e34314
--- /dev/null
+++ b/module/plugins/accounts/OneFichierCom.py
@@ -0,0 +1,46 @@
+# -*- coding: utf-8 -*-
+
+import re
+from time import strptime, mktime
+from pycurl import REFERER
+
+from module.plugins.Account import Account
+
+
+class OneFichierCom(Account):
+ __name__ = "OneFichierCom"
+ __version__ = "0.1"
+ __type__ = "account"
+ __description__ = """1fichier.com account plugin"""
+ __author_name__ = ("Elrick69")
+ __author_mail__ = ("elrick69[AT]rocketmail[DOT]com")
+
+ VALID_UNTIL_PATTERN = r'You are a premium user until (?P<d>\d{2})/(?P<m>\d{2})/(?P<y>\d{4})'
+
+ def loadAccountInfo(self, user, req):
+
+ html = req.load("http://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<d>/\g<m>/\g<y>', m.group(0))
+ validuntil = int(mktime(strptime(validuntil, "%d/%m/%Y")))
+ else:
+ premium = False
+ validuntil = -1
+
+ return {"premium": premium, "trafficleft": -1, "validuntil": validuntil}
+
+ def login(self, user, data, req):
+
+ req.http.c.setopt(REFERER, "http://1fichier.com/login.pl?lg=en")
+
+ html = req.load("http://1fichier.com/login.pl?lg=en", post={
+ "mail": user,
+ "pass": data["password"],
+ "Login": "Login"})
+
+ if r'<div class="error_message">Invalid username or password.</div>' in html:
+ self.wrongPassword()