diff --git a/beets/autotag/match.py b/beets/autotag/match.py index 8ec6f966d..a0121f293 100644 --- a/beets/autotag/match.py +++ b/beets/autotag/match.py @@ -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 diff --git a/beets/plugins.py b/beets/plugins.py index d6810a35f..0752422e4 100755 --- a/beets/plugins.py +++ b/beets/plugins.py @@ -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 diff --git a/docs/changelog.rst b/docs/changelog.rst index 6f181149d..313645800 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -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) ---------------------- diff --git a/docs/plugins/writing.rst b/docs/plugins/writing.rst index 2947bb4d2..738a56bb4 100644 --- a/docs/plugins/writing.rst +++ b/docs/plugins/writing.rst @@ -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