diff options
author | zoidberg10 <zoidberg@mujmail.cz> | 2012-01-30 18:17:43 +0100 |
---|---|---|
committer | zoidberg10 <zoidberg@mujmail.cz> | 2012-01-30 18:17:43 +0100 |
commit | 2f31e623d7d3aab497533c4fd1cc8d0260419c57 (patch) | |
tree | 803f87aef00bd49e61edeb654f36dbedc297788d /module/plugins/hoster | |
parent | increase version (diff) | |
download | pyload-2f31e623d7d3aab497533c4fd1cc8d0260419c57.tar.xz |
Diffstat (limited to 'module/plugins/hoster')
-rw-r--r-- | module/plugins/hoster/FshareVn.py | 44 |
1 files changed, 33 insertions, 11 deletions
diff --git a/module/plugins/hoster/FshareVn.py b/module/plugins/hoster/FshareVn.py index 5a8b00c17..977e97211 100644 --- a/module/plugins/hoster/FshareVn.py +++ b/module/plugins/hoster/FshareVn.py @@ -16,23 +16,27 @@ def getInfo(urls): yield file_info +def doubleDecode(m): + return m.group(1).decode('raw_unicode_escape') + class FshareVn(SimpleHoster): __name__ = "FshareVn" __type__ = "hoster" __pattern__ = r"http://(www\.)?fshare.vn/file/.*" - __version__ = "0.12" + __version__ = "0.13" __description__ = """FshareVn Download Hoster""" __author_name__ = ("zoidberg") __author_mail__ = ("zoidberg@mujmail.cz") - FILE_INFO_PATTERN = r'<p>(?P<N>[^<]+)<\\/p>\\r\\n\s*<p>(?P<S>[0-9,.]+)\s*(?P<U>[kKMG])i?B<\\/p>' + FILE_INFO_PATTERN = r'<p>(?P<N>[^<]+)<\\/p>[\\trn\s]*<p>(?P<S>[0-9,.]+)\s*(?P<U>[kKMG])i?B<\\/p>' FILE_OFFLINE_PATTERN = r'<div class=\\"f_left file_(enable|w)\\">' + FILE_NAME_REPLACEMENTS = [("(.*)", doubleDecode)] DOWNLOAD_URL_PATTERN = r"<a class=\"bt_down\" id=\"down\".*window.location='([^']+)'\">" FORM_PATTERN = r'<form action="" method="post" name="frm_download">(.*?)</form>' FORM_INPUT_PATTERN = r'<input[^>]* name="?([^" ]+)"? value="?([^" ]+)"?[^>]*>' VIP_URL_PATTERN = r'<form action="([^>]+)" method="get" name="frm_download">' - WAIT_PATTERN = u"Vui lòng chờ cho lượt download kế tiếp !" + WAIT_PATTERN = u"Vui lòng chờ lượt download kế tiếp" def process(self, pyfile): self.html = self.load('http://www.fshare.vn/check_link.php', post = { @@ -40,15 +44,17 @@ class FshareVn(SimpleHoster): "arrlinks": pyfile.url }, decode = True) self.getFileInfo() - if self.account and self.premium: - self.handlePremium() - else: - self.handleFree() + + url = self.handlePremium() if self.premium else self.handleFree() + self.download(url) + self.checkDownloadedFile() def handleFree(self): self.html = self.load(self.pyfile.url, decode = True) if self.WAIT_PATTERN in self.html: - self.retry(300, 20, "Try again later...") + self.retry(20, 300, "Try again later...") + + self.checkErrors() found = re.search(self.FORM_PATTERN, self.html, re.DOTALL) if not found: self.parseError('FORM') @@ -68,15 +74,18 @@ class FshareVn(SimpleHoster): self.setWait(int(found.group(1)) if found else 30) self.wait() - self.download(url) + return url def handlePremium(self): header = self.load(self.pyfile.url, just_header = True) if 'location' in header and header['location'].startswith('http://download'): self.logDebug('Direct download') - self.download(self.pyfile.url) + return self.pyfile.url else: self.html = self.load(self.pyfile.url) + + self.checkErrors() + found = re.search(self.VIP_URL_PATTERN, self.html) if not found: if self.retries >= 3: self.resetAccount() @@ -84,4 +93,17 @@ class FshareVn(SimpleHoster): self.retry(5, 1, 'VIP URL not found') url = found.group(1) self.logDebug('VIP URL: ' + url) - self.download(url)
\ No newline at end of file + return url + + def checkErrors(self): + if '/error.php?' in self.req.lastEffectiveURL: + self.offline() + + def checkDownloadedFile(self): + # check download + check = self.checkDownload({ + "not_found": ("<head><title>404 Not Found</title></head>") + }) + + if check == "not_found": + self.fail("File not found on server")
\ No newline at end of file |