Fix singleton candidate ordering when using MB id

* Fix an issue that caused the candidates for a singleton not to be
returned ordered by distance from autotag.match.tag_item(), when
searching multiple MusicBrainz ids (ie. several "--musicbrainzid"
arguments). The candidates are now explicitely reordered before being
returned and before the recommendation is computed.
* Fix test_importer.mocked_get_recording_by_id so that the artist is
nested properly (and as a result, taken into account into the distance
calculations).
This commit is contained in:
Diego Moreda 2016-01-20 20:22:48 +01:00
parent 4e5ddac949
commit 39cf4651b8
2 changed files with 10 additions and 10 deletions

View file

@ -467,16 +467,16 @@ def tag_item(item, search_artist=None, search_title=None,
candidates[track_info.track_id] = \
hooks.TrackMatch(dist, track_info)
# If this is a good match, then don't keep searching.
rec = _recommendation(candidates.values())
rec = _recommendation(sorted(candidates.itervalues()))
if rec == Recommendation.strong and \
not config['import']['timid']:
log.debug(u'Track ID match.')
return candidates.values(), rec
return sorted(candidates.itervalues()), rec
# If we're searching by ID, don't proceed.
if search_ids != []:
if candidates:
return candidates.values(), rec
return sorted(candidates.itervalues()), rec
else:
return [], Recommendation.none

View file

@ -1844,13 +1844,13 @@ def mocked_get_recording_by_id(id_, includes=[], release_status=[],
'title': releases[id_][0],
'id': id_,
'length': 59,
},
'artist-credit': [{
'artist': {
'name': releases[id_][1],
'id': 'some-id',
},
}],
'artist-credit': [{
'artist': {
'name': releases[id_][1],
'id': 'some-id',
},
}],
}
}