mirror of
https://github.com/beetbox/beets.git
synced 2026-01-04 15:03:22 +01:00
Add Discogs and general source weight penalty (configurable, undocumented).
Discogs (and other individual plugins) should return a penalty between 0.0 and 0.1, which will be multiplied by the general source weight. This allows individual plugins to be weighted against relative to each other, and amplified together against other penalty categories (track, title, etc.)
This commit is contained in:
parent
7700eaee79
commit
35e926a51b
2 changed files with 14 additions and 0 deletions
|
|
@ -73,6 +73,7 @@ match:
|
|||
tracklength: strong
|
||||
tracknumber: strong
|
||||
weight:
|
||||
source: 3.0
|
||||
artist: 3.0
|
||||
album: 3.0
|
||||
track: 1.0
|
||||
|
|
@ -85,3 +86,6 @@ match:
|
|||
track_length_max: 30
|
||||
track_length: 2.0
|
||||
track_id: 5.0
|
||||
|
||||
discogs:
|
||||
source_weight: 0.5
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
"""Adds Discogs album search support to the autotagger. Requires the
|
||||
discogs-client library.
|
||||
"""
|
||||
from beets import config
|
||||
from beets.autotag.hooks import AlbumInfo, TrackInfo
|
||||
from beets.autotag.match import current_metadata, VA_ARTISTS
|
||||
from beets.plugins import BeetsPlugin
|
||||
|
|
@ -27,6 +28,10 @@ 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)
|
||||
|
|
@ -36,6 +41,11 @@ discogs_client.user_agent = 'beets/%s +http://beets.radbox.org/' % \
|
|||
beets.__version__
|
||||
|
||||
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
|
||||
|
||||
def candidates(self, items, artist, album, va_likely):
|
||||
"""Returns a list of AlbumInfo objects for discogs search results
|
||||
matching an album and artist (if not various).
|
||||
|
|
|
|||
Loading…
Reference in a new issue