summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2011-10-02 21:01:32 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2011-10-02 21:01:32 +0200
commit63d9fa12a205b5c770e75c09be1a0a9656eb1ea1 (patch)
tree1dbf8cd99c00cd59f02cbcc7474ddbf03ef1f8f3
parentGUI_progressbar_fix.patch by royflo (diff)
downloadpyload-63d9fa12a205b5c770e75c09be1a0a9656eb1ea1.tar.xz
fixed urlmatcher, clear links on start option
-rw-r--r--module/Api.py5
-rw-r--r--module/database/FileDatabase.py5
-rwxr-xr-xpyLoadCore.py14
3 files changed, 15 insertions, 9 deletions
diff --git a/module/Api.py b/module/Api.py
index 66ba855f1..3480f05b8 100644
--- a/module/Api.py
+++ b/module/Api.py
@@ -45,7 +45,7 @@ def permission(bits):
return _Dec
-urlmatcher = re.compile(r"((https?|ftps?|xdcc|sftp):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)", re.IGNORECASE)
+urlmatcher = re.compile(r"((https?|ftps?|xdcc|sftp):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+\-=\\\.&]*)", re.IGNORECASE)
class PERMS:
ALL = 0 # requires no permission, but login
@@ -338,7 +338,8 @@ class Api(Iface):
page = getURL(url)
urls += [x[0] for x in urlmatcher.findall(page)]
- return self.checkURLs(urls)
+ # remove duplicates
+ return self.checkURLs(set(urls))
@permission(PERMS.ADD)
diff --git a/module/database/FileDatabase.py b/module/database/FileDatabase.py
index 2ca7fd07d..91213d8a6 100644
--- a/module/database/FileDatabase.py
+++ b/module/database/FileDatabase.py
@@ -863,6 +863,11 @@ class FileMethods():
self.c.execute("SELECT l.plugin FROM links as l INNER JOIN packages as p ON l.package=p.id AND p.folder=? WHERE l.id!=? AND l.status=0 AND l.name=?", (folder, id, filename))
return self.c.fetchone()
+ @style.queue
+ def purgeLinks(self):
+ self.c.execute("DELETE FROM links;")
+ self.c.execute("DELETE FROM packages;")
+
DatabaseBackend.registerSub(FileMethods)
if __name__ == "__main__":
diff --git a/pyLoadCore.py b/pyLoadCore.py
index b95d6f072..1d1f197ec 100755
--- a/pyLoadCore.py
+++ b/pyLoadCore.py
@@ -79,6 +79,7 @@ class Core(object):
self.daemon = False
self.arg_links = []
self.pidfile = "pyload.pid"
+ self.deleteLinks = False # will delete links on startup
if len(argv) > 1:
try:
@@ -93,11 +94,7 @@ class Core(object):
elif option == "--daemon":
self.daemon = True
elif option in ("-c", "--clear"):
- try:
- remove("files.db")
- print "Removed Linklist"
- except:
- print "No Linklist found"
+ self.deleteLinks = True
elif option in ("-h", "--help"):
self.print_help()
exit()
@@ -341,10 +338,9 @@ class Core(object):
self.captcha = True # checks seems to fail, althoug tesseract is available
self.check_file(self.config['general']['download_folder'], _("folder for downloads"), True)
- self.check_file("links.txt", _("file for links"))
if self.config['ssl']['activated']:
- self.check_install("OpenSSL", _("OpenSSL for secure connection"), True)
+ self.check_install("OpenSSL", _("OpenSSL for secure connection"))
self.setupDB()
if self.config.oldRemoteData:
@@ -353,6 +349,10 @@ class Core(object):
self.log.info(_("Please check your logindata with ./pyLoadCore.py -u"))
+ if self.deleteLinks:
+ self.log.info(_("All links removed"))
+ self.db.purgeLinks()
+
self.requestFactory = RequestFactory(self)
__builtin__.pyreq = self.requestFactory