From 78f061eed59e084f001f8a0cd9c5b585f6fc0ce0 Mon Sep 17 00:00:00 2001 From: mkaay Date: Fri, 4 Dec 2009 20:01:17 +0100 Subject: fixes, minimal gui changes --- module/Plugin.py | 5 ++++- module/file_list.py | 16 ++++++++++++---- module/plugins/RapidshareCom.py | 7 +++++++ module/thread_list.py | 16 +++++++++------- 4 files changed, 32 insertions(+), 12 deletions(-) (limited to 'module') diff --git a/module/Plugin.py b/module/Plugin.py index 7b726c3ac..f343dc62f 100644 --- a/module/Plugin.py +++ b/module/Plugin.py @@ -89,7 +89,10 @@ class Plugin(): return self.parent.url def get_file_name(self): - return re.findall("([^\/=]+)", self.parent.url)[-1] + try: + return re.findall("([^\/=]+)", self.parent.url)[-1] + except: + return "no_name" def wait_until(self): if self.html != None: diff --git a/module/file_list.py b/module/file_list.py index f66567e0f..2bfe37298 100644 --- a/module/file_list.py +++ b/module/file_list.py @@ -136,7 +136,7 @@ class File_List(object): try: n, pyfile = self.collector._getFileFromID(id) except NoSuchElementException: - key, n, pyfile, pypack, pid = self.packager._getFileFromID() + key, n, pyfile, pypack, pid = self.packager._getFileFromID(id) info = {} info["id"] = pyfile.id info["url"] = pyfile.url @@ -146,6 +146,7 @@ class File_List(object): info["status_url"] = pyfile.status.url info["status_filename"] = pyfile.status.filename info["status_error"] = pyfile.status.error + info["active"] = pyfile.active return info class pyLoadCollector(): @@ -260,11 +261,11 @@ class File_List(object): for n, pypack in enumerate(packager.file_list.data["packages"]): for pyfile in pypack.files: if pyfile.id == id: - return ("packages", n, pyfile, pypack, pid) + return ("packages", n, pyfile, pypack, pypack.data["id"]) for n, pypack in enumerate(packager.file_list.data["queue"]): for pyfile in pypack.files: if pyfile.id == id: - return ("queue", n, pyfile, pypack, pid) + return ("queue", n, pyfile, pypack, pypack.data["id"]) raise NoSuchElementException() def addNewPackage(packager, package_name=None): @@ -291,6 +292,8 @@ class File_List(object): try: key, n, pyfile, pypack, pid = self._getFileFromID() del pypack.files[n] + if not pypack.files: + packager.removePackage(pid) finally: packager.file_list.lock.release() @@ -343,11 +346,14 @@ class File_List(object): pypack.files.append(pyfile) packager.file_list.data[key][n] = pypack + #oooops, duplicate? def removeFileFromPackage(packager, id, pid): key, n, pypack = packager._getPackageFromID(pid) for k, pyfile in enumerate(pypack.files): if id == pyfile.id: del pypack.files[k] + if not pypack.files: + packager.removePackage(pid) return True raise NoSuchElementException() @@ -368,7 +374,7 @@ class PyLoadFile(): self.file_list = file_list self.core = file_list.core self.package = None - self.filename = "filename" + self.filename = "n/a" self.download_folder = "" self.active = False pluginName = self._get_my_plugin() @@ -380,6 +386,8 @@ class PyLoadFile(): pluginClass = module.Plugin.Plugin self.plugin = pluginClass(self) self.status = Status(self) + if self.plugin.file_exists(): + self.filename = self.plugin.get_file_name() def _get_my_plugin(self): for plugin, plugin_pattern in self.core.plugins_avaible.items(): diff --git a/module/plugins/RapidshareCom.py b/module/plugins/RapidshareCom.py index 7daff3f8f..f7bcb5de8 100644 --- a/module/plugins/RapidshareCom.py +++ b/module/plugins/RapidshareCom.py @@ -27,6 +27,7 @@ class RapidshareCom(Plugin): self.time_plus_wait = None #time() + wait in seconds self.want_reconnect = False self.no_slots = True + self.api_data = None #~ self.logger = logging.getLogger("log") self.read_config() if self.config['premium']: @@ -153,6 +154,8 @@ class RapidshareCom(Plugin): def file_exists(self): """ returns True or False """ + if self.html[0] == None: + self.download_html() if re.search("The file could not be found|This limit is reached| \ is momentarily not available|removed this file| \ contain illegal content", self.html[0], re.I) != None: @@ -190,6 +193,10 @@ class RapidshareCom(Plugin): #raise Exception, "Error when retrieving download url" def get_file_name(self): + if self.html[0] == None: + self.download_html() + if self.api_data == None: + self.download_api_data() if self.api_data and self.api_data["filename"]: return self.api_data["filename"] file_name_pattern = r"

.+/(.+)