Skip to content

Commit

Permalink
Merge pull request #26 from wisp3rwind/pr-explicit-write
Browse files Browse the repository at this point in the history
Explicitly write tags after initial conversion
  • Loading branch information
Thomas Scholtes authored Nov 19, 2018
2 parents 4d8e669 + f099414 commit cf7fadd
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions beetsplug/alternatives.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 15 additions & 0 deletions test/cli_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit cf7fadd

Please sign in to comment.