From 114a0bb615ed904302f55acabb99ffcc4f0f2ed9 Mon Sep 17 00:00:00 2001 From: Timmy Welch Date: Thu, 12 Oct 2023 01:26:31 -0700 Subject: [PATCH] Fix parsing '&' with the "complicated" filename parser --- comicapi/filenameparser.py | 7 +++++-- testing/filenames.py | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/comicapi/filenameparser.py b/comicapi/filenameparser.py index e7a86bf..7741019 100644 --- a/comicapi/filenameparser.py +++ b/comicapi/filenameparser.py @@ -1237,8 +1237,11 @@ def join_title(lst: list[filenamelexer.Item]) -> str: if lst[i + 1].typ in [filenamelexer.ItemType.Operator, filenamelexer.ItemType.Symbol]: # exept if followed by a dollarsign if not ( - lst[i].typ in [filenamelexer.ItemType.Number, filenamelexer.ItemType.IssueNumber] - and lst[i + 1].val == "$" + ( + lst[i].typ in [filenamelexer.ItemType.Number, filenamelexer.ItemType.IssueNumber] + and lst[i + 1].val == "$" + ) + or lst[i + 1].val == "&" ): continue diff --git a/testing/filenames.py b/testing/filenames.py index aaba1a4..3c1812f 100644 --- a/testing/filenames.py +++ b/testing/filenames.py @@ -23,6 +23,21 @@ datadir = pathlib.Path(__file__).parent / "data" cbz_path = datadir / "Cory Doctorow's Futuristic Tales of the Here and Now #001 - Anda's Game (2007).cbz" names = [ + ( + "Drystan & Esyllt #3", + "Shortened word followed by a number eg No. 13, Mr. 13", + { + "issue": "3", + "series": "Drystan & Esyllt", + "title": "", + "volume": "", + "year": "", + "remainder": "", + "issue_count": "", + "alternate": "", + }, + (False, False), + ), ( "Michel Vaillant #5 Nr. 13 aan de start", "Shortened word followed by a number eg No. 13, Mr. 13",