From b2d386948821b1fd8503d4781b18e9a2da57e635 Mon Sep 17 00:00:00 2001 From: Timmy Welch Date: Sat, 17 Feb 2024 17:40:21 -0800 Subject: [PATCH] Update filerenaming for web_links Ensure the j specifier in MetadataFormatter converts to str before joining Add a web_link variable to the filerenamer --- comictaggerlib/filerenamer.py | 6 +++++- testing/filenames.py | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/comictaggerlib/filerenamer.py b/comictaggerlib/filerenamer.py index ad52062..1760e19 100644 --- a/comictaggerlib/filerenamer.py +++ b/comictaggerlib/filerenamer.py @@ -69,7 +69,7 @@ class MetadataFormatter(string.Formatter): if conversion == "t": return str(value).title() if conversion == "j": - return ", ".join(list(value)) + return ", ".join(list(str(v) for v in value)) return cast(str, super().convert_field(value, conversion)) def handle_replacements(self, string: str, replacements: list[Replacement]) -> str: @@ -218,6 +218,10 @@ class FileRenamer: fmt = MetadataFormatter(self.smart_cleanup, platform=self.platform, replacements=self.replacements) md_dict = vars(md) + md_dict["web_link"] = "" + if md.web_links: + md_dict["web_link"] = md.web_links[0] + md_dict["issue"] = IssueString(md.issue).as_string(pad=self.issue_zero_padding) for role in ["writer", "penciller", "inker", "colorist", "letterer", "cover artist", "editor"]: md_dict[role] = md.get_primary_credit(role) diff --git a/testing/filenames.py b/testing/filenames.py index ad0eb4e..399f2a8 100644 --- a/testing/filenames.py +++ b/testing/filenames.py @@ -1152,6 +1152,13 @@ rnames = [ "Anda's Game https:--comicvine.gamespot.com-cory-doctorows-futuristic-tales-of-the-here-and-no-4000-140529-.cbz", does_not_raise(), ), + ( + "{title} {web_links!j}", # Test that join forces str conversion + False, + "Linux", + "Anda's Game https:--comicvine.gamespot.com-cory-doctorows-futuristic-tales-of-the-here-and-no-4000-140529-.cbz", + does_not_raise(), + ), ( "{series}:{title} #{issue} ({year})", # on windows the ':' is replaced False,