diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2009-05-26 00:04:33 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2009-05-26 00:04:33 +0200 |
commit | d44888ca5ab15913db944d1b1646df8f103c4ba6 (patch) | |
tree | e1d9d6109cb29ae45db1fe065b8395e5f3f789eb | |
parent | changed variable names (diff) | |
download | pyload-d44888ca5ab15913db944d1b1646df8f103c4ba6.tar.xz |
improved plugins
-rw-r--r-- | Core.py | 2 | ||||
-rw-r--r-- | Plugins/Plugin.py | 5 | ||||
-rw-r--r-- | Plugins/RapidshareCom.py | 6 | ||||
-rw-r--r-- | Plugins/UploadedTo.py | 5 | ||||
-rw-r--r-- | Plugins/YoutubeCom.py | 24 | ||||
-rw-r--r-- | module/Py_Load_File.py | 2 | ||||
-rw-r--r-- | module/download_thread.py | 41 | ||||
-rw-r--r-- | module/thread_list.py | 13 |
8 files changed, 53 insertions, 45 deletions
@@ -212,7 +212,7 @@ class Core(object): return True def _test_print_status(self): - if len(self.thread_list.py_downloading)>0: + if self.thread_list.py_downloading: for pyfile in self.thread_list.py_downloading: if pyfile.status.type == 'downloading': diff --git a/Plugins/Plugin.py b/Plugins/Plugin.py index 971677ec7..1babd3686 100644 --- a/Plugins/Plugin.py +++ b/Plugins/Plugin.py @@ -9,7 +9,7 @@ class Plugin(): def __init__(self, parent): self.plugin_name = None self.plugin_pattern = None - self.plugin_type = "" + self.plugin_type = "hoster" pluginProp = {} pluginProp ['name'] = "Beispiel Plugin" pluginProp ['version'] = "0.1" @@ -23,6 +23,7 @@ class Plugin(): self.html = None self.time_plus_wait = None #time() + wait in seconds self.want_reconnect = None + self.multi_dl = True def set_parent_status(self): """ sets all available Statusinfos about a File in self.parent.status @@ -46,6 +47,8 @@ class Plugin(): """ if self.html != None: self.download_html() + return self.parent.url + def get_file_name(self): raise NotImplementedError diff --git a/Plugins/RapidshareCom.py b/Plugins/RapidshareCom.py index 6ad0b43e8..f512b2460 100644 --- a/Plugins/RapidshareCom.py +++ b/Plugins/RapidshareCom.py @@ -17,20 +17,22 @@ class RapidshareCom(Plugin): self.plugin_pattern = r"http://(?:www.)?rapidshare.com/files/" self.plugin_type = "hoster" self.plugin_config = {} - pluginProp = {} + pluginProp = {} pluginProp ['name'] = "RapidshareCom" pluginProp ['version'] = "0.1" pluginProp ['format'] = "*.py" pluginProp ['description'] = """Rapidshare Plugin""" pluginProp ['author'] = "spoob" pluginProp ['author_email'] = "nn@nn.de" - self.pluginProp = pluginProp + pluginProp ['multi_dl'] = False + self.pluginProp = pluginProp self.parent = parent 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 + self.multi_dl = False def set_parent_status(self): """ sets all available Statusinfos about a File in self.parent.status diff --git a/Plugins/UploadedTo.py b/Plugins/UploadedTo.py index 4b2d3c6f0..d75a4eb95 100644 --- a/Plugins/UploadedTo.py +++ b/Plugins/UploadedTo.py @@ -13,19 +13,20 @@ class UploadedTo(Plugin): self.plugin_pattern = r"http://(www\.)?uploaded.to/" self.plugin_type = "hoster" self.plugin_config = {} - pluginProp = {} + pluginProp = {} pluginProp ['name'] = "UploadedTo" pluginProp ['version'] = "0.1" pluginProp ['format'] = "*.py" pluginProp ['description'] = """Uploaded Plugin""" pluginProp ['author'] = "spoob" pluginProp ['author_email'] = "spoob@gmx.de" - self.pluginProp = pluginProp + self.pluginProp = pluginProp self.parent = parent 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 + self.multi_dl = False def set_parent_status(self): """ sets all available Statusinfos about a File in self.parent.status diff --git a/Plugins/YoutubeCom.py b/Plugins/YoutubeCom.py index 2c019aa7c..7224323bb 100644 --- a/Plugins/YoutubeCom.py +++ b/Plugins/YoutubeCom.py @@ -13,14 +13,14 @@ class YoutubeCom(Plugin): self.plugin_pattern = r"http://(www\.)?(de\.)?\youtube\.com/watch\?v=(.*)" self.plugin_type = "hoster" self.plugin_config = {} - pluginProp = {} + pluginProp = {} pluginProp ['name'] = "YoutubeCom" pluginProp ['version'] = "0.1" pluginProp ['format'] = "*.py" pluginProp ['description'] = """Youtube Plugin""" pluginProp ['author'] = "spoob" pluginProp ['author_email'] = "spoob@pyload.org" - self.pluginProp = pluginProp + self.pluginProp = pluginProp self.parent = parent self.html = None self.html_old = None #time() where loaded the HTML @@ -45,22 +45,18 @@ class YoutubeCom(Plugin): """ if self.html == None: self.download_html() - if not self.want_reconnect: - videoId = re.search(self.plugin_pattern, self.parent.url).group(3) - videoHash = re.search(r', "t": "([^"]+)"', self.html).group(1) - file_url = 'http://youtube.com/get_video?video_id=' + videoId + '&t=' + videoHash + '&fmt=18' - return file_url - else: - return False + + videoId = re.search(self.plugin_pattern, self.parent.url).group(3) + videoHash = re.search(r', "t": "([^"]+)"', self.html).group(1) + file_url = 'http://youtube.com/get_video?video_id=' + videoId + '&t=' + videoHash + '&fmt=18' + return file_url def get_file_name(self): if self.html == None: self.download_html() - if not self.want_reconnect: - file_name_pattern = r"<title>YouTube - (.*)</title>" - return re.search(file_name_pattern, self.html).group(1).replace("/", "") + '.mp4' - else: - return self.parent.url + + file_name_pattern = r"<title>YouTube - (.*)</title>" + return re.search(file_name_pattern, self.html).group(1).replace("/", "") + '.mp4' def file_exists(self): """ returns True or False diff --git a/module/Py_Load_File.py b/module/Py_Load_File.py index c4bf2b08c..9f962ffb3 100644 --- a/module/Py_Load_File.py +++ b/module/Py_Load_File.py @@ -23,7 +23,7 @@ class PyLoadFile: if re.match(plugin_pattern, self.url) != None: return plugin #logger: kein plugin gefunden # was soll passieren wenn nichts gefunden wird?!? - return None + return "Plugin" def prepareDownload(self): self.status.exists = self.plugin.file_exists() diff --git a/module/download_thread.py b/module/download_thread.py index 31d449472..f103b2271 100644 --- a/module/download_thread.py +++ b/module/download_thread.py @@ -83,7 +83,13 @@ class Download_Thread(threading.Thread): if self.parent.py_load_files: self.loadedPyFile = self.parent.get_job() if self.loadedPyFile: - self.download(self.loadedPyFile) + try: + self.download(self.loadedPyFile) + except Exception, e: + print "Error:", e + #catch up all error here + finally: + self.parent.job_finished(self.loadedPyFile) sleep(0.5) if self.shutdown: sleep(1) @@ -94,26 +100,25 @@ class Download_Thread(threading.Thread): status = pyfile.status pyfile.prepareDownload() - if status.exists: - - if status.want_reconnect: - print "handle reconnect" - - while (time() < status.waituntil): - status.type = "waiting" - sleep(1) #eventuell auf genaue zeit warten + if not status.exists: + raise "FileDontExists" #i know its deprecated, who cares^^ - - status.type = "downloading" - print status.url , status.filename + + if status.want_reconnect: + print "handle reconnect" - try: - pyfile.plugin.req.download(status.url, pyfile.download_folder + "/" + status.filename) - status.type = "finished" - except: - status.type = "failed" + while (time() < status.waituntil): + status.type = "waiting" + sleep(1) #eventuell auf genaue zeit warten - self.parent.job_finished(pyfile) + try: + status.type = "downloading" + print status.url , status.filename + + pyfile.plugin.req.download(status.url, pyfile.download_folder + "/" + status.filename) + status.type = "finished" + except: + status.type = "failed" #startet downloader #urllib.urlretrieve(status.url, pyfile.download_folder + "/" + status.filename, status) diff --git a/module/thread_list.py b/module/thread_list.py index 34fa05599..1f967540b 100644 --- a/module/thread_list.py +++ b/module/thread_list.py @@ -53,11 +53,11 @@ class Thread_List(object): def remove_thread(self, thread): self.threads.remove(thread) - def status(self): - if not self.status_queue.empty(): - while not self.status_queue.empty(): - status = self.status_queue.get() - self.py_load_files[status.id].status = status +# def status(self): +# if not self.status_queue.empty(): +# while not self.status_queue.empty(): +# status = self.status_queue.get() +# self.py_load_files[status.id].status = status def get_job(self): # return job if suitable, otherwise send thread idle @@ -71,7 +71,8 @@ class Thread_List(object): if pyfile: self.py_downloading.append(pyfile) - self.occ_plugins.append(pyfile.modul.__name__) + if not pyfile.plugin.multi_dl: + self.occ_plugins.append(pyfile.modul.__name__) self.lock.release() return pyfile |