From ea2bbde7934cbac2aa4c92ab7e67917bdd7ae046 Mon Sep 17 00:00:00 2001 From: wisp3rwind <17089248+wisp3rwind@users.noreply.github.com> Date: Tue, 2 Oct 2018 23:30:28 +0200 Subject: [PATCH 1/3] Fix: Explicitly write tags after conversion. Else, the tags of newly added files could be incomplete/missing depending on the encoding program. --- beetsplug/alternatives.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/beetsplug/alternatives.py b/beetsplug/alternatives.py index 6ff89f3..8b4d623 100644 --- a/beetsplug/alternatives.py +++ b/beetsplug/alternatives.py @@ -268,6 +268,8 @@ def _convert(item): if self.should_transcode(item): self._encode(self.convert_cmd, item.path, dest) + # Don't rely on the converter to write correct/complete tags. + item.write(path=dest) else: self._log.debug(u'copying {0}'.format(displayable_path(dest))) util.copy(item.path, dest, replace=True) From ee888d766f59bea6bf66094c7a7994e5e1d3d217 Mon Sep 17 00:00:00 2001 From: wisp3rwind <17089248+wisp3rwind@users.noreply.github.com> Date: Tue, 13 Nov 2018 00:15:24 +0100 Subject: [PATCH 2/3] Changelog: explicit tag write --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4abfdb7..cbe35f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ Change Log * Python 3 support (Python 2.7 continuous to be supported) * Support the format aliases defined by the convert plugin ('wma' and 'vorbis' with current beets) +* Bugfix: Explicitly write tags after encoding instead of relying on the + encoder to do so ## v0.8.2 - 2015-05-31 * Fix a bug that made the plugin crash when reading unicode strings From f09941496a39040a2ba66421d799f9a6892e8e2f Mon Sep 17 00:00:00 2001 From: wisp3rwind <17089248+wisp3rwind@users.noreply.github.com> Date: Sat, 17 Nov 2018 20:13:16 +0100 Subject: [PATCH 3/3] Test for explicitly writing tags Code copied verbatim from a comment by @geigerzaehler --- test/cli_test.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/cli_test.py b/test/cli_test.py index 43b1244..5fd3a9d 100644 --- a/test/cli_test.py +++ b/test/cli_test.py @@ -323,6 +323,21 @@ def test_convert_and_embed(self): item = album.items().get() self.assertHasEmbeddedArtwork(self.get_path(item)) + def test_convert_write_tags(self): + item = self.add_track(myexternal='true', format='mp4', title=u'TITLE') + + # We "convert" by copying the file. Setting the title simulates + # a badly behaved converter + mediafile_converted = MediaFile(syspath(item.path)) + mediafile_converted.title = u'WRONG' + mediafile_converted.save() + + self.runcli('alt', 'update', 'myexternal') + item.load() + + alt_mediafile = MediaFile(syspath(self.get_path(item))) + self.assertEqual(alt_mediafile.title, u'TITLE') + def test_skip_convert_for_same_format(self): item = self.add_track(myexternal='true') item['format'] = 'OGG'