diff options
Diffstat (limited to 'module')
-rw-r--r-- | module/Plugin.py | 5 | ||||
-rw-r--r-- | module/file_list.py | 16 | ||||
-rw-r--r-- | module/plugins/RapidshareCom.py | 7 | ||||
-rw-r--r-- | module/thread_list.py | 16 |
4 files changed, 32 insertions, 12 deletions
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"<p class=\"downloadlink\">.+/(.+) <font" diff --git a/module/thread_list.py b/module/thread_list.py index 55f237544..3c69121c2 100644 --- a/module/thread_list.py +++ b/module/thread_list.py @@ -107,14 +107,16 @@ class Thread_List(object): if pyfile.status.type == "finished": if pyfile.plugin.props['type'] == "container": #works(!) but adds many packs to queue + self.list.packager.removeFileFromPackage(pyfile.id, pyfile.package.data["id"]) newLinks = 0 - newPackager = self.list.packager.addNewPackage(pyfile.status.filename) - for link in pyfile.plugin.links: - newFile = self.list.collector.addLink(link) - self.list.packager.addFileToPackage(newPackager, self.list.collector.popFile(newFile)) - newLinks += 1 - self.list.packager.pushPackage2Queue(newPackager) - + if pyfile.plugin.links: + newPackager = self.list.packager.addNewPackage(pyfile.status.filename) + for link in pyfile.plugin.links: + newFile = self.list.collector.addLink(link) + self.list.packager.addFileToPackage(newPackager, self.list.collector.popFile(newFile)) + newLinks += 1 + self.list.packager.pushPackage2Queue(newPackager) + if newLinks: self.parent.logger.info("Parsed link from %s: %i" % (pyfile.status.filename, newLinks)) else: |