diff options
author | spoob <spoob@gmx.de> | 2009-12-20 01:13:28 +0100 |
---|---|---|
committer | spoob <spoob@gmx.de> | 2009-12-20 01:13:28 +0100 |
commit | dc80059a0695767ead2f2d89c11ca88b2ad946e3 (patch) | |
tree | 6069338d1cc1408499d9c7e6d5fb8a74fc6c32c2 | |
parent | merged (diff) | |
parent | Checksum for Shareonline.biz (diff) | |
download | pyload-dc80059a0695767ead2f2d89c11ca88b2ad946e3.tar.xz |
merged
-rw-r--r-- | module/plugins/DLC.pyc | bin | 5663 -> 5740 bytes | |||
-rw-r--r-- | module/plugins/LinkList.py | 10 | ||||
-rw-r--r-- | module/plugins/ShareonlineBiz.py | 72 |
3 files changed, 55 insertions, 27 deletions
diff --git a/module/plugins/DLC.pyc b/module/plugins/DLC.pyc Binary files differindex 93d2bec7f..235e46e1a 100644 --- a/module/plugins/DLC.pyc +++ b/module/plugins/DLC.pyc diff --git a/module/plugins/LinkList.py b/module/plugins/LinkList.py index fc737e8c5..92508ce29 100644 --- a/module/plugins/LinkList.py +++ b/module/plugins/LinkList.py @@ -29,11 +29,11 @@ class LinkList(Plugin): if link != "\n": tmpLinks.append(link.replace("\n", "")) txt.close() -#~ - #~ if not self.parent.core.config['general']['debug_mode']: - #~ txt = open(linkList, 'w') - #~ txt.write("") - #~ txt.close() + + if not self.parent.core.config['general']['debug_mode']: + txt = open(linkList, 'w') + txt.write("") + txt.close() #@TODO: maybe delete read txt file? self.links = tmpLinks diff --git a/module/plugins/ShareonlineBiz.py b/module/plugins/ShareonlineBiz.py index a798ccefa..1b1eb6e27 100644 --- a/module/plugins/ShareonlineBiz.py +++ b/module/plugins/ShareonlineBiz.py @@ -26,14 +26,48 @@ class ShareonlineBiz(Plugin): self.html = [None, None] self.want_reconnect = False self.init_ocr() + self.url = self.parent.url + self.read_config() if self.config['premium']: self.multi_dl = True else: self.multi_dl = False + def prepare(self, thread): + pyfile = self.parent + + self.download_api_data() + if self.api_data["status"]: + self.download_html() + pyfile.status.filename = self.api_data["filename"] + pyfile.status.waituntil = self.time_plus_wait + pyfile.status.url = self.get_file_url() + pyfile.status.want_reconnect = self.want_reconnect + else: + raise Exception, "File not found" + return False + + def download_api_data(self): + """ + http://images.rapidshare.com/apidoc.txt + """ + api_url_base = "http://www.share-online.biz/linkcheck/linkcheck.php?md5=1" + api_param_file = {"links": self.url} + src = self.req.load(api_url_base, cookies=False, post=api_param_file) + + fields = src.split(";") + self.api_data = {} + self.api_data["fileid"] = fields[0] + self.api_data["status"] = fields[1] + if self.api_data["status"] == "NOTFOUND": + return + self.api_data["filename"] = fields[2] + self.api_data["size"] = fields[3] # in bytes + self.api_data["checksum"] = fields[4].strip().lower().replace("\n\n", "") # md5 + def download_html(self): if self.config['premium']: - post_vars = {"act": "login", + post_vars = {ct": "login", "location": "service.php", "dieseid": "", "user": self.config['username'], @@ -47,11 +81,12 @@ class ShareonlineBiz(Plugin): if not self.config['premium']: captcha_image = tempfile.NamedTemporaryFile(suffix=".jpg").name - for i in range(5): + for i in range(10): self.req.download("http://www.share-online.biz/captcha.php", captcha_image, cookies=True) captcha = self.ocr.get_captcha(captcha_image) + self.logger.debug("Captcha %s: %s" % (i, captcha)) self.html[1] = self.req.load(url, post={"captchacode": captcha}, cookies=True) - if re.search(r"Der Download ist Ihnen zu langsam?", self.html[1]) != None: + if re.search(r"Der Download ist Ihnen zu langsam", self.html[1]) != None: self.time_plus_wait = time() + 15 break @@ -60,29 +95,22 @@ class ShareonlineBiz(Plugin): def get_file_url(self): """ returns the absolute downloadable filepath """ - if self.html[0] == None: - self.download_html() if not self.want_reconnect: file_url_pattern = 'loadfilelink\.decode\("(.*)\); document' return b64decode(re.search(file_url_pattern, self.html[1]).group(1)) else: return False - def get_file_name(self): - if self.html[0] == None: - self.download_html() - if not self.want_reconnect: - file_name_pattern = 'class="locatedActive">Download (.*)</span>' - return re.search(file_name_pattern, self.html[1]).group(1) - else: - return self.parent.url - - def file_exists(self): - """ returns True or False - """ - if self.html[0] == None: - self.download_html() - if re.search(r"nicht zum Download bereitgestellt werden", self.html[0]) != None: - return False + 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 + return (True, 5) |