diff options
Diffstat (limited to 'module/plugins/ShareonlineBiz.py')
-rw-r--r-- | module/plugins/ShareonlineBiz.py | 72 |
1 files changed, 50 insertions, 22 deletions
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) |