diff options
Diffstat (limited to 'module/plugins/hoster/NetloadIn.py')
-rw-r--r-- | module/plugins/hoster/NetloadIn.py | 154 |
1 files changed, 69 insertions, 85 deletions
diff --git a/module/plugins/hoster/NetloadIn.py b/module/plugins/hoster/NetloadIn.py index c6f9da434..04b9f81f7 100644 --- a/module/plugins/hoster/NetloadIn.py +++ b/module/plugins/hoster/NetloadIn.py @@ -9,68 +9,62 @@ from time import sleep import hashlib from module.plugins.Hoster import Hoster +from module.plugins.Plugin import Plugin class NetloadIn(Hoster): __name__ = "NetloadIn" __type__ = "hoster" __pattern__ = r"http://.*netload\.in/(?:datei(.*?)(?:\.htm|/)|index.php?id=10&file_id=)" - __version__ = "0.1" + __version__ = "0.2" __description__ = """Netload.in Download Hoster""" __author_name__ = ("spoob", "RaNaN") __author_mail__ = ("spoob@pyload.org", "ranan@pyload.org") - def __init__(self, parent): - Hoster.__init__(self, parent) - self.parent = parent + def setup(self): + self.multiDL = False + + def process(self, pyfile): self.html = [None, None, None] - self.want_reconnect = False - self.multi_dl = False - self.api_data = None - self.init_ocr() - self.read_config() - if self.config['premium']: - self.multi_dl = True - else: - self.multi_dl = False - - def prepare(self, thread): - pyfile = self.parent - self.req.clear_cookies() - self.want_reconnect = False - + self.url = pyfile.url + self.prepare() + self.pyfile.setStatus("downloading") + self.proceed(self.url) + + def prepare(self): self.download_api_data() if self.file_exists(): - pyfile.status.filename = self.get_file_name() - - if self.config['premium']: - self.logger.info("Netload: Use Premium Account") - pyfile.status.url = self.parent.url - return True - - while not pyfile.status.url: - self.download_html() - 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() + self.pyfile.name = self.get_file_name() + + #if self.config['premium']: + # self.log.info("Netload: Use Premium Account") + # return True + + self.download_html() + self.setWait(self.get_wait_time()) + + #self.wait() + self.log.info("Netload: waiting %d seconds" % self.get_wait_time()) + self.pyfile.setStatus("waiting") + sleep(self.get_wait_time()) + + + self.url = self.get_file_url() return True else: - return False + self.offline() def download_api_data(self): - url = self.parent.url + url = self.url id_regex = re.compile("http://.*netload\.in/(?:datei(.*?)(?:\.htm|/)|index.php?id=10&file_id=)") match = id_regex.search(url) if match: apiurl = "http://netload.in/share/fileinfos2.php" - src = self.req.load(apiurl, cookies=False, get={"file_id": match.group(1)}) + src = self.load(apiurl, cookies=False, get={"file_id": match.group(1)}) self.api_data = {} if src == "unknown_server_data": self.api_data = False - self.html[0] = self.req.load(self.parent.url, cookies=False) + self.html[0] = self.load(self.url, cookies=False) elif not src == "unknown file_data": lines = src.split(";") self.api_data["exists"] = True @@ -81,32 +75,40 @@ class NetloadIn(Hoster): self.api_data["checksum"] = lines[4].strip() else: self.api_data["exists"] = False + else: + self.api_data = False + self.html[0] = self.load(self.url, cookies=False) def download_html(self): - self.html[0] = self.req.load(self.parent.url, cookies=True) + self.html[0] = self.load(self.url, cookies=True) url_captcha_html = "http://netload.in/" + re.search('(index.php\?id=10&.*&captcha=1)', self.html[0]).group(1).replace("amp;", "") - for i in range(6): - 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;", "") - 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) + + m = re.search(r"countdown\((\d+),'change\(\)'\);", url_captcha_html) + if m: + wait_time = int(m.group(1)) + self.log.info("Netload: waiting %d seconds." % wait_time) + sleep(wait_time) + + #for i in range(6): + self.html[1] = self.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;", "") + self.html[1] = self.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 - self.req.download(captcha_url, captcha_image, cookies=True) - captcha = self.ocr.get_captcha(captcha_image) - os.remove(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) + file_id = re.search('<input name="file_id" type="hidden" value="(.*)" />', self.html[1]).group(1) + + captcha = self.decryptCaptcha(captcha_url) + sleep(5) + + self.html[2] = self.load("http://netload.in/index.php?id=10", post={"file_id": file_id, "captcha_check": captcha}, cookies=True) - if re.search(r"(We will prepare your download..|We had a reqeust with the IP)", self.html[2]) != None: - return True + 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 not decrypted") + fail("Captcha not decrypted") def get_file_url(self): try: @@ -116,14 +118,13 @@ class NetloadIn(Hoster): return None def get_wait_time(self): - if re.search(r"We had a reqeust with the IP", self.html[2]): + if re.search(r"We had a request with the IP", self.html[2]): wait_minutes = int(re.search(r"countdown\((.+),'change\(\)'\)", self.html[2]).group(1)) / 6000 - self.want_reconnect = True - self.time_plus_wait = time() + wait_minutes * 60 - return + self.wantReconnect = True + return wait_minutes * 60 wait_seconds = int(re.search(r"countdown\((.+),'change\(\)'\)", self.html[2]).group(1)) / 100 - self.time_plus_wait = time() + wait_seconds + return wait_seconds def get_file_name(self): if self.api_data and self.api_data["filename"]: @@ -133,7 +134,7 @@ class NetloadIn(Hoster): file_name_search = re.search(file_name_pattern, self.html[0]) if file_name_search: return file_name_search.group(1) - return self.parent.url + return self.url def file_exists(self): if self.api_data and self.api_data["exists"]: @@ -142,25 +143,8 @@ class NetloadIn(Hoster): return True return False - def proceed(self, url, location): - if self.config['premium']: - self.req.load("http://netload.in/index.php", None, { "txtuser" : self.config['username'], "txtpass" : self.config['password'], "txtcheck" : "login", "txtlogin" : ""}, cookies=True) - self.req.download(url, location, cookies=True) + def proceed(self, url): + #if self.config['premium']: + # self.req.load("http://netload.in/index.php", None, { "txtuser" : self.config['username'], "txtpass" : self.config['password'], "txtcheck" : "login", "txtlogin" : ""}, cookies=True) + self.download(url, cookies=True) - def check_file(self, local_file): - if self.api_data and self.api_data["checksum"]: - h = hashlib.md5() - f = open(local_file, "rb") - while True: - data = f.read(128) - if not data: - break - h.update(data) - f.close() - hexd = h.hexdigest() - if hexd == self.api_data["checksum"]: - return (True, 0) - else: - return (False, 1) - else: - return (True, 5) |