Merge pull request #3238 from rain0r/2790-acousticbrainz

Fix for #2790 - acousticbrainz: Really small float values are stored as strings
This commit is contained in:
Adrian Sampson 2019-04-30 11:48:41 -04:00
commit b6ac986526
2 changed files with 31 additions and 3 deletions

View file

@ -173,14 +173,17 @@ class Id(Integer):
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):

View file

@ -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 @@ ABSCHEME = {
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__()