From efc7b1c8dd98723a9ca94ca3e206e36565e11c54 Mon Sep 17 00:00:00 2001 From: Ognyan Moore Date: Fri, 17 Oct 2025 22:19:44 +0300 Subject: [PATCH 1/3] Use new format in determining destination. When figuring out what the filepath should be for the converted file, we pass along the new item `fmt` property. --- beets/library/models.py | 3 ++- beetsplug/convert.py | 12 +++++++++++- docs/changelog.rst | 2 ++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/beets/library/models.py b/beets/library/models.py index 7d81720142..e83973d67c 100644 --- a/beets/library/models.py +++ b/beets/library/models.py @@ -1223,6 +1223,7 @@ def destination( relative_to_libdir: bool = False, basedir: bytes | None = None, path_formats: list[PathFormat] | None = None, + extension: str | None = None, ) -> bytes: """Return the path in the library directory designated for the item (i.e., where the file ought to be). @@ -1262,7 +1263,7 @@ def destination( subpath = util.asciify_path(subpath) lib_path_str, fallback = util.legalize_path( - subpath, self.db.replacements, self.filepath.suffix + subpath, self.db.replacements, extension or self.filepath.suffix ) if fallback: # Print an error message if legalization fell back to diff --git a/beetsplug/convert.py b/beetsplug/convert.py index 92e4f2f8f4..8cb1b861f7 100644 --- a/beetsplug/convert.py +++ b/beetsplug/convert.py @@ -394,8 +394,18 @@ def should_transcode(self, item: Item) -> bool: return self.fmt != item.format.lower() def get_item_destination(self, item: Item) -> bytes: + extension = ( + f".{os.fsdecode(self.command.ext)}" + if ( + self.should_transcode(item) + and not self.config["keep_new"].get(bool) + ) + else None + ) return item.destination( - basedir=self.dest, path_formats=self.path_formats + basedir=self.dest, + path_formats=self.path_formats, + extension=extension, ) @pipeline.mutator_stage diff --git a/docs/changelog.rst b/docs/changelog.rst index 096a35a6db..e5aaf26438 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -95,6 +95,8 @@ Bug fixes valid date/time string" error instead of crashing with an uncaught ``KeyError``. A ``|`` was being accepted as a relative-date unit due to a regular expression character-class typo. +- Fixed convert plugin not taking into account the new format when determining + the target path. :bug:`1360` .. For plugin developers From dadfd73039e4914f04257ef61198d65bfa3b78c0 Mon Sep 17 00:00:00 2001 From: Ognyan Moore Date: Sat, 27 Jun 2026 10:07:41 -0400 Subject: [PATCH 2/3] pass in extension, not suffix --- beets/library/models.py | 4 +++- beetsplug/convert.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/beets/library/models.py b/beets/library/models.py index e83973d67c..623ccacaa2 100644 --- a/beets/library/models.py +++ b/beets/library/models.py @@ -1263,7 +1263,9 @@ def destination( subpath = util.asciify_path(subpath) lib_path_str, fallback = util.legalize_path( - subpath, self.db.replacements, extension or self.filepath.suffix + subpath, + self.db.replacements, + f".{extension}" if extension else self.filepath.suffix, ) if fallback: # Print an error message if legalization fell back to diff --git a/beetsplug/convert.py b/beetsplug/convert.py index 8cb1b861f7..ca34f145e1 100644 --- a/beetsplug/convert.py +++ b/beetsplug/convert.py @@ -395,7 +395,7 @@ def should_transcode(self, item: Item) -> bool: def get_item_destination(self, item: Item) -> bytes: extension = ( - f".{os.fsdecode(self.command.ext)}" + os.fsdecode(self.command.ext) if ( self.should_transcode(item) and not self.config["keep_new"].get(bool) From fa05c955ca3f02de8e511b3c79b7dd5bbc8b2b99 Mon Sep 17 00:00:00 2001 From: Ognyan Moore Date: Thu, 30 Jul 2026 15:35:21 -0400 Subject: [PATCH 3/3] Move changelog message to unreleased section. --- docs/changelog.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 6e728ebef9..de39d47f5b 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -30,6 +30,8 @@ Bug fixes - :doc:`plugins/lyrics`: ``beet lyrics`` no longer crashes with an ``AttributeError`` on tracks that have no stored lyrics when ``force`` is enabled; a missing lyrics body is now treated as empty text. :bug:`6860` +- Fixed convert plugin not taking into account the new format when determining + the target path. :bug:`1360` .. For plugin developers @@ -136,8 +138,6 @@ Bug fixes valid date/time string" error instead of crashing with an uncaught ``KeyError``. A ``|`` was being accepted as a relative-date unit due to a regular expression character-class typo. -- Fixed convert plugin not taking into account the new format when determining - the target path. :bug:`1360` .. For plugin developers