mirror of
https://github.com/beetbox/beets.git
synced 2025-12-10 10:32:34 +01:00
Fix #1404 by only writing _media_fields
This just makes "date" and "original_date" into ordinary flexible fields, which is probably the way it should be.
This commit is contained in:
parent
6004da7c42
commit
56ca69d63d
2 changed files with 14 additions and 1 deletions
|
|
@ -550,7 +550,7 @@ class Item(LibModel):
|
|||
defaults to the item's path.
|
||||
|
||||
`tags` is a dictionary of additional metadata the should be
|
||||
written to the file.
|
||||
written to the file. (These tags need not be in `_media_fields`.)
|
||||
|
||||
Can raise either a `ReadError` or a `WriteError`.
|
||||
"""
|
||||
|
|
@ -559,17 +559,22 @@ class Item(LibModel):
|
|||
else:
|
||||
path = normpath(path)
|
||||
|
||||
# Get the data to write to the file.
|
||||
item_tags = dict(self)
|
||||
item_tags = {k: v for k, v in item_tags.items()
|
||||
if k in self._media_fields} # Only write media fields.
|
||||
if tags is not None:
|
||||
item_tags.update(tags)
|
||||
plugins.send('write', item=self, path=path, tags=item_tags)
|
||||
|
||||
# Open the file.
|
||||
try:
|
||||
mediafile = MediaFile(syspath(path),
|
||||
id3v23=beets.config['id3v23'].get(bool))
|
||||
except (OSError, IOError, UnreadableFileError) as exc:
|
||||
raise ReadError(self.path, exc)
|
||||
|
||||
# Write the tags to the file.
|
||||
mediafile.update(item_tags)
|
||||
try:
|
||||
mediafile.save()
|
||||
|
|
|
|||
|
|
@ -1058,6 +1058,14 @@ class WriteTest(unittest.TestCase, TestHelper):
|
|||
self.assertNotEqual(item.artist, 'new artist')
|
||||
self.assertEqual(MediaFile(item.path).artist, 'new artist')
|
||||
|
||||
def test_write_date_field(self):
|
||||
# Since `date` is not a MediaField, this should do nothing.
|
||||
item = self.add_item_fixture()
|
||||
clean_year = item.year
|
||||
item.date = 'foo'
|
||||
item.write()
|
||||
self.assertEqual(MediaFile(item.path).year, clean_year)
|
||||
|
||||
|
||||
class ItemReadTest(unittest.TestCase):
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue