diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2009-05-19 16:26:37 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2009-05-19 16:26:37 +0200 |
commit | b44f560c3a53c073a1290e3403ff76ebbe35e91b (patch) | |
tree | 595a55d2acd0670a313c58f0263dd3c15050e80a | |
parent | rapidshare waits (diff) | |
download | pyload-b44f560c3a53c073a1290e3403ff76ebbe35e91b.tar.xz |
RapidshareCom läuft jetzt wieder.
-rw-r--r-- | Plugins/RapidshareCom.py | 66 | ||||
-rw-r--r-- | Py_Load_File.py | 11 | ||||
-rw-r--r-- | download_thread.py | 3 |
3 files changed, 50 insertions, 30 deletions
diff --git a/Plugins/RapidshareCom.py b/Plugins/RapidshareCom.py index e075ecfc7..6f81a9549 100644 --- a/Plugins/RapidshareCom.py +++ b/Plugins/RapidshareCom.py @@ -25,7 +25,8 @@ class RapidshareCom(Plugin): pluginProp ['author_email'] = "nn@nn.de" self.pluginProp = pluginProp self.parent = parent - self.html = None + self.html = [None, None] + self.prehtml = None self.html_old = None #time() where loaded the HTML self.time_plus_wait = None #time() + wait in seconds self.want_reconnect = False @@ -33,46 +34,62 @@ class RapidshareCom(Plugin): def set_parent_status(self): """ sets all available Statusinfos about a File in self.parent.status """ - if self.html == None: + if self.html[0] == None: self.download_html() + + self.get_wait_time() self.parent.status.filename = self.get_file_name() self.parent.status.url = self.get_file_url() - self.parent.status.wait = self.wait_until() + self.parent.status.waituntil = self.wait_until() def download_html(self): """ gets the url from self.parent.url saves html in self.html and parses """ url = self.parent.url html = urllib2.urlopen(url).read() - self.html = html + self.html[0] = html self.html_old = time() - def get_wait_time(self): - file_server_url = re.search(r"<form action=\"(.*?)\"", self.html).group(1) + def download_serverhtml(self): + """downloads html with the important informations + """ + if self.html[0] == None: + self.download_html() + + file_server_url = re.search(r"<form action=\"(.*?)\"", self.html[0]).group(1) #free user free_user_encode = urllib.urlencode({"dl.start" : "Free"}) - self.html = urllib2.urlopen(file_server_url, free_user_encode).read() - if re.search(r".*is already downloading.*", self.html) != None: + self.html[1] = urllib2.urlopen(file_server_url, free_user_encode).read() + self.html_old = time() + self.get_wait_time() + + + def get_wait_time(self): + + if self.html[1] == None: + download_serverhtml(self) + + if re.search(r".*is already downloading.*", self.html[1]) != None: self.time_plus_wait = time() + 10*60 try: - wait_minutes = re.search(r"Or try again in about (\d+) minute", self.html).group(1) + wait_minutes = re.search(r"Or try again in about (\d+) minute", self.html[1]).group(1) self.time_plus_wait = time() + 60 * int(wait_minutes) self.want_reconnect = True except: - if re.search(r".*Currently a lot of users.*", self.html) != None: + if re.search(r".*Currently a lot of users.*", self.html[1]) != None: self.time_plus_wait = time() + 2*60 - wait_seconds = re.search(r"var c=(.*);.*", self.html).group(1) + wait_seconds = re.search(r"var c=(.*);.*", self.html[1]).group(1) self.time_plus_wait = time() + int(wait_seconds) + 5 def file_exists(self): """ returns True or False """ - if self.html == None: + if self.html[0] == None: self.download_html() - if re.search(r".*The File could not be found.*", self.html) != None or \ - re.search(r"(<p>This limit is reached.</p>)", self.html) or \ - re.search(r"(.*is momentarily not available.*)", self.html) or \ - re.search(r"(.*The uploader has removed this file from the server.*)", self.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 \ + re.search(r"(.*The uploader has removed this file from the server.*)", self.html[0]): return False else: return True @@ -80,24 +97,23 @@ class RapidshareCom(Plugin): def get_file_url(self): """ returns the absolute downloadable filepath """ - se.get_wait_time() - if self.html == None: - self.download_html() - if (self.html_old + 5*60) > time(): # nach einiger zeit ist die file_url nicht mehr aktuell - self.download_html() + 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() if not self.want_reconnect: file_url_pattern = r".*name=\"dlf\" action=\"(.*)\" method=.*" - return re.search(file_url_pattern, self.html).group(1) + return re.search(file_url_pattern, self.html[1]).group(1) else: return False def get_file_name(self): - if self.html == None: - self.download_html() + if self.html[1] == None: + self.download_serverhtml() if not self.want_reconnect: file_name_pattern = r".*name=\"dlf\" action=\"(.*)\" method=.*" - return re.search(file_name_pattern, self.html).group(1).split('/')[-1] + return re.search(file_name_pattern, self.html[1]).group(1).split('/')[-1] else: return self.parent.url diff --git a/Py_Load_File.py b/Py_Load_File.py index dc1c2ba75..157d51bfd 100644 --- a/Py_Load_File.py +++ b/Py_Load_File.py @@ -19,9 +19,10 @@ class PyLoadFile: def prepareDownload(self): - self.status.exists = True #self.plugin.file_exists() - self.status.filename = self.plugin.get_file_name() - self.status.waituntil = self.plugin.time_plus_wait - self.status.url = self.plugin.get_file_url() - self.status.want_reconnect = self.plugin.want_reconnect + self.status.exists = self.plugin.file_exists() + if self.status.exists: + self.status.filename = self.plugin.get_file_name() + self.status.waituntil = self.plugin.time_plus_wait + self.status.url = self.plugin.get_file_url() + self.status.want_reconnect = self.plugin.want_reconnect diff --git a/download_thread.py b/download_thread.py index 2b6fafdab..672f15682 100644 --- a/download_thread.py +++ b/download_thread.py @@ -84,10 +84,13 @@ class Download_Thread(threading.Thread): if not status.exists: self.shutdown = True + return False if status.want_reconnect: print "handle reconnect" self.shutdown = True + return False + while (time() < status.waituntil): status.type = "waiting" sleep(1) #eventuell auf genaue zeit warten |