add track mapping to album_distance plugin method

This commit is contained in:
Adrian Sampson 2012-08-03 18:12:58 -07:00
parent 8a63a381b4
commit 96de3ee400
4 changed files with 12 additions and 10 deletions

View file

@ -289,7 +289,7 @@ def distance(items, album_info, mapping):
dist_max += UNMATCHED_WEIGHT
# Plugin distances.
plugin_d, plugin_dm = plugins.album_distance(items, album_info)
plugin_d, plugin_dm = plugins.album_distance(items, album_info, mapping)
dist += plugin_d
dist_max += plugin_dm

View file

@ -57,7 +57,7 @@ class BeetsPlugin(object):
"""
return 0.0, 0.0
def album_distance(self, items, info):
def album_distance(self, items, album_info, mapping):
"""Should return a (distance, distance_max) pair to be added
to the distance value for every album-level comparison.
"""
@ -211,12 +211,12 @@ def track_distance(item, info):
dist_max += dm
return dist, dist_max
def album_distance(items, info):
def album_distance(items, album_info, mapping):
"""Returns the album distance calculated by plugins."""
dist = 0.0
dist_max = 0.0
for plugin in find_plugins():
d, dm = plugin.album_distance(items, info)
d, dm = plugin.album_distance(items, album_info, mapping)
dist += d
dist_max += dm
return dist, dist_max

View file

@ -6,6 +6,7 @@ Changelog
* :doc:`/plugins/fetchart`: Fix a bug where cover art filenames could lack
a ``.jpg`` extension.
* Add the track mapping dictionary to the ``album_distance`` plugin function.
1.0b15 (July 26, 2012)
----------------------

View file

@ -167,14 +167,15 @@ methods on the plugin class:
* ``track_distance(self, item, info)``: adds a component to the distance
function (i.e., the similarity metric) for individual tracks. ``item`` is the
track to be matched (and Item object) and ``info`` is the MusicBrainz track
entry that is proposed as a match. Should return a ``(dist, dist_max)`` pair
track to be matched (an Item object) and ``info`` is the TrackInfo object
that is proposed as a match. Should return a ``(dist, dist_max)`` pair
of floats indicating the distance.
* ``album_distance(self, items, info)``: like the above, but compares a list of
items (representing an album) to an album-level MusicBrainz entry. Should
only consider album-level metadata (e.g., the artist name and album title) and
should not duplicate the factors considered by ``track_distance``.
* ``album_distance(self, items, album_info, mapping)``: like the above, but
compares a list of items (representing an album) to an album-level MusicBrainz
entry. ``items`` is a list of Item objects; ``album_info`` is an AlbumInfo
object; and ``mapping`` is a dictionary that maps Items to their corresponding
TrackInfo objects.
* ``candidates(self, items)``: given a list of items comprised by an album to be
matched, return a list of ``AlbumInfo`` objects for candidate albums to be