From 5574280ad68048805b2936dab07d3a810b926d2d Mon Sep 17 00:00:00 2001 From: fcanc Date: Thu, 12 Feb 2015 19:09:33 +0100 Subject: [PATCH] Filename parser tweaks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes the Scan Info tag being left blank when the filename doesn’t provide an issue number. --- comictaggerlib/filenameparser.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/comictaggerlib/filenameparser.py b/comictaggerlib/filenameparser.py index 6f3aa05..5659f02 100644 --- a/comictaggerlib/filenameparser.py +++ b/comictaggerlib/filenameparser.py @@ -222,7 +222,7 @@ class FileNameParser: year = re.sub("[^0-9]", "", year) return year - def getRemainder( self, filename, year, count, issue_end ): + def getRemainder( self, filename, year, count, volume, issue_end ): #make a guess at where the the non-interesting stuff begins remainder = "" @@ -235,12 +235,15 @@ class FileNameParser: remainder = filename[issue_end:] remainder = self.fixSpaces(remainder, remove_dashes=False) + if volume != "": + remainder = remainder.replace("Vol."+volume,"",1) if year != "": remainder = remainder.replace(year,"",1) if count != "": remainder = remainder.replace("of "+count,"",1) remainder = remainder.replace("()","") + remainder = remainder.replace(" "," ") # cleans some whitespace mess return remainder.strip() @@ -264,9 +267,14 @@ class FileNameParser: self.issue, issue_start, issue_end = self.getIssueNumber(filename) self.series, self.volume = self.getSeriesName(filename, issue_start) + + # provides proper value when the filename doesn't have a issue number + if issue_end == 0: + issue_end=len(self.series) + self.year = self.getYear(filename, issue_end) self.issue_count = self.getIssueCount(filename, issue_end) - self.remainder = self.getRemainder( filename, self.year, self.issue_count, issue_end ) + self.remainder = self.getRemainder( filename, self.year, self.issue_count, self.volume, issue_end ) if self.issue != "": # strip off leading zeros