summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorGravatar zoidberg10 <zoidberg@mujmail.cz> 2012-08-10 16:49:28 +0200
committerGravatar zoidberg10 <zoidberg@mujmail.cz> 2012-08-10 16:49:28 +0200
commit37fc7ae3d4177e5d111fba70975df8e4a9575319 (patch)
treec3e15bd88bf961482b028d8b198cb7d27185be27 /module
parentupdates c1neonCom decrypter (diff)
downloadpyload-37fc7ae3d4177e5d111fba70975df8e4a9575319.tar.xz
easybytez.com -- closed #625
Diffstat (limited to 'module')
-rw-r--r--module/plugins/accounts/EasybytezCom.py39
-rw-r--r--module/plugins/internal/SimpleHoster.py41
2 files changed, 51 insertions, 29 deletions
diff --git a/module/plugins/accounts/EasybytezCom.py b/module/plugins/accounts/EasybytezCom.py
index cf2b16394..ba7829b83 100644
--- a/module/plugins/accounts/EasybytezCom.py
+++ b/module/plugins/accounts/EasybytezCom.py
@@ -18,13 +18,14 @@
"""
from module.plugins.Account import Account
+from module.plugins.internal.SimpleHoster import parseHtmlForm
import re
from module.utils import parseFileSize
from time import mktime, strptime
class EasybytezCom(Account):
__name__ = "EasybytezCom"
- __version__ = "0.01"
+ __version__ = "0.02"
__type__ = "account"
__description__ = """EasyBytez.com account plugin"""
__author_name__ = ("zoidberg")
@@ -33,36 +34,40 @@ class EasybytezCom(Account):
VALID_UNTIL_PATTERN = r'<TR><TD>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):
- #self.relogin(user)
+ def loadAccountInfo(self, user, req):
html = req.load("http://www.easybytez.com/?op=my_account", decode = True)
- validuntil = -1
+ validuntil = trafficleft = None
+ premium = False
+
found = re.search(self.VALID_UNTIL_PATTERN, html)
if found:
premium = True
+ trafficleft = -1
try:
self.logDebug(found.group(1))
validuntil = mktime(strptime(found.group(1), "%d %B %Y"))
except Exception, e:
self.logError(e)
else:
- premium = False
-
- #found = re.search(self.TRAFFIC_LEFT_PATTERN, html)
- #trafficleft = parseFileSize(found.group('S')) / 1024 if found else 0
- #self.premium = True if trafficleft else False
- trafficleft = -1
+ found = re.search(self.TRAFFIC_LEFT_PATTERN, html)
+ if found:
+ trafficleft = found.group(1)
+ if "Unlimited" in trafficleft:
+ premium = True
+ 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/', post = {
- "login": user,
- "op": "login",
- "password": data['password'],
- "redirect": "http://easybytez.com/"
- }, decode = True)
+ 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:
+ if 'Incorrect Login or Password' in html or '>Error<' in html:
self.wrongPassword() \ No newline at end of file
diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py
index 3ae780ba2..09b496aa9 100644
--- a/module/plugins/internal/SimpleHoster.py
+++ b/module/plugins/internal/SimpleHoster.py
@@ -42,6 +42,18 @@ def parseHtmlTagAttrValue(attr_name, tag):
m = re.search(r"%s\s*=\s*([\"']?)((?<=\")[^\"]+|(?<=')[^']+|[^\s\"'][^>\s]+)\1" % attr_name, tag)
return m.group(2) if m else ''
+def parseHtmlForm(attr_str, html):
+ inputs = {}
+ action = None
+ form = re.search(r"(?P<tag><form[^>]*%s[^>]*>)(?P<content>.*?)</(form|body|html)[^>]*>" % attr_str, html, re.S | re.I)
+ if form:
+ action = parseHtmlTagAttrValue("action", form.group('tag'))
+ for input in re.finditer(r'(<(?:input|textarea)[^>]*>)', form.group('content'), re.S | re.I):
+ name = parseHtmlTagAttrValue("name", input.group(1))
+ if name:
+ inputs[name] = parseHtmlTagAttrValue("value", input.group(1))
+ return action, inputs
+
def parseFileInfo(self, url = '', html = ''):
info = {"name" : url, "size" : 0, "status" : 3}
@@ -112,7 +124,7 @@ class PluginParseError(Exception):
class SimpleHoster(Hoster):
__name__ = "SimpleHoster"
- __version__ = "0.22"
+ __version__ = "0.24"
__pattern__ = None
__type__ = "hoster"
__description__ = """Base hoster plugin"""
@@ -184,19 +196,24 @@ class SimpleHoster(Hoster):
self.fail("Premium download not implemented")
def parseError(self, msg):
- raise PluginParseError(msg)
+ raise PluginParseError(msg)
+
+ def longWait(self, wait_time = None, max_tries = 3):
+ if wait_time and isinstance(wait_time, (int, long, float)):
+ time_str = "%dh %dm" % divmod(wait_time / 60, 60)
+ else:
+ wait_time = 900
+ time_str = "(unknown time)"
+ max_tries = 100
+
+ self.logInfo("Download limit reached, reconnect or wait %s" % time_str)
+
+ self.setWait(wait_time, True)
+ self.wait()
+ self.retry(max_tries = max_tries, reason="Download limit reached")
def parseHtmlForm(self, attr_str):
- inputs = {}
- action = None
- form = re.search(r"(?P<tag><form[^>]*%s[^>]*>)(?P<content>.*?)</(form|body|html)[^>]*>" % attr_str, self.html, re.S | re.I)
- if form:
- action = parseHtmlTagAttrValue("action", form.group('tag'))
- for input in re.finditer(r'(<(?:input|textarea)[^>]*>)', form.group('content'), re.S | re.I):
- name = parseHtmlTagAttrValue("name", input.group(1))
- if name:
- inputs[name] = parseHtmlTagAttrValue("value", input.group(1))
- return action, inputs
+ return parseHtmlForm(attr_str, self.html)
def checkTrafficLeft(self):
traffic = self.account.getAccountInfo(self.user, True)["trafficleft"]