From 24fd08a6773a4cddfb3dc7d81e85d9bec7d18205 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Thu, 3 Sep 2009 00:13:48 +0200 Subject: netload fix --- Plugins/NetloadIn.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'Plugins') diff --git a/Plugins/NetloadIn.py b/Plugins/NetloadIn.py index 733347272..11765f42a 100644 --- a/Plugins/NetloadIn.py +++ b/Plugins/NetloadIn.py @@ -72,31 +72,36 @@ class NetloadIn(Plugin): def download_html2(self): url_captcha_html = "http://netload.in/" + re.search('(index.php\?id=10&.*&captcha=1)', self.html[0]).group(1).replace("amp;", "") - self.html[1] = self.req.load(url_captcha_html, cookies=True) - try: - captcha_url = "http://netload.in/" + re.search('(share/includes/captcha.php\?t=\d*)', self.html[1]).group(1) - except: - url_captcha_html = "http://netload.in/" + re.search('(index.php\?id=10&.*&captcha=1)', self.html[1]).group(1).replace("amp;", "") + for i in range(6): + self.html[1] = self.req.load(url_captcha_html, cookies=True) - captcha_url = "http://netload.in/" + re.search('(share/includes/captcha.php\?t=\d*)', self.html[1]).group(1) + + try: + captcha_url = "http://netload.in/" + re.search('(share/includes/captcha.php\?t=\d*)', self.html[1]).group(1) + except: + url_captcha_html = "http://netload.in/" + re.search('(index.php\?id=10&.*&captcha=1)', self.html[1]).group(1).replace("amp;", "") + self.html[1] = self.req.load(url_captcha_html, cookies=True) + captcha_url = "http://netload.in/" + re.search('(share/includes/captcha.php\?t=\d*)', self.html[1]).group(1) - file_id = re.search('', self.html[1]).group(1) + file_id = re.search('', self.html[1]).group(1) - captcha_image = tempfile.NamedTemporaryFile(suffix=".png").name + captcha_image = tempfile.NamedTemporaryFile(suffix=".png").name - for i in range(10): + self.req.download(captcha_url, captcha_image, cookies=True) captcha = self.ocr.get_captcha(captcha_image) self.logger.debug("Captcha %s: %s" % (i, captcha)) sleep(5) self.html[2] = self.req.load("http://netload.in/index.php?id=10", post={"file_id": file_id, "captcha_check": captcha}, cookies=True) + + os.remove(captcha_image) + if re.search(r"(We will prepare your download..|We had a reqeust with the IP)", self.html[2]) != None: return True raise Exception, "Captcha reading failed" - os.remove(captcha_image) def get_file_url(self): """ returns the absolute downloadable filepath -- cgit v1.2.3