summaryrefslogtreecommitdiffstats
path: root/pyload/plugins/accounts/EasybytezCom.py
diff options
context:
space:
mode:
Diffstat (limited to 'pyload/plugins/accounts/EasybytezCom.py')
-rw-r--r--pyload/plugins/accounts/EasybytezCom.py61
1 files changed, 61 insertions, 0 deletions
diff --git a/pyload/plugins/accounts/EasybytezCom.py b/pyload/plugins/accounts/EasybytezCom.py
new file mode 100644
index 000000000..595e95ec4
--- /dev/null
+++ b/pyload/plugins/accounts/EasybytezCom.py
@@ -0,0 +1,61 @@
+# -*- coding: utf-8 -*-
+
+import re
+from time import mktime, strptime, gmtime
+
+from pyload.plugins.Account import Account
+from pyload.plugins.internal.SimpleHoster import parseHtmlForm
+from pyload.utils import parseFileSize
+
+
+class EasybytezCom(Account):
+ __name__ = "EasybytezCom"
+ __type__ = "account"
+ __version__ = "0.04"
+
+ __description__ = """EasyBytez.com account plugin"""
+ __author_name__ = "zoidberg"
+ __author_mail__ = "zoidberg@mujmail.cz"
+
+ VALID_UNTIL_PATTERN = r'Premium account expire:</TD><TD><b>([^<]+)</b>'
+ TRAFFIC_LEFT_PATTERN = r'<TR><TD>Traffic available today:</TD><TD><b>(?P<S>[^<]+)</b>'
+
+
+ def loadAccountInfo(self, user, req):
+ html = req.load("http://www.easybytez.com/?op=my_account", decode=True)
+
+ validuntil = trafficleft = None
+ premium = False
+
+ m = re.search(self.VALID_UNTIL_PATTERN, html)
+ if m:
+ try:
+ self.logDebug("Expire date: " + m.group(1))
+ validuntil = mktime(strptime(m.group(1), "%d %B %Y"))
+ except Exception, e:
+ self.logError(e)
+ if validuntil > mktime(gmtime()):
+ premium = True
+ trafficleft = -1
+ else:
+ m = re.search(self.TRAFFIC_LEFT_PATTERN, html)
+ if m:
+ trafficleft = m.group(1)
+ if "Unlimited" in trafficleft:
+ trafficleft = -1
+ else:
+ trafficleft = parseFileSize(trafficleft) / 1024
+
+ return {"validuntil": validuntil, "trafficleft": trafficleft, "premium": premium}
+
+ def login(self, user, data, req):
+ html = req.load('http://www.easybytez.com/login.html', decode=True)
+ action, inputs = parseHtmlForm('name="FL"', html)
+ inputs.update({"login": user,
+ "password": data['password'],
+ "redirect": "http://www.easybytez.com/"})
+
+ html = req.load(action, post=inputs, decode=True)
+
+ if 'Incorrect Login or Password' in html or '>Error<' in html:
+ self.wrongPassword()