diff options
| -rw-r--r-- | Plugins/NetloadIn.py | 58 | ||||
| -rw-r--r-- | captcha/captcha.py | 2 | ||||
| -rwxr-xr-x | module/network/Request.py | 3 | 
3 files changed, 51 insertions, 12 deletions
| diff --git a/Plugins/NetloadIn.py b/Plugins/NetloadIn.py index ade424868..f3ef99586 100644 --- a/Plugins/NetloadIn.py +++ b/Plugins/NetloadIn.py @@ -5,6 +5,7 @@ import os  import re  import tempfile  from time import time +from time import sleep  from Plugin import Plugin @@ -15,10 +16,10 @@ class NetloadIn(Plugin):          props = {}          props['name'] = "NetloadIn"          props['type'] = "hoster" -        props['pattern'] = r"(?:http://)?(?:www.)?http://netload.in/" +        props['pattern'] = r"http://.+netload.in/"          props['version'] = "0.1"          props['description'] = """Netload.in Download Plugin""" -        props['author_name'] = ("spoob") +        props['author_name'] = ("spoob", "RaNaN")          props['author_mail'] = ("spoob@pyload.org")          self.props = props          self.parent = parent @@ -27,23 +28,53 @@ class NetloadIn(Plugin):          self.init_ocr()          self.multi_dl = False +    def prepare(self, thread): +        pyfile = self.parent + +        self.want_reconnect = False + +        self.req.clear_cookies() +        self.download_html() + +        pyfile.status.exists = self.file_exists() + +        if not pyfile.status.exists: +            raise Exception, "The file was not found on the server." + +        pyfile.status.filename = self.get_file_name() + +        self.download_html2() + +        self.get_wait_time() + +        pyfile.status.waituntil = self.time_plus_wait +        pyfile.status.want_reconnect = self.want_reconnect + +        thread.wait(self.parent) + +        pyfile.status.url = self.get_file_url() + +        return True + +      def download_html(self):          url = self.parent.url          self.html[0] = self.req.load(url, cookies=True) -        url_captcha_html = "http://netload.in/" + re.search('(index.php\?id=10&.*&captcha=1)', self.html[0]).group(1).replace("amp;", "") +    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)          captcha_url = "http://netload.in/" + re.search('(share/includes/captcha.php\?t=\d*)', self.html[1]).group(1)          file_id = re.search('<input name="file_id" type="hidden" value="(.*)" />', self.html[1]).group(1)          captcha_image = tempfile.NamedTemporaryFile(suffix=".png").name -        for i in range(5): +        for i in range(10):              self.req.download(captcha_url, captcha_image, cookies=True)              captcha = self.ocr.get_captcha(captcha_image) +            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) -            if re.search(r"download:", self.html[2]) != None: -                self.time_plus_wait = time() + 20 +            if re.search(r"(We will prepare your download..|We had a reqeust with the IP)", self.html[2]) != None:                  break          os.remove(captcha_image) @@ -54,14 +85,21 @@ class NetloadIn(Plugin):          if self.html[0] == None:              self.download_html()          if not self.want_reconnect: -            file_url_pattern = '<a class="Orange_Link" href="(http://.+)" >Click here' +            file_url_pattern = r"<a class=\"Orange_Link\" href=\"(http://.+)\" >Click here"              search = re.search(file_url_pattern, self.html[2]) -            if search: -                return search.group(1) -            return "" +            return search.group(1)          else:              return False +    def get_wait_time(self): +        wait = int(re.search(r"countdown\((.+),'change\(\)'\)", self.html[2]).group(1)) +        self.time_plus_wait = time() + wait / 100 + +        if re.search(r"We had a reqeust with the IP", self.html[2]): +            self.want_reconnect = True + + +              def get_file_name(self):          if self.html[0] == None:              self.download_html() diff --git a/captcha/captcha.py b/captcha/captcha.py index 22c097f38..8f0b828d8 100644 --- a/captcha/captcha.py +++ b/captcha/captcha.py @@ -236,11 +236,9 @@ class OCR(object):          for key, item in values.iteritems():              if key.__class__ == str: -                print key, "->", item                  result = result.replace(key, item)              else:                  for expr in key: -                    print expr, "->", item                      result = result.replace(expr, item)          if var: diff --git a/module/network/Request.py b/module/network/Request.py index ff50c34bc..30ffbcd3e 100755 --- a/module/network/Request.py +++ b/module/network/Request.py @@ -109,6 +109,9 @@ class Request:      #def download(url, filename, reporthook = None, data = None): #default von urlretrieve auch None?          #  return self.downloader.urlretrieve(url, filename, reporthook, data) +    def clear_cookies(self): +        del self.cookies[:] +      def add_proxy(self, protocol, adress):          handler = urllib2.ProxyHandler({protocol: adress})          self.opener.add_handler(handler) | 
