From 0036345203f37f7f29cc60cbf19b4f355ee8e0ce Mon Sep 17 00:00:00 2001 From: RaNaN Date: Tue, 19 May 2009 12:19:31 +0000 Subject: =?UTF-8?q?UploadedTo=20funktioniert=20jetzt=20auch.=20Wartezeit?= =?UTF-8?q?=20wird=20auch=20ber=C3=BCcksichigt.=20TODO:=20Reconnect=20verw?= =?UTF-8?q?alten,=20Download=20Verwaltung=20->=20von=20einem=20Plugin=20nu?= =?UTF-8?q?r=20eine=20Datei=20gleichzeitig,=20Zeit=20zum=20Downloaden=20et?= =?UTF-8?q?c..?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Plugins/UploadedTo.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'Plugins/UploadedTo.py') diff --git a/Plugins/UploadedTo.py b/Plugins/UploadedTo.py index dad5db3a9..fe2c3ec37 100644 --- a/Plugins/UploadedTo.py +++ b/Plugins/UploadedTo.py @@ -2,6 +2,7 @@ import urllib2 import re +from time import time from Plugin import Plugin class UploadedTo(Plugin): @@ -23,6 +24,7 @@ class UploadedTo(Plugin): self.html = None self.html_old = None #time() where loaded the HTML self.time_plus_wait = None #time() + wait in seconds + self.want_reconnect = None def set_parent_status(self): """ sets all available Statusinfos about a File in self.parent.status @@ -35,10 +37,12 @@ class UploadedTo(Plugin): def download_html(self): url = self.parent.url - html = urllib2.urlopen(url).read() + self.html = urllib2.urlopen(url).read() + try: wait_minutes = re.search(r"Or wait (\d+) minutes", self.html).group(1) - self.time_plus_wait = time() + 60 * wait_minutes + self.time_plus_wait = time() + 60 * int(wait_minutes) + self.want_reconnect = True except: self.time_plus_wait = 0 @@ -47,14 +51,20 @@ class UploadedTo(Plugin): """ if self.html == None: self.download_html() - file_url_pattern = r".*
" - return re.search(file_url_pattern, self.html).group(1) + if not self.want_reconnect: + file_url_pattern = r".*" + return re.search(file_url_pattern, self.html).group(1) + else: + return False def get_file_name(self): if self.html == None: self.download_html() - file_name_pattern = r"\s*(.*?)\s+\.\.\." - return re.search(file_name_pattern, self.html).group(1) + if not self.want_reconnect: + file_name_pattern = r"<title>\s*(.*?)\s+\.\.\." + return re.search(file_name_pattern, self.html).group(1) + else: + return self.parent.url def file_exists(self): """ returns True or False -- cgit v1.2.3