From 8e87787753b2e049917a5491727d285b1c5a7095 Mon Sep 17 00:00:00 2001 From: mkaay Date: Sun, 27 Dec 2009 00:20:21 +0100 Subject: closes #13 --- module/plugins/hoster/NetloadIn.py | 157 +++++++++++++++++++++++++++++++++++++ 1 file changed, 157 insertions(+) create mode 100644 module/plugins/hoster/NetloadIn.py (limited to 'module/plugins/hoster/NetloadIn.py') diff --git a/module/plugins/hoster/NetloadIn.py b/module/plugins/hoster/NetloadIn.py new file mode 100644 index 000000000..bc755fb58 --- /dev/null +++ b/module/plugins/hoster/NetloadIn.py @@ -0,0 +1,157 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import os +import re +import tempfile +from time import time +from time import sleep +import hashlib + +from module.Plugin import Plugin + +class NetloadIn(Plugin): + + def __init__(self, parent): + Plugin.__init__(self, parent) + props = {} + props['name'] = "NetloadIn" + props['type'] = "hoster" + props['pattern'] = r"http://.*netload\.in/" + props['version'] = "0.1" + props['description'] = """Netload.in Download Plugin""" + props['author_name'] = ("spoob", "RaNaN") + props['author_mail'] = ("spoob@pyload.org") + self.props = props + self.parent = parent + 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.download_api_data() + if self.file_exists(): + pyfile.status.filename = self.get_file_name() + + if self.config['premium']: + self.req.load("http://netload.in/index.php", None, { "txtuser" : self.config['username'], "txtpass" : self.config['password'], "txtcheck" : "login", "txtlogin" : ""}) + self.logger.info("Netload: Use Premium Account") + pyfile.status.url = self.parent.url + #@TODO: premium?? + return True + + 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() + + 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|/)") + 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)}) + self.api_data = {} + 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): + 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('', 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 get_file_url(self): + """ returns the absolute downloadable filepath + """ + try: + file_url_pattern = r"Click here" + return re.search(file_url_pattern, self.html[2]).group(1) + except: + return None + + def get_wait_time(self): + if re.search(r"We had a reqeust with the IP", self.html[2]): + 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): + if self.api_data["filename"]: + return self.api_data["filename"] + elif self.html[0]: + file_name_pattern = '\t\t\t(.+)' + 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): + 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() + 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) -- cgit v1.2.3 From 090c9d2abdac07025fe6d7351e376e85aabc0891 Mon Sep 17 00:00:00 2001 From: mkaay Date: Sun, 27 Dec 2009 22:16:51 +0100 Subject: fixed uploaded.to and netload.in, gui clipboard check --- module/plugins/hoster/NetloadIn.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hoster/NetloadIn.py') diff --git a/module/plugins/hoster/NetloadIn.py b/module/plugins/hoster/NetloadIn.py index bc755fb58..dc639df45 100644 --- a/module/plugins/hoster/NetloadIn.py +++ b/module/plugins/hoster/NetloadIn.py @@ -64,7 +64,7 @@ class NetloadIn(Plugin): def download_api_data(self): url = self.parent.url - id_regex = re.compile("http://netload.in/datei(.*?)(?:\.htm|/)") + id_regex = re.compile("http://.*netload.in/datei(.*?)(?:\.htm|/)") match = id_regex.search(url) if match: apiurl = "http://netload.in/share/fileinfos2.php" -- cgit v1.2.3 From ea1cbdf0a88216d128ed63ec62b1ff0f22123556 Mon Sep 17 00:00:00 2001 From: spoob Date: Sun, 27 Dec 2009 23:29:51 +0100 Subject: Fixed Reconnect in Netload and Rapidshare --- module/plugins/hoster/NetloadIn.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'module/plugins/hoster/NetloadIn.py') diff --git a/module/plugins/hoster/NetloadIn.py b/module/plugins/hoster/NetloadIn.py index dc639df45..6941ad033 100644 --- a/module/plugins/hoster/NetloadIn.py +++ b/module/plugins/hoster/NetloadIn.py @@ -38,6 +38,8 @@ class NetloadIn(Plugin): def prepare(self, thread): pyfile = self.parent self.req.clear_cookies() + self.want_reconnect = False + self.download_api_data() if self.file_exists(): @@ -116,6 +118,7 @@ class NetloadIn(Plugin): def get_wait_time(self): 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 -- cgit v1.2.3 From d2ea03a068c9cbc43750d672aab7f2574ccfd9b4 Mon Sep 17 00:00:00 2001 From: mkaay Date: Fri, 1 Jan 2010 20:54:44 +0100 Subject: fixed netload.in premium --- module/plugins/hoster/NetloadIn.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'module/plugins/hoster/NetloadIn.py') diff --git a/module/plugins/hoster/NetloadIn.py b/module/plugins/hoster/NetloadIn.py index 6941ad033..1f7e7d011 100644 --- a/module/plugins/hoster/NetloadIn.py +++ b/module/plugins/hoster/NetloadIn.py @@ -46,7 +46,7 @@ class NetloadIn(Plugin): pyfile.status.filename = self.get_file_name() if self.config['premium']: - self.req.load("http://netload.in/index.php", None, { "txtuser" : self.config['username'], "txtpass" : self.config['password'], "txtcheck" : "login", "txtlogin" : ""}) + self.req.load("http://netload.in/index.php", None, { "txtuser" : self.config['username'], "txtpass" : self.config['password'], "txtcheck" : "login", "txtlogin" : ""}, cookies=True) self.logger.info("Netload: Use Premium Account") pyfile.status.url = self.parent.url #@TODO: premium?? @@ -72,14 +72,15 @@ 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 = {} - if src != "unknown file_data": + if not src == "unknown file_data": + print "apidata:", src 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", "") + self.api_data["checksum"] = lines[4].strip() else: self.api_data["exists"] = False -- cgit v1.2.3 From e9dc8ea08452c1555e28f4ac1970b96315ec4376 Mon Sep 17 00:00:00 2001 From: spoob Date: Sun, 3 Jan 2010 21:12:02 +0100 Subject: Cleaned Reconnect XML Config --- module/plugins/hoster/NetloadIn.py | 3 --- 1 file changed, 3 deletions(-) (limited to 'module/plugins/hoster/NetloadIn.py') diff --git a/module/plugins/hoster/NetloadIn.py b/module/plugins/hoster/NetloadIn.py index 1f7e7d011..0e5245e9e 100644 --- a/module/plugins/hoster/NetloadIn.py +++ b/module/plugins/hoster/NetloadIn.py @@ -40,7 +40,6 @@ class NetloadIn(Plugin): self.req.clear_cookies() self.want_reconnect = False - self.download_api_data() if self.file_exists(): pyfile.status.filename = self.get_file_name() @@ -49,7 +48,6 @@ class NetloadIn(Plugin): self.req.load("http://netload.in/index.php", None, { "txtuser" : self.config['username'], "txtpass" : self.config['password'], "txtcheck" : "login", "txtlogin" : ""}, cookies=True) self.logger.info("Netload: Use Premium Account") pyfile.status.url = self.parent.url - #@TODO: premium?? return True self.download_html() @@ -73,7 +71,6 @@ class NetloadIn(Plugin): src = self.req.load(apiurl, cookies=False, get={"file_id": match.group(1)}) self.api_data = {} if not src == "unknown file_data": - print "apidata:", src lines = src.split(";") self.api_data["exists"] = True self.api_data["fileid"] = lines[0] -- cgit v1.2.3 From f34d216d292c5608a2011db0c406ef9c3fc01181 Mon Sep 17 00:00:00 2001 From: spoob Date: Thu, 21 Jan 2010 21:16:01 +0100 Subject: Fixed Netload Wait --- module/plugins/hoster/NetloadIn.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'module/plugins/hoster/NetloadIn.py') diff --git a/module/plugins/hoster/NetloadIn.py b/module/plugins/hoster/NetloadIn.py index 0e5245e9e..a4c274c04 100644 --- a/module/plugins/hoster/NetloadIn.py +++ b/module/plugins/hoster/NetloadIn.py @@ -50,8 +50,8 @@ class NetloadIn(Plugin): pyfile.status.url = self.parent.url return True - self.download_html() 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 @@ -106,8 +106,6 @@ class NetloadIn(Plugin): break def get_file_url(self): - """ returns the absolute downloadable filepath - """ try: file_url_pattern = r"Click here" return re.search(file_url_pattern, self.html[2]).group(1) @@ -116,8 +114,10 @@ class NetloadIn(Plugin): def get_wait_time(self): if re.search(r"We had a reqeust 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() + 10 * 30 + print wait_minutes + self.time_plus_wait = time() + wait_minutes * 60 return wait_seconds = int(re.search(r"countdown\((.+),'change\(\)'\)", self.html[2]).group(1)) / 100 -- cgit v1.2.3 From ae550575a710201df8e7f928d8ba743b4cc4e532 Mon Sep 17 00:00:00 2001 From: spoob Date: Sat, 23 Jan 2010 13:58:40 +0100 Subject: Removed Prints --- module/plugins/hoster/NetloadIn.py | 1 - 1 file changed, 1 deletion(-) (limited to 'module/plugins/hoster/NetloadIn.py') diff --git a/module/plugins/hoster/NetloadIn.py b/module/plugins/hoster/NetloadIn.py index a4c274c04..46afc4080 100644 --- a/module/plugins/hoster/NetloadIn.py +++ b/module/plugins/hoster/NetloadIn.py @@ -116,7 +116,6 @@ class NetloadIn(Plugin): if re.search(r"We had a reqeust with the IP", self.html[2]): wait_minutes = int(re.search(r"countdown\((.+),'change\(\)'\)", self.html[2]).group(1)) / 6000 self.want_reconnect = True - print wait_minutes self.time_plus_wait = time() + wait_minutes * 60 return -- cgit v1.2.3