diff --git a/mylar/filechecker.py b/mylar/filechecker.py index 3c56b156..44d686bc 100755 --- a/mylar/filechecker.py +++ b/mylar/filechecker.py @@ -25,7 +25,11 @@ def file2comicmatch(watchmatch): #print ("match: " + str(watchmatch)) pass -def listFiles(dir,watchcomic): +def listFiles(dir,watchcomic,AlternateSearch=None): + # use AlternateSearch to check for filenames that follow that naming pattern + # ie. Star Trek TNG Doctor Who Assimilation won't get hits as the + # checker looks for Star Trek TNG Doctor Who Assimilation2 (according to CV) + logger.fdebug("comic: " + watchcomic) basedir = dir logger.fdebug("Looking in: " + dir) @@ -41,10 +45,16 @@ def listFiles(dir,watchcomic): modwatchcomic = re.sub('[\_\#\,\/\:\;\.\-\!\$\%\&\+\'\?\@]', ' ', str(watchcomic)) modwatchcomic = re.sub('\s+', ' ', str(modwatchcomic)).strip() subname = re.sub('\s+', ' ', str(subname)).strip() + if AlternateSearch is not None: + altsearchcomic = re.sub('[\_\#\,\/\:\;\.\-\!\$\%\&\+\'\?\@]', ' ', str(AlternateSearch)) + altsearchcomic = re.sub('\s+', ' ', str(altsearchcomic)).strip() + else: + #create random characters so it will never match. + altsearchcomic = "127372873872871091383 abdkhjhskjhkjdhakajhf" #if '_' in subname: # subname = subname.replace('_', ' ') logger.fdebug("watchcomic:" + str(modwatchcomic) + " ..comparing to found file: " + str(subname)) - if modwatchcomic.lower() in subname.lower(): + if modwatchcomic.lower() in subname.lower() or altsearchcomic.lower() in subname.lower(): if 'annual' in subname.lower(): #print ("it's an annual - unsure how to proceed") continue diff --git a/mylar/updater.py b/mylar/updater.py index 687b2ba8..a7e195e7 100755 --- a/mylar/updater.py +++ b/mylar/updater.py @@ -208,7 +208,7 @@ def forceRescan(ComicID): # file check to see if issue exists rescan = myDB.action('SELECT * FROM comics WHERE ComicID=?', [ComicID]).fetchone() logger.info(u"Now checking files for " + str(rescan['ComicName']) + " (" + str(rescan['ComicYear']) + ") in " + str(rescan['ComicLocation']) ) - fc = filechecker.listFiles(dir=rescan['ComicLocation'], watchcomic=rescan['ComicName']) + fc = filechecker.listFiles(dir=rescan['ComicLocation'], watchcomic=rescan['ComicName'], AlternateSearch=rescan['AlternateSearch']) iscnt = rescan['Total'] havefiles = 0 fccnt = int(fc['comiccount'])