diff --git a/beets/dbcore/types.py b/beets/dbcore/types.py index 935d03870a..e08b417a74 100644 --- a/beets/dbcore/types.py +++ b/beets/dbcore/types.py @@ -173,14 +173,17 @@ def __init__(self, primary=True): class Float(Type): - """A basic floating-point type. + """A basic floating-point type. Supports padding. """ sql = u'REAL' query = query.NumericQuery model_type = float + def __init__(self, digits=1): + self.digits = digits + def format(self, value): - return u'{0:.1f}'.format(value or 0.0) + return u'{0:.{1}f}'.format(value or 0, self.digits) class NullFloat(Float): diff --git a/beetsplug/acousticbrainz.py b/beetsplug/acousticbrainz.py index f4960c301e..01f3ac6acf 100644 --- a/beetsplug/acousticbrainz.py +++ b/beetsplug/acousticbrainz.py @@ -17,10 +17,12 @@ """ from __future__ import division, absolute_import, print_function +from collections import defaultdict + import requests -from collections import defaultdict from beets import plugins, ui +from beets.dbcore import types ACOUSTIC_BASE = "https://acousticbrainz.org/" LEVELS = ["/low-level", "/high-level"] @@ -104,6 +106,29 @@ class AcousticPlugin(plugins.BeetsPlugin): + item_types = { + 'average_loudness': types.Float(6), + 'chords_changes_rate': types.Float(6), + 'chords_key': types.STRING, + 'chords_number_rate': types.Float(6), + 'chords_scale': types.STRING, + 'danceable': types.Float(6), + 'gender': types.STRING, + 'genre_rosamerica': types.STRING, + 'initial_key': types.STRING, + 'key_strength': types.Float(6), + 'mood_acoustic': types.Float(6), + 'mood_aggressive': types.Float(6), + 'mood_electronic': types.Float(6), + 'mood_happy': types.Float(6), + 'mood_party': types.Float(6), + 'mood_relaxed': types.Float(6), + 'mood_sad': types.Float(6), + 'rhythm': types.Float(6), + 'tonal': types.Float(6), + 'voice_instrumental': types.STRING, + } + def __init__(self): super(AcousticPlugin, self).__init__()