From 93ac5760a0737cc8ec6c99f76ecfb58a79f54bdc Mon Sep 17 00:00:00 2001 From: AJ Slater Date: Tue, 20 Feb 2024 13:42:37 -0800 Subject: [PATCH] copy volume into issue if issue not available --- NEWS.md | 2 ++ comicfn2dict/parse.py | 4 ++++ tests/comic_filenames.py | 23 +++++++++++++++-------- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/NEWS.md b/NEWS.md index e2c0973..4037888 100644 --- a/NEWS.md +++ b/NEWS.md @@ -6,6 +6,8 @@ either issue, year or volume. - Issue numbers that lead with a '#' character may start with alphabetical characters. +- If volume is parsed, but issue number is not, the issue number is copied from + the volume number. - ComicFilenameParser and ComicFilenameSerializer classes are available as well as the old function API. diff --git a/comicfn2dict/parse.py b/comicfn2dict/parse.py index 8f72170..77c8d5a 100644 --- a/comicfn2dict/parse.py +++ b/comicfn2dict/parse.py @@ -213,6 +213,10 @@ class ComicFilenameParser: self._parse_item(ISSUE_ANYWHERE_RE) self._log_progress("AFTER ISSUE PICKUP") + # Copy volume into issue if it's all we have. + if "issue" not in self.metadata and "volume" in self.metadata: + self.metadata["issue"] = self.metadata["volume"] + self._add_remainders() return self.metadata diff --git a/tests/comic_filenames.py b/tests/comic_filenames.py index 74e04db..db4238e 100644 --- a/tests/comic_filenames.py +++ b/tests/comic_filenames.py @@ -22,6 +22,7 @@ TEST_COMIC_FIELDS_VOL = { TEST_COMIC_VOL_ONLY = { "series": "Long Series Name", "volume": "1", + "issue": "1", "title": "Title", "original_format": "TPB", "year": "2000", @@ -74,6 +75,7 @@ FNS = { "Arkenstone Vol. 01 - The Smell of Burnt Toast (2020) (digital) (My-brother).cbr": { "series": "Arkenstone", "volume": "01", + "issue": "01", "year": "2020", "ext": "cbr", "scan_info": "My-brother", @@ -83,6 +85,7 @@ FNS = { "The_Arkenstone_v03_(2002)_(Digital)_(DR_&_Quenya-Elves).cbr": { "series": "The Arkenstone", "volume": "03", + "issue": "03", "year": "2002", "ext": "cbr", "scan_info": "DR & Quenya-Elves", @@ -101,6 +104,7 @@ FNS = { "Kartalk Library Edition v01 (1992) (digital) (Son of Ultron-Empire).cbr": { "series": "Kartalk Library Edition", "volume": "01", + "issue": "01", "year": "1992", "ext": "cbr", "original_format": "digital", @@ -109,6 +113,7 @@ FNS = { "Kind of Deadly v02 - Last Bullet (2006) (Digital) (Zone-Empire).cbr": { "series": "Kind of Deadly", "volume": "02", + "issue": "02", "year": "2006", "ext": "cbr", "original_format": "Digital", @@ -142,6 +147,7 @@ FNS = { "Jeremy John v01 - Uninterested! (2007) (Digital) (Asgard-Empire).cbr": { "series": "Jeremy John", "volume": "01", + "issue": "01", "year": "2007", "ext": "cbr", "original_format": "Digital", @@ -168,6 +174,7 @@ FNS = { "Darkwad by Carlos Zemo v01 - Knuckle Fight (2009) (Digital) (Zone-Empire).cbr": { "series": "Darkwad by Carlos Zemo", "volume": "01", + "issue": "01", "year": "2009", "ext": "cbr", "title": "Knuckle Fight", @@ -314,6 +321,14 @@ FNS.update( "series": "Free Comic Book Day - Avengers Hulk", "year": "2021", }, + # CT assumes the volume is also the issue number if it can't find an issue number + "Avengers By Brian Michael Bendis volume 03 (2013).cbz": { + "ext": "cbz", + "issue": "03", + "series": "Avengers By Brian Michael Bendis", + "volume": "03", + "year": "2013", + }, } ) LATER = { @@ -338,14 +353,6 @@ LATER = { # Not examined yet. FNS.update( { - # CT assumes the volume is also the issue number if it can't find an issue number - "Avengers By Brian Michael Bendis volume 03 (2013).cbz": { - "ext": "cbz", - "issue": "3", - "series": "Avengers By Brian Michael Bendis", - "volume": "03", - "year": "2013", - }, # CT has extra processing to re-attach the year in this case "Blade Runner Free Comic Book Day 2021 (2021).cbr": { "ext": "cbr",