mirror of
https://github.com/beetbox/beets.git
synced 2025-12-27 19:12:40 +01:00
fix "beet modify" for date fields (GC-449)
This is fixed by allowing MediaFiles to convert strings to integers on assignment. An eventual complete fix will perform these type conversions in the Item interface.
This commit is contained in:
parent
b1b4b39db7
commit
244ffd71e2
5 changed files with 15 additions and 2 deletions
|
|
@ -255,7 +255,7 @@ class Packed(object):
|
|||
field_lengths = [4, 2, 2] # YYYY-MM-DD
|
||||
elems = []
|
||||
for i, item in enumerate(new_items):
|
||||
elems.append( ('%0' + str(field_lengths[i]) + 'i') % item )
|
||||
elems.append('{0:0{1}}'.format(int(item), field_lengths[i]))
|
||||
self.items = '-'.join(elems)
|
||||
elif self.packstyle == packing.TUPLE:
|
||||
self.items = new_items
|
||||
|
|
|
|||
|
|
@ -529,7 +529,7 @@ def cpu_count():
|
|||
"""Return the number of hardware thread contexts (cores or SMT
|
||||
threads) in the system.
|
||||
"""
|
||||
# Adapted from observing the soundconverter project:
|
||||
# Adapted from the soundconverter project:
|
||||
# https://github.com/kassoulet/soundconverter
|
||||
if sys.platform == 'win32':
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -51,6 +51,8 @@ Changelog
|
|||
modify files' tags even when they successfully change the database.
|
||||
* Fix a VFS bug leading to a crash in the :doc:`/plugins/bpd` when files had
|
||||
non-ASCII extensions.
|
||||
* Fix for changing date fields (like "year") with the :ref:`modify-cmd`
|
||||
command.
|
||||
* Add a human-readable error message when writing files' tags fails.
|
||||
* Changed plugin loading so that modules can be imported without
|
||||
unintentionally loading the plugins they contain.
|
||||
|
|
|
|||
|
|
@ -164,6 +164,8 @@ You'll be shown a list of the files that will be removed and asked to confirm.
|
|||
By default, this just removes entries from the library database; it doesn't
|
||||
touch the files on disk. To actually delete the files, use ``beet remove -d``.
|
||||
|
||||
.. _modify-cmd:
|
||||
|
||||
modify
|
||||
``````
|
||||
::
|
||||
|
|
|
|||
|
|
@ -196,6 +196,15 @@ class MissingAudioDataTest(unittest.TestCase):
|
|||
del self.mf.mgfile.info.bitrate # Not available directly.
|
||||
self.assertEqual(self.mf.bitrate, 0)
|
||||
|
||||
class TypeTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
path = os.path.join(_common.RSRC, 'full.mp3')
|
||||
self.mf = beets.mediafile.MediaFile(path)
|
||||
|
||||
def test_year_integer_in_string(self):
|
||||
self.mf.year = '2009'
|
||||
self.assertEqual(self.mf.year, 2009)
|
||||
|
||||
def suite():
|
||||
return unittest.TestLoader().loadTestsFromName(__name__)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue