summaryrefslogtreecommitdiffstats
path: root/Plugins
diff options
context:
space:
mode:
Diffstat (limited to 'Plugins')
-rw-r--r--Plugins/NetloadIn.py50
-rw-r--r--Plugins/RapidshareCom.py14
-rw-r--r--Plugins/UploadedTo.py46
3 files changed, 61 insertions, 49 deletions
diff --git a/Plugins/NetloadIn.py b/Plugins/NetloadIn.py
index 0df1fab8c..ac14a670c 100644
--- a/Plugins/NetloadIn.py
+++ b/Plugins/NetloadIn.py
@@ -33,26 +33,35 @@ class NetloadIn(Plugin):
self.want_reconnect = False
- self.req.clear_cookies()
- self.download_html()
+ tries = 0
- pyfile.status.exists = self.file_exists()
+ while not pyfile.status.url:
- if not pyfile.status.exists:
- raise Exception, "The file was not found on the server."
+ 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."
- pyfile.status.filename = self.get_file_name()
+ pyfile.status.filename = self.get_file_name()
- self.download_html2()
+ self.download_html2()
- self.get_wait_time()
+ self.get_wait_time()
- pyfile.status.waituntil = self.time_plus_wait
- pyfile.status.want_reconnect = self.want_reconnect
+ pyfile.status.waituntil = self.time_plus_wait
+ pyfile.status.want_reconnect = self.want_reconnect
- thread.wait(self.parent)
+ 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])
- pyfile.status.url = self.get_file_url()
return True
@@ -72,24 +81,25 @@ class NetloadIn(Plugin):
for i in range(10):
self.req.download(captcha_url, captcha_image, cookies=True)
captcha = self.ocr.get_captcha(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
+ return True
+
+ raise Exception, "Captcha reading failed"
os.remove(captcha_image)
def get_file_url(self):
""" returns the absolute downloadable filepath
"""
- if self.html[0] == None:
- self.download_html()
- if not self.want_reconnect:
+ try:
file_url_pattern = r"<a class=\"Orange_Link\" href=\"(http://.+)\" >Click here"
search = re.search(file_url_pattern, self.html[2])
return search.group(1)
- else:
- return False
+ except:
+ return None
def get_wait_time(self):
wait = int(re.search(r"countdown\((.+),'change\(\)'\)", self.html[2]).group(1))
@@ -99,8 +109,6 @@ class NetloadIn(Plugin):
self.want_reconnect = True
def get_file_name(self):
- if self.html[0] == None:
- self.download_html()
if not self.want_reconnect:
file_name_pattern = '\t\t\t(.+)<span style="color: #8d8d8d;">'
return re.search(file_name_pattern, self.html[0]).group(1)
@@ -110,8 +118,6 @@ class NetloadIn(Plugin):
def file_exists(self):
""" returns True or False
"""
- if self.html[0] == None:
- self.download_html()
if re.search(r"The file has been deleted", self.html[0]) != None:
return False
else:
diff --git a/Plugins/RapidshareCom.py b/Plugins/RapidshareCom.py
index 52d731053..2c78a2672 100644
--- a/Plugins/RapidshareCom.py
+++ b/Plugins/RapidshareCom.py
@@ -62,7 +62,7 @@ class RapidshareCom(Plugin):
tries += 1
if tries > 5:
- raise Exception, "Error when downloading, HTML dump:"+ str(self.html[0]) + str(self.html[1])
+ raise Exception, "Error while preparing, HTML dump:"+ str(self.html[0]) + str(self.html[1])
return True
@@ -78,8 +78,6 @@ class RapidshareCom(Plugin):
def download_serverhtml(self):
"""downloads html with the important informations
"""
- if self.html[0] == None:
- self.download_html()
if self.config['premium']:
return False
@@ -95,9 +93,6 @@ class RapidshareCom(Plugin):
self.time_plus_wait = 0
return True
- if self.html[1] == None:
- self.download_serverhtml(self)
-
if re.search(r".*is already downloading.*", self.html[1]) != None:
self.time_plus_wait = time() + 10 * 60
try:
@@ -114,8 +109,6 @@ class RapidshareCom(Plugin):
def file_exists(self):
""" returns True or False
"""
- if self.html[0] == None:
- self.download_html()
if re.search(r".*The File could not be found.*", self.html[0]) != None or \
re.search(r"(<p>This limit is reached.</p>)", self.html[0]) or \
re.search(r"(.*is momentarily not available.*)", self.html[0]) or \
@@ -132,9 +125,6 @@ class RapidshareCom(Plugin):
self.start_dl = True
return self.parent.url
- if self.html[1] == None:
- self.download_serverhtml()
-
#if (self.html_old + 5 * 60) < time(): # nach einiger zeit ist die file_url nicht mehr aktuell
# self.download_serverhtml()
@@ -154,8 +144,6 @@ class RapidshareCom(Plugin):
#raise Exception, "Error when retrieving download url"
def get_file_name(self):
- if self.html[0] == None:
- self.download_html()
file_name_pattern = r"<p class=\"downloadlink\">.+/(.+) <font"
return re.findall(file_name_pattern, self.html[0])[0]
diff --git a/Plugins/UploadedTo.py b/Plugins/UploadedTo.py
index 7f30a0519..e163a3230 100644
--- a/Plugins/UploadedTo.py
+++ b/Plugins/UploadedTo.py
@@ -25,6 +25,35 @@ class UploadedTo(Plugin):
self.want_reconnect = None
self.multi_dl = False
+ def prepare(self, thread):
+ pyfile = self.parent
+
+ self.want_reconnect = False
+ tries = 0
+
+ while not pyfile.status.url:
+
+ self.download_html()
+
+ pyfile.status.exists = self.file_exists()
+
+ if not pyfile.status.exists:
+ raise Exception, "The file was not found on the server."
+
+ pyfile.status.filename = self.get_file_name()
+
+ pyfile.status.waituntil = self.time_plus_wait
+ pyfile.status.url = self.get_file_url()
+ pyfile.status.want_reconnect = self.want_reconnect
+
+ thread.wait(self.parent)
+
+ tries += 1
+ if tries > 5:
+ raise Exception, "Error while preparing DL, HTML dump: %s" % self.html
+
+ return True
+
def download_html(self):
url = self.parent.url
self.html = self.req.load(url)
@@ -39,17 +68,13 @@ class UploadedTo(Plugin):
def get_file_url(self):
""" returns the absolute downloadable filepath
"""
- if self.html == None:
- self.download_html()
- if not self.want_reconnect:
+ try:
file_url_pattern = r".*<form name=\"download_form\" method=\"post\" action=\"(.*)\">"
return re.search(file_url_pattern, self.html).group(1)
- else:
- return False
+ except:
+ return None
def get_file_name(self):
- if self.html == None:
- self.download_html()
if not self.want_reconnect:
file_name = re.search(r"<td><b>\s+(.+)\s", self.html).group(1)
file_suffix = re.search(r"</td><td>(\..+)</td></tr>", self.html)
@@ -62,14 +87,7 @@ class UploadedTo(Plugin):
def file_exists(self):
""" returns True or False
"""
- if self.html == None:
- self.download_html()
if re.search(r"(File doesn't exist .*)", self.html) != None:
return False
else:
return True
-
- def wait_until(self):
- if self.html == None:
- self.download_html()
- return self.time_plus_wait