diff options
author | zoidberg10 <zoidberg@mujmail.cz> | 2011-10-29 13:48:09 +0200 |
---|---|---|
committer | zoidberg10 <zoidberg@mujmail.cz> | 2011-10-29 13:48:09 +0200 |
commit | 2aac609c9826a68f0fabbf8be956600e4506608a (patch) | |
tree | 50e3a545c549a2ac41330001d8182edd62d93ba0 /module/plugins | |
parent | closed #411 (diff) | |
download | pyload-2aac609c9826a68f0fabbf8be956600e4506608a.tar.xz |
update hellshare.cz
Diffstat (limited to 'module/plugins')
-rw-r--r-- | module/plugins/accounts/HellshareCz.py | 20 | ||||
-rw-r--r-- | module/plugins/hoster/HellshareCz.py | 123 |
2 files changed, 71 insertions, 72 deletions
diff --git a/module/plugins/accounts/HellshareCz.py b/module/plugins/accounts/HellshareCz.py index eb44ee47f..fc44e9307 100644 --- a/module/plugins/accounts/HellshareCz.py +++ b/module/plugins/accounts/HellshareCz.py @@ -13,7 +13,7 @@ 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 """ @@ -22,33 +22,33 @@ import re class HellshareCz(Account): __name__ = "HellshareCz" - __version__ = "0.1" + __version__ = "0.11" __type__ = "account" __description__ = """hellshare.cz account plugin""" __author_name__ = ("zoidberg") __author_mail__ = ("zoidberg@mujmail.cz") - - CREDIT_LEFT_PATTERN = r'<a class="button-amount-1" href="/buy-credit/" title="Your current credit">([^<]+)</a>' + + CREDIT_LEFT_PATTERN = r'<div class="credit-link">\s*<table>\s*<tr>\s*<th>(\d+)</th>' def loadAccountInfo(self, user, req): self.relogin(user) html = req.load("http://www.hellshare.com/") - + found = re.search(self.CREDIT_LEFT_PATTERN, html) if found is None: credits = 0 else: credits = int(found.group(1)) * 1024 - + return {"validuntil": -1, "trafficleft": credits} - + def login(self, user, data, req): - + html = req.load('http://www.hellshare.com/login?do=loginForm-submit', post={ "login": "Log in", "password": data["password"], "username": user }) - + if "<p>You input a wrong user name or wrong password</p>" in html: - self.wrongPassword() + self.wrongPassword()
\ No newline at end of file diff --git a/module/plugins/hoster/HellshareCz.py b/module/plugins/hoster/HellshareCz.py index 7ff5e5367..7986ecf11 100644 --- a/module/plugins/hoster/HellshareCz.py +++ b/module/plugins/hoster/HellshareCz.py @@ -31,94 +31,94 @@ def getInfo(urls): result.append((url, 0, 1, url)) else: # Get file info + found = re.search(HellshareCz.FILE_SIZE_PATTERN, html) + if found is not None: + size, units = found.groups() + size = float(size) * 1024 ** {'kB': 1, 'KB': 1, 'MB': 2, 'GB': 3}[units] + found = re.search(HellshareCz.FILE_NAME_PATTERN, html) if found is not None: name = found.group(1) + + if found or size > 0: result.append((name, 0, 2, url)) yield result - class HellshareCz(Hoster): __name__ = "HellshareCz" __type__ = "hoster" __pattern__ = r"http://(.*\.)*hellshare\.(cz|com|sk|hu)/.*" - __version__ = "0.6" + __version__ = "0.70" __description__ = """Hellshare.cz""" __author_name__ = ("zoidberg") - FREE_URL_PATTERN = r'<a id="button-download-free" href="([^"]*)"' - PREMIUM_URL_PATTERN = r'<a onclick="return launchFullDownload[^>]*href="(http://[^/]+/([^/]+)/[^"]+)" target="full-download-iframe">' - FILE_NAME_PATTERN = r'<strong id="FileName_master">([^<]+)</strong>' - FILE_OFFLINE_PATTERN = r'<h1>Soubor nenalezen</h1>' - SERVER_PATTERN = r'<form method="post" action="([^"]+)">' - CAPTCHA_PATTERN = r'<p class="text-center marg-off"><img id="captcha-img" class="va-middle" src="([^"]+)"' - FILE_CREDITS_PATTERN = r'<strong style="font-size:20px;">(\d+)\s*credits</strong>' - CREDIT_LEFT_PATTERN = r'<a class="button-amount-1" href="[^>]*/buy-credit/" title="Your current credit">([^<]+)</a>' - DOWNLOAD_AGAIN_PATTERN = r'Soubor jste ji. stahoval - opakovan. download prob.hne zdarma. Pokra.ovat' + FREE_URL_PATTERN = r'<h3>I\'ll wait.*\s*<form action="([^"]*)"' + PREMIUM_URL_PATTERN = r"launchFullDownload\('([^']*)'\);" + FILE_NAME_PATTERN = r'<h1 id="filename">([^<]+)</h1>' + FILE_SIZE_PATTERN = r'<td><span>Size</span></td>\s*<th><span>([0-9.]*) (kB|KB|MB|GB)</span></th>' + FILE_OFFLINE_PATTERN = r'<h1>File not found.</h1>' + CAPTCHA_PATTERN = r'<img class="left" id="captcha-img"src="([^"]*)" />' + FILE_CREDITS_PATTERN = r'<strong class="filesize">(\d+) MB</strong>' + CREDIT_LEFT_PATTERN = r'<p>After downloading this file you will have (\d+) MB for future downloads.' + DOWNLOAD_AGAIN_PATTERN = r'<p>This file you downloaded already and re-download is for free. </p>' def setup(self): self.resumeDownload = self.multiDL = True if self.account else False self.chunkLimit = 1 def process(self, pyfile): - if self.premium and self.account is not None: + if self.account: self.account.relogin(self.user) - self.getFileInfo(pyfile) + + pyfile.url = re.search(r'([^?]*)', pyfile.url).group(1) + self.html = self.load(pyfile.url, get = {"do" : "fileDownloadButton-showDownloadWindow"}, decode=True) + self.getFileInfo(pyfile) + + if self.account: self.handlePremium() else: - self.getFileInfo(pyfile) self.handleFree() def getFileInfo(self, pyfile): - self.html = self.load(pyfile.url, decode=True) - #marks the file as "offline" when the pattern was found on the html-page if re.search(self.FILE_OFFLINE_PATTERN, self.html) is not None: self.offline() - # parse the name from the site and set attribute in pyfile + # parse the name from the site and set attribute in pyfile found = re.search(self.FILE_NAME_PATTERN, self.html) if found is None: self.fail("Parse error (Filename") pyfile.name = found.group(1) - def handleFree(self): - # parse free download url - found = re.search(self.FREE_URL_PATTERN, self.html) - if found is None: - self.fail("Parse error (URL)") - - parsed_url = found.group(1) + found = re.search(self.FILE_SIZE_PATTERN, self.html) + if found is not None: + size, units = found.groups() + pyfile.size = float(size) * 1024 ** {'kB': 1, 'KB': 1, 'MB': 2, 'GB': 3}[units] - if parsed_url == "": + def handleFree(self): + # hellshare is very generous + if 'You exceeded your today's limit for free download. You can download only 1 files per 24 hours.' in self.html: t = datetime.datetime.today().replace(hour=1, minute=0, second=0) + datetime.timedelta( days=1) - datetime.datetime.today() self.setWait(t.seconds, True) self.wait() self.retry() - # get download ticket and parse html - self.logDebug("PARSED_URL:" + parsed_url) - self.html = self.load(parsed_url) - - found = re.search(self.SERVER_PATTERN, self.html) - if found is None: - self.fail("Parse error (Server)") - download_url = found.group(1) + # parse free download url + found = re.search(self.FREE_URL_PATTERN, self.html) + if found is None: self.fail("Parse error (URL)") + parsed_url = found.group(1) + self.logDebug("Free URL: %s" % parsed_url) + # decrypt captcha found = re.search(self.CAPTCHA_PATTERN, self.html) - if found is None: - self.fail("Parse error (Captcha)") + if found is None: self.fail("Parse error (Captcha)") captcha_url = found.group(1) - # get and decrypt captcha captcha = self.decryptCaptcha(captcha_url) self.logDebug('CAPTCHA_URL:' + captcha_url + ' CAPTCHA:' + captcha) - # download the file, destination is determined by pyLoad - self.download(download_url, post={ - "captcha": captcha - }) + self.download(parsed_url, post = {"captcha" : captcha, "submit" : "Download"}) # check download check = self.checkDownload({ @@ -130,32 +130,31 @@ class HellshareCz(Hoster): self.retry() def handlePremium(self): - found = re.search(self.FILE_CREDITS_PATTERN, self.html) - if found is None: - self.fail("Parse error (Credits)") - file_credits = int(found.group(1)) - - found = re.search(self.CREDIT_LEFT_PATTERN, self.html) - if found is None: - self.fail("Parse error (Credits left)") - credits_left = int(found.group(1)) + # get premium download url + found = re.search(self.PREMIUM_URL_PATTERN, self.html) + if found is None: self.fail("Parse error (URL)") + download_url = found.group(1) - self.logInfo("Premium download for %i credits" % file_credits) - self.logInfo("User %s has %i credits left" % (self.user, credits_left)) + # check credit + if self.DOWNLOAD_AGAIN_PATTERN in self.html: + self.logInfo("Downloading again for free") + else: + found = re.search(self.CREDIT_LEFT_PATTERN, self.html) + if not found: + self.fail("Not enough credit left. Trying to download as free user.") + self.resetAccount() + credits_left = int(found.group(1)) - if file_credits > credits_left and not re.search(self.DOWNLOAD_AGAIN_PATTERN, self.html): - self.resetAccount() + found = re.search(self.FILE_CREDITS_PATTERN, self.html) + if found: + self.file_credits = found.group(1) + else: + self.logError("Parse error: file credits") + self.file_credits = "???" - found = re.search(self.PREMIUM_URL_PATTERN, self.html) - if found is None: - self.fail("Parse error (URL)") - download_url = found.group(1) + self.logInfo("Downloading file for %s credits, %d credits left" % (self.file_credits, credits_left)) self.download(download_url) info = self.account.getAccountInfo(self.user, True) - self.logInfo("User %s has %i credits left" % (self.user, info["trafficleft"] / 1024)) - - - - + self.logInfo("User %s has %i credits left" % (self.user, info["trafficleft"] / 1024))
\ No newline at end of file |