From ed14601a9a83439ce096441ad7ca7a8c4d9b13f8 Mon Sep 17 00:00:00 2001 From: spoob Date: Sat, 19 Dec 2009 20:50:26 +0100 Subject: Fixed file_exists function for local files --- module/Plugin.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'module/Plugin.py') diff --git a/module/Plugin.py b/module/Plugin.py index 14a480e3b..8e5bbcfe8 100644 --- a/module/Plugin.py +++ b/module/Plugin.py @@ -20,6 +20,8 @@ import ConfigParser import logging import re +from os.path import exists + from module.network.Request import Request @@ -54,7 +56,7 @@ class Plugin(): pyfile.status.exists = self.file_exists() if not pyfile.status.exists: - raise Exception, "The file was not found on the server." + raise Exception, "File not found" return False pyfile.status.filename = self.get_file_name() @@ -75,12 +77,15 @@ class Plugin(): def download_html(self): """ gets the url from self.parent.url saves html in self.html and parses """ - html = "" - self.html = html + self.html = "" def file_exists(self): """ returns True or False """ + if re.search(r"(?!http://).*\.(dlc|ccf|rsdf|txt)", self.parent.url): + return exists(self.parent.url) + elif re.search(r"Not Found", self.parent.url): + return False return True def get_file_url(self): @@ -92,7 +97,7 @@ class Plugin(): try: return re.findall("([^\/=]+)", self.parent.url)[-1] except: - return "no_name" + return self.parent.url[:20] def wait_until(self): if self.html != None: -- cgit v1.2.3