From d39d51044b8b36a0dae2bda3214f5be554654b9a Mon Sep 17 00:00:00 2001 From: spoob Date: Thu, 17 Dec 2009 19:12:25 +0100 Subject: Fixed Megaupload, need better captcha detection --- module/plugins/MegauploadCom.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'module/plugins/MegauploadCom.py') diff --git a/module/plugins/MegauploadCom.py b/module/plugins/MegauploadCom.py index 3736503c0..db1859db7 100644 --- a/module/plugins/MegauploadCom.py +++ b/module/plugins/MegauploadCom.py @@ -4,6 +4,7 @@ import os import re import tempfile +from time import time from module.Plugin import Plugin @@ -21,6 +22,8 @@ class MegauploadCom(Plugin): props['author_mail'] = ("spoob@pyload.org") self.props = props self.parent = parent + self.time_plus_wait = None #time() + wait in seconds + self.html = [None, None] self.want_reconnect = False self.init_ocr() @@ -31,18 +34,24 @@ class MegauploadCom(Plugin): captcha_image = tempfile.NamedTemporaryFile(suffix=".gif").name - for i in range(5): + got_captcha = False + + for i in range(10): self.html[0] = self.req.load(url, cookies=True) url_captcha_html = re.search('(http://www.{,3}\.megaupload\.com/gencap.php\?.*\.gif)', self.html[0]).group(1) self.req.download(url_captcha_html, captcha_image, cookies=True) captcha = self.ocr.get_captcha(captcha_image) + os.remove(captcha_image) captchacode = re.search('name="captchacode" value="(.*)"', self.html[0]).group(1) megavar = re.search('name="megavar" value="(.*)">', self.html[0]).group(1) self.html[1] = self.req.load(url, post={"captcha": captcha, "captchacode": captchacode, "megavar": megavar}, cookies=True) if re.search(r"Waiting time before each download begins", self.html[1]) != None: + got_captcha = True break + self.time_plus_wait = time() + 45 + if not got_captcha: + raise "Fuckin captcha to hard" - os.remove(captcha_image) def get_file_url(self): """ returns the absolute downloadable filepath @@ -52,7 +61,7 @@ class MegauploadCom(Plugin): if not self.want_reconnect: file_url_pattern = 'id="downloadlink">