From 82aceb93be33157a637905cc807b9b7f7fe15d31 Mon Sep 17 00:00:00 2001 From: zoidberg10 Date: Thu, 8 Dec 2011 02:04:48 +0100 Subject: httprequest: encode('utf_8') for unicode post --- module/plugins/hoster/EnteruploadCom.py | 3 ++- module/plugins/hoster/FshareVn.py | 42 ++++++++++++++++++++------------- 2 files changed, 28 insertions(+), 17 deletions(-) (limited to 'module/plugins/hoster') diff --git a/module/plugins/hoster/EnteruploadCom.py b/module/plugins/hoster/EnteruploadCom.py index 5e899ae96..37e24a93f 100644 --- a/module/plugins/hoster/EnteruploadCom.py +++ b/module/plugins/hoster/EnteruploadCom.py @@ -29,7 +29,8 @@ class EnteruploadCom(SimpleHoster): __author_mail__ = ("zoidberg@mujmail.cz") FILE_INFO_PATTERN = r'

(?P[^<]+)

\s*File size:\s*(?P[0-9.]+)\s*(?P[kKMG])i?B' - FILE_OFFLINE_PATTERN = r'<(b|h2)>File Not Found|No such file with this filename' + FILE_OFFLINE_PATTERN = r'<(b|h2)>File Not Found|No such file with this filename' + TEMP_OFFLINE_PATTERN = r'>This server is in maintenance mode\. Refresh this page in some minutes\.<' URL_REPLACEMENTS = [(r"(http://(?:www\.)?enterupload.com/\w+).*", r"\1")] FORM1_PATTERN = r'
(.*?)
' diff --git a/module/plugins/hoster/FshareVn.py b/module/plugins/hoster/FshareVn.py index 91cc167b1..5a8b00c17 100644 --- a/module/plugins/hoster/FshareVn.py +++ b/module/plugins/hoster/FshareVn.py @@ -11,67 +11,77 @@ def getInfo(urls): "action" : "check_link", "arrlinks" : url }, decode = True) - + file_info = parseFileInfo(FshareVn, url, html) - + yield file_info class FshareVn(SimpleHoster): __name__ = "FshareVn" __type__ = "hoster" __pattern__ = r"http://(www\.)?fshare.vn/file/.*" - __version__ = "0.11" + __version__ = "0.12" __description__ = """FshareVn Download Hoster""" __author_name__ = ("zoidberg") __author_mail__ = ("zoidberg@mujmail.cz") FILE_INFO_PATTERN = r'

(?P[^<]+)<\\/p>\\r\\n\s*

(?P[0-9,.]+)\s*(?P[kKMG])i?B<\\/p>' FILE_OFFLINE_PATTERN = r'

' - + DOWNLOAD_URL_PATTERN = r"" FORM_PATTERN = r'
(.*?)
' FORM_INPUT_PATTERN = r']* name="?([^" ]+)"? value="?([^" ]+)"?[^>]*>' - VIP_URL_PATTERN = r'
' + VIP_URL_PATTERN = r'' + WAIT_PATTERN = u"Vui lòng chờ cho lượt download kế tiếp !" def process(self, pyfile): self.html = self.load('http://www.fshare.vn/check_link.php', post = { "action": "check_link", "arrlinks": pyfile.url }, decode = True) - self.getFileInfo() - if self.account: + self.getFileInfo() + if self.account and self.premium: self.handlePremium() else: self.handleFree() 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...") + found = re.search(self.FORM_PATTERN, self.html, re.DOTALL) if not found: self.parseError('FORM') form = found.group(1) inputs = dict(re.findall(self.FORM_INPUT_PATTERN, form)) - - self.html = self.load(self.pyfile.url, post = inputs) - + + self.html = self.load(self.pyfile.url, post = inputs, decode = True) + + if self.WAIT_PATTERN in self.html: + self.retry(300, 20, "Try again later...") + found = re.search(self.DOWNLOAD_URL_PATTERN, self.html) if not found: self.parseError('Free URL') url = found.group(1) - + found = re.search(r'var count = (\d+)', self.html) self.setWait(int(found.group(1)) if found else 30) self.wait() - + self.download(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) else: - self.html = self.load(self.pyfile.url) + self.html = self.load(self.pyfile.url) found = re.search(self.VIP_URL_PATTERN, self.html) - if not found: self.parseError('VIP URL') + if not found: + if self.retries >= 3: self.resetAccount() + self.account.relogin(self.user) + 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 + self.download(url) \ No newline at end of file -- cgit v1.2.3