diff --git a/beets/dbcore/types.py b/beets/dbcore/types.py index 935d03870..bc923f747 100644 --- a/beets/dbcore/types.py +++ b/beets/dbcore/types.py @@ -183,6 +183,17 @@ class Float(Type): return u'{0:.1f}'.format(value or 0.0) +class PaddedFloat(Integer): + """A float field that is formatted with a given number of digits, + padded with zeroes. + """ + def __init__(self, digits): + self.digits = digits + + def format(self, value): + return u'{0:0{1}d}'.format(value or 0, self.digits) + + class NullFloat(Float): """Same as `Float`, but does not normalize `None` to `0.0`. """ diff --git a/beetsplug/acousticbrainz.py b/beetsplug/acousticbrainz.py index 3a6db7d4e..9c1eb7ce5 100644 --- a/beetsplug/acousticbrainz.py +++ b/beetsplug/acousticbrainz.py @@ -117,13 +117,13 @@ class AcousticPlugin(plugins.BeetsPlugin): 'genre_rosamerica': types.STRING, 'initial_key': types.STRING, 'key_strength': types.FLOAT, - 'mood_acoustic': types.FLOAT, - 'mood_aggressive': types.FLOAT, - 'mood_electronic': types.FLOAT, - 'mood_happy': types.FLOAT, - 'mood_party': types.FLOAT, - 'mood_relaxed': types.FLOAT, - 'mood_sad': types.FLOAT, + 'mood_acoustic': types.PaddedInt(6), + 'mood_aggressive': types.PaddedInt(6), + 'mood_electronic': types.PaddedInt(6), + 'mood_happy': types.PaddedInt(6), + 'mood_party': types.PaddedInt(6), + 'mood_relaxed': types.PaddedInt(6), + 'mood_sad': types.PaddedInt(6), 'rhythm': types.FLOAT, 'tonal': types.FLOAT, 'voice_instrumental': types.STRING,