diff options
author | spoob <spoob@gmx.de> | 2009-12-19 19:07:17 +0100 |
---|---|---|
committer | spoob <spoob@gmx.de> | 2009-12-19 19:07:17 +0100 |
commit | f7f83692039997e1988cc6fae53676856668444b (patch) | |
tree | 543dd9f63e690fc249d78b6d855c5cb14c64b358 | |
parent | active download list 40% (diff) | |
download | pyload-f7f83692039997e1988cc6fae53676856668444b.tar.xz |
Fixed Netload, no Premium
-rw-r--r-- | module/config/core.xml | 2 | ||||
-rw-r--r-- | module/plugins/NetloadIn.py | 136 | ||||
-rw-r--r-- | module/plugins/RapidshareCom.py | 14 | ||||
-rw-r--r-- | module/thread_list.py | 1 |
4 files changed, 81 insertions, 72 deletions
diff --git a/module/config/core.xml b/module/config/core.xml index 6da85cf32..392309e1c 100644 --- a/module/config/core.xml +++ b/module/config/core.xml @@ -11,7 +11,7 @@ <key>ssl.key</key> </ssl> <webinterface> - <activated>True</activated> + <activated>False</activated> <host>0.0.0.0</host> <port>8000</port> <template>default</template> diff --git a/module/plugins/NetloadIn.py b/module/plugins/NetloadIn.py index b9fb4cfed..e90124f10 100644 --- a/module/plugins/NetloadIn.py +++ b/module/plugins/NetloadIn.py @@ -37,46 +37,30 @@ class NetloadIn(Plugin): def prepare(self, thread): pyfile = self.parent + self.req.clear_cookies() - self.want_reconnect = False - - tries = 0 - - while not pyfile.status.url: - - 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." - - self.download_api_data() - + 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 + #@TODO: premium?? return True - - 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() - - tries += 1 - if tries > 3: - raise Exception, "Error while preparing DL, HTML dump: %s %s" % (self.html[0], self.html[1]) + self.download_html() + while not pyfile.status.url: + 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 - + else: + raise Exception, "The file was not found on the server." + def download_api_data(self): url = self.parent.url id_regex = re.compile("http://netload.in/datei(.*?)(?:\.htm|/)") @@ -85,20 +69,43 @@ class NetloadIn(Plugin): apiurl = "http://netload.in/share/fileinfos2.php" src = self.req.load(apiurl, cookies=False, get={"file_id": match.group(1)}) self.api_data = {} - lines = src.split(";") - self.api_data["fileid"] = lines[0] - self.api_data["filename"] = lines[1] - self.api_data["size"] = lines[2] #@TODO formatting? (ex: '2.07 KB') - self.api_data["status"] = lines[3] - self.api_data["checksum"] = lines[4] - + if src != "unknown file_data": + lines = src.split(";") + self.api_data["exists"] = True + self.api_data["fileid"] = lines[0] + self.api_data["filename"] = lines[1] + self.api_data["size"] = lines[2] #@TODO formatting? (ex: '2.07 KB') + self.api_data["status"] = lines[3] + self.api_data["checksum"] = lines[4].replace("\n", "") + else: + self.api_data["exists"] = False def download_html(self): - if self.config['premium']: - self.config['username'], self.config['password'] - self.req.load("http://netload.in/index.php", None, { "txtuser" : self.config['username'], "txtpass" : self.config['password'], "txtcheck" : "login", "txtlogin" : ""}) - url = self.parent.url - self.html[0] = self.req.load(url, cookies=True) + #~ if self.config['premium']: + #~ self.config['username'], self.config['password'] + #~ self.req.load("http://netload.in/index.php", None, { "txtuser" : self.config['username'], "txtpass" : self.config['password'], "txtcheck" : "login", "txtlogin" : ""}) + self.html[0] = self.req.load(self.parent.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) + + 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) + + if re.search(r"(We will prepare your download..|We had a reqeust with the IP)", self.html[2]) != None: + break def download_html2(self): @@ -141,42 +148,43 @@ class NetloadIn(Plugin): return None 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 + self.time_plus_wait = time() + 10 * 30 + return + + wait_seconds = int(re.search(r"countdown\((.+),'change\(\)'\)", self.html[2]).group(1)) / 100 + self.time_plus_wait = time() + wait_seconds def get_file_name(self): - try: - if self.api_data and self.api_data["filename"]: - return self.api_data["filename"] + if self.api_data["filename"]: + return self.api_data["filename"] + elif self.html[0]: file_name_pattern = '\t\t\t(.+)<span style="color: #8d8d8d;">' - return re.search(file_name_pattern, self.html[0]).group(1) - except: - return self.parent.url + 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 def file_exists(self): - """ returns True or False - """ - if re.search(r"The file has been deleted", self.html[0]) != None: - return False - else: + if self.api_data["exists"]: + return self.api_data["exists"] + elif self.html[0] and re.search(r"The file has been deleted", self.html[0]) == None: return True + return False def proceed(self, url, location): - self.req.download(url, location, cookies=True) def check_file(self, local_file): if self.api_data and self.api_data["checksum"]: h = hashlib.md5() - with open(local_file, "rb") as f: - h.update(f.read()) + f = open(local_file, "rb") + h.update(f.read()) + f.close() hexd = h.hexdigest() if hexd == self.api_data["checksum"]: return (True, 0) else: return (False, 1) else: - return (True, 5) + return (True, 5) diff --git a/module/plugins/RapidshareCom.py b/module/plugins/RapidshareCom.py index 615dda521..96d526d73 100644 --- a/module/plugins/RapidshareCom.py +++ b/module/plugins/RapidshareCom.py @@ -38,10 +38,12 @@ class RapidshareCom(Plugin): def prepare(self, thread): pyfile = self.parent - + self.req.clear_cookies() + self.download_api_data() if self.api_data["status"] == "1": pyfile.status.filename = self.get_file_name() + if self.config["premium"]: self.logger.info("Rapidshare: Use Premium Account (%sGB left)" % (self.props["premkbleft"]/1000000)) pyfile.status.url = self.parent.url @@ -49,7 +51,7 @@ class RapidshareCom(Plugin): self.download_html() while self.no_slots: - self.download_serverhtml() + self.get_wait_time() pyfile.status.waituntil = self.time_plus_wait pyfile.status.want_reconnect = self.want_reconnect thread.wait(pyfile) @@ -122,7 +124,7 @@ class RapidshareCom(Plugin): self.html[0] = self.req.load(self.url, cookies=True) self.html_old = time() - def download_serverhtml(self): + def get_wait_time(self): """downloads html with the important informations """ file_server_url = re.search(r"<form action=\"(.*?)\"", self.html[0]).group(1) @@ -130,10 +132,10 @@ class RapidshareCom(Plugin): self.html_old = time() - if re.search(r"is already downloading", self.html[1]) != None: + if re.search(r"is already downloading", self.html[1]): self.logger.info("Rapidshare: Already downloading, wait 30 minutes") self.time_plus_wait = time() + 10 * 30 - return False + return self.no_slots = False try: wait_minutes = re.search(r"Or try again in about (\d+) minute", self.html[1]).group(1) @@ -160,7 +162,7 @@ class RapidshareCom(Plugin): return re.search(file_url_pattern, self.html[1]).group(1) def get_file_name(self): - if self.api_data and self.api_data["filename"]: + if self.api_data["filename"]: return self.api_data["filename"] elif self.html[0]: file_name_pattern = r"<p class=\"downloadlink\">.+/(.+) <font" diff --git a/module/thread_list.py b/module/thread_list.py index 6a42898be..d78a9b95c 100644 --- a/module/thread_list.py +++ b/module/thread_list.py @@ -110,7 +110,6 @@ class Thread_List(object): newLinks = 0 if pyfile.plugin.links: for link in pyfile.plugin.links: - print link newFile = self.list.collector.addLink(link) self.list.packager.addFileToPackage(pyfile.package.data["id"], self.list.collector.popFile(newFile)) newLinks += 1 |