From f51559e16fef413f34b1e591c88512ef224c9cc1 Mon Sep 17 00:00:00 2001 From: rdy2go <47011689+rdy2go@users.noreply.github.com> Date: Sat, 21 Jun 2025 00:01:01 +0200 Subject: [PATCH 1/3] Fix 'from_scratch': delete all tags before writing new tags to file ## Github Issues Fixes #3706 Related #5165 ## Issue Comment tags are written to file even if option 'from_scratch' is used. The same tags are not written to the file if imported together with other files as album. Therefore 'from_scratch' is not working as described in the documentation. ## Solution 1. Add test: Adapt the function from the 'regular' import class and insert it in the class for the singleton import test. 2. Fix bug : Add check for 'from_scratch' option. If used, clear metadata before applying 'new' metadata with autotag. 3. No documentation change needed. Option now works as described in the documentation. 4. Add changelog. --- beets/importer/tasks.py | 2 ++ docs/changelog.rst | 3 +++ test/test_importer.py | 11 +++++++++++ 3 files changed, 16 insertions(+) diff --git a/beets/importer/tasks.py b/beets/importer/tasks.py index 75f04cf5a..4aa1f8a62 100644 --- a/beets/importer/tasks.py +++ b/beets/importer/tasks.py @@ -690,6 +690,8 @@ class SingletonImportTask(ImportTask): return [self.item] def apply_metadata(self): + if config["import"]["from_scratch"]: + self.item.clear() autotag.apply_item_metadata(self.item, self.match.info) def _emit_imported(self, lib): diff --git a/docs/changelog.rst b/docs/changelog.rst index 88b82e4da..bf830bade 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -39,6 +39,9 @@ Bug fixes: :bug:`5797` * :doc:`plugins/musicbrainz`: Fix the MusicBrainz search not taking into account the album/recording aliases +* :doc:`reference/cli`: Fix 'from_scratch' option for singleton imports: delete + all (old) metadata when new metadata is applied. + :bug:`3706` For packagers: diff --git a/test/test_importer.py b/test/test_importer.py index 9bb0e8a63..2fa5b32d3 100644 --- a/test/test_importer.py +++ b/test/test_importer.py @@ -315,6 +315,17 @@ class ImportSingletonTest(AutotagImportTestCase): self.importer.run() self.assert_file_in_lib(b"singletons", b"Applied Track 1.mp3") + def test_apply_from_scratch_removes_other_metadata(self): + config["import"]["from_scratch"] = True + + for mediafile in self.import_media: + mediafile.comments = "Tag Comment" + mediafile.save() + + self.importer.add_choice(importer.Action.APPLY) + self.importer.run() + assert self.lib.items().get().comments == "" + def test_skip_does_not_add_first_track(self): self.importer.add_choice(importer.Action.SKIP) self.importer.run() From 2c240b4788096c2c41b6a662ff59f05186206f47 Mon Sep 17 00:00:00 2001 From: rdy2go <47011689+rdy2go@users.noreply.github.com> Date: Sat, 2 Aug 2025 21:55:30 +0200 Subject: [PATCH 2/3] fix indentation --- docs/changelog.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 49be459dd..04dbb1cd9 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -52,7 +52,7 @@ Bug fixes: * :doc:`reference/cli`: Fix 'from_scratch' option for singleton imports: delete all (old) metadata when new metadata is applied. :bug:`3706` - * :doc:`/plugins/spotify`: Fix the issue with that every query to spotify was +* :doc:`/plugins/spotify`: Fix the issue with that every query to spotify was ascii encoded. This resulted in bad matches for queries that contained special e.g. non latin characters as 盗作. If you want to keep the legacy behavior set the config option ``spotify.search_query_ascii: yes``. From fdfeb3507692ab15d6fd4299171e6e1c8191c185 Mon Sep 17 00:00:00 2001 From: rdy2go <47011689+rdy2go@users.noreply.github.com> Date: Thu, 15 Jan 2026 16:07:54 +0100 Subject: [PATCH 3/3] add changelog for and to resolve PR #5828 --- docs/changelog.rst | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 9f30ffd9a..84bb0cc02 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -90,6 +90,8 @@ Bug fixes: - :doc:`/plugins/ftintitle`: Fixed artist name splitting to prioritize explicit featuring tokens (feat, ft, featuring) over generic separators (&, and), preventing incorrect splits when both are present. +- :doc:`reference/cli`: Fix 'from_scratch' option for singleton imports: delete + all (old) metadata when new metadata is applied. :bug:`3706` For plugin developers: @@ -292,11 +294,8 @@ Bug fixes: - Fix ``HiddenFileTest`` by using ``bytestring_path()``. - tests: Fix tests failing without ``langdetect`` (by making it required). :bug:`5797` -- :doc:`plugins/musicbrainz`: Fix the MusicBrainz search not taking into - account the album/recording aliases -- :doc:`reference/cli`: Fix 'from_scratch' option for singleton imports: delete - all (old) metadata when new metadata is applied. - :bug:`3706` +- :doc:`plugins/musicbrainz`: Fix the MusicBrainz search not taking into account + the album/recording aliases - :doc:`/plugins/spotify`: Fix the issue with that every query to spotify was ascii encoded. This resulted in bad matches for queries that contained special e.g. non latin characters as 盗作. If you want to keep the legacy behavior set