diff --git a/beets/library/models.py b/beets/library/models.py index 7d81720142..623ccacaa2 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,9 @@ 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, + 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 92e4f2f8f4..ca34f145e1 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 = ( + 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 8316ff9a3c..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