From 480fa80e47776dbec03ae8ba0a4f0ddb9e38c3a3 Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Tue, 28 May 2013 21:25:28 -0700 Subject: [PATCH] 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). --- beetsplug/discogs.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/beetsplug/discogs.py b/beetsplug/discogs.py index 951c5d593..8d7e59ce7 100644 --- a/beetsplug/discogs.py +++ b/beetsplug/discogs.py @@ -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