From 282726fd6c730b20d29303cf587e833491fbbd30 Mon Sep 17 00:00:00 2001 From: evilhero Date: Thu, 20 Dec 2012 06:52:21 -0500 Subject: [PATCH] Fix: allow for ',:' in search, directory creation, and post-processing IMP: Altering default comic directory --- mylar/PostProcessor.py | 3 +++ mylar/search.py | 1 + mylar/webserve.py | 11 +++++++++++ 3 files changed, 15 insertions(+) diff --git a/mylar/PostProcessor.py b/mylar/PostProcessor.py index 7054517d..0e68cea3 100755 --- a/mylar/PostProcessor.py +++ b/mylar/PostProcessor.py @@ -16,6 +16,7 @@ import os import shutil +import re import time @@ -130,6 +131,8 @@ def PostProcess(nzb_name, nzb_folder): #mylar.REPLACE_CHAR ...determines what to replace spaces with underscore or dot nfilename = nfilename.replace(' ', mylar.REPLACE_CHAR) #TODO - sort issue numbering 12.00 should be 12 + #replace funky characters so it doesn't break things + nfilename = re.sub('[\,\:]', '', nfilename) log2screen = log2screen + "New Filename: " + nfilename + "\n" src = nzb_folder + "/" + ofilename diff --git a/mylar/search.py b/mylar/search.py index ec280d8e..5050f421 100755 --- a/mylar/search.py +++ b/mylar/search.py @@ -441,6 +441,7 @@ def NZB_SEARCH(ComicName, IssueNumber, ComicYear, SeriesYear, nzbprov, nzbpr, Is #filenzb = os.path.join(tmppath,filenamenzb) logger.fdebug("unalterted nzb name: " + str(filenamenzb)) #let's send a clean copy to SAB because the names are random characters and/or could be stupid. + ComicName = re.sub('[\:\,]', '', ComicName) filenzb = str(ComicName.replace(' ', '_')) + "_" + str(IssueNumber) + "_(" + str(comyear) + ")" logger.fdebug("prettified nzb name: " + str(filenzb)) diff --git a/mylar/webserve.py b/mylar/webserve.py index e58d7665..f00d203d 100755 --- a/mylar/webserve.py +++ b/mylar/webserve.py @@ -531,6 +531,17 @@ class WebInterface(object): #"QUALtype": qual_type, #"QUALquality": qual_quality #} + #force the check/creation of directory com_location here + if os.path.isdir(str(com_location)): + logger.info(u"Validating Directory (" + str(com_location) + "). Already exists! Continuing...") + else: + logger.fdebug("Updated Directory doesn't exist! - attempting to create now.") + try: + os.makedirs(str(com_location)) + logger.info(u"Directory successfully created at: " + str(com_location)) + except OSError: + logger.error(u"Could not create comicdir : " + str(com_location)) + myDB.upsert("comics", newValues, controlValueDict) raise cherrypy.HTTPRedirect("artistPage?ComicID=%s" % ComicID) comic_config.exposed = True