discogs: penalty only for matches from discogs

Otherwise, this was penalizing all album matches.

This also applies the same treatment as the previous commit: only load the
config at run time (at the expense of code clutter).
This commit is contained in:
Adrian Sampson 2013-05-28 21:25:28 -07:00
parent 17ae1e90c5
commit 480fa80e47

View file

@ -28,10 +28,6 @@ import time
log = logging.getLogger('beets')
# Distance parameters.
DISCOGS_SOURCE_WEIGHT = config['discogs']['source_weight'].as_number()
SOURCE_WEIGHT = config['match']['weight']['source'].as_number()
# Silence spurious INFO log lines generated by urllib3.
urllib3_logger = logging.getLogger('requests.packages.urllib3')
urllib3_logger.setLevel(logging.CRITICAL)
@ -44,7 +40,12 @@ class DiscogsPlugin(BeetsPlugin):
def album_distance(self, items, album_info, mapping):
"""Returns the discogs source weight and the maximum source weight.
"""
return DISCOGS_SOURCE_WEIGHT * SOURCE_WEIGHT, SOURCE_WEIGHT
if album_info.data_source == 'Discogs':
return config['discogs']['source_weight'].as_number() * \
config['match']['weight']['source'].as_number(), \
config['match']['weight']['source'].as_number()
else:
return 0.0, 0.0
def candidates(self, items, artist, album, va_likely):
"""Returns a list of AlbumInfo objects for discogs search results