From 67db64c7c8c1813a4e22ed819846a69c6abefc2e Mon Sep 17 00:00:00 2001 From: RaNaN Date: Mon, 13 Jun 2011 20:19:23 +0200 Subject: erniebs patches --- module/plugins/hoster/EasyShareCom.py | 4 ++-- module/plugins/hoster/FreakshareCom.py | 22 ++++++++++++++++++++-- module/plugins/hoster/HotfileCom.py | 11 ++++++++--- module/plugins/hoster/MegauploadCom.py | 5 ++++- 4 files changed, 34 insertions(+), 8 deletions(-) (limited to 'module/plugins/hoster') diff --git a/module/plugins/hoster/EasyShareCom.py b/module/plugins/hoster/EasyShareCom.py index b389c5262..542b4367f 100644 --- a/module/plugins/hoster/EasyShareCom.py +++ b/module/plugins/hoster/EasyShareCom.py @@ -24,11 +24,11 @@ class EasyShareCom(Hoster): self.html = self.load(self.pyfile.url) if re.search("Die von ihnen angeforderte Datei wurde gel\xc3\xb6scht.", self.html): - self.offline(); + self.offline() self.pyfile.name = self.getFileName() - self.download( self.getFileUrl() ) + self.download(self.getFileUrl()) def getFileName(self): diff --git a/module/plugins/hoster/FreakshareCom.py b/module/plugins/hoster/FreakshareCom.py index d795147a6..c20206bf5 100644 --- a/module/plugins/hoster/FreakshareCom.py +++ b/module/plugins/hoster/FreakshareCom.py @@ -49,6 +49,7 @@ class FreakshareCom(Hoster): self.setWait( self.get_waiting_time() ) pyfile.name = self.get_file_name() + pyfile.size = self.get_file_size() self.wait() @@ -73,11 +74,28 @@ class FreakshareCom(Hoster): if self.html is None: self.download_html() if not self.wantReconnect: - file_name = re.search(r"([^ ]+)", self.html).group(1) + file_name = re.search(r"([^ ]+)", self.html) + if file_name is not None: + file_name = file_name.group(1) + else: + file_name = self.pyfile.url return file_name else: return self.pyfile.url + def get_file_size(self): + size = 0 + if self.html is None: + self.download_html() + if not self.wantReconnect: + file_size_check = re.search(r"[^ ]+ - ([^ ]+) (\w\w)yte", self.html) + if file_size_check is not None: + units = float(file_size_check.group(1).replace(",", "")) + pow = {'KB': 1, 'MB': 2, 'GB': 3}[file_size_check.group(2)] + size = int(units * 1024 ** pow) + + return size + def get_waiting_time(self): if self.html is None: self.download_html() @@ -140,4 +158,4 @@ class FreakshareCom(Hoster): request_options.append(("recaptcha_challenge_field", challenge)) request_options.append(("recaptcha_response_field", result)) - return request_options \ No newline at end of file + return request_options diff --git a/module/plugins/hoster/HotfileCom.py b/module/plugins/hoster/HotfileCom.py index 75806fe4e..2da443e29 100644 --- a/module/plugins/hoster/HotfileCom.py +++ b/module/plugins/hoster/HotfileCom.py @@ -86,14 +86,19 @@ class HotfileCom(Hoster): self.download(dl) def downloadHTML(self): - self.html[0] = self.load(self.pyfile.url, get={"lang":"en"}, cookies=True) + self.html[0] = self.load(self.pyfile.url, get={"lang":"en"}) def freeDownload(self): - form_content = re.search(r"
\s*)*?\n", self.html[0]).group(0) + form_content = re.search(r"\s*)*?[\n\t]?", self.html[0]) + if form_content is None: + print self.html[0] + self.fail("Form not found in HTML. Can not proceed.") + + form_content = form_content.group(0) form_posts = re.findall(r"", form_content) - self.html[1] = self.load(self.pyfile.url, post=form_posts, cookies=True) + self.html[1] = self.load(self.pyfile.url, post=form_posts) challenge = re.search(r"http://api\.recaptcha\.net/challenge\?k=([0-9A-Za-z]+)", self.html[1]) diff --git a/module/plugins/hoster/MegauploadCom.py b/module/plugins/hoster/MegauploadCom.py index 5e03ce3aa..fa16fdf31 100644 --- a/module/plugins/hoster/MegauploadCom.py +++ b/module/plugins/hoster/MegauploadCom.py @@ -99,7 +99,10 @@ class MegauploadCom(Hoster): self.wait() pyfile.name = self.get_file_name() - self.download(self.get_file_url()) + url = self.get_file_url() + if url is None: + return self.fail("URL could not be retrieved") + self.download( url ) check = self.checkDownload({"limit": "Download limit exceeded"}) if check == "limit": -- cgit v1.2.3