diff --git a/beets/autotag/match.py b/beets/autotag/match.py index 7569f0dc8..9e4bc2ad5 100644 --- a/beets/autotag/match.py +++ b/beets/autotag/match.py @@ -144,14 +144,19 @@ def assign_items( } # allow plugins to modify the mapping - new_assign_list = plugins.send("assign_items", mapping=mapping, org_items=items, org_tracks=tracks) - + new_assign_list = plugins.send( + "assign_items", mapping=mapping, org_items=items, org_tracks=tracks + ) + # get the first plugin provided mapping that is a dict and not empty - new_mapping = next((item for item in new_assign_list if isinstance(item, dict) and item), None) + new_mapping = next( + (item for item in new_assign_list if isinstance(item, dict) and item), + None, + ) if new_mapping: # if a plugin provided a mapping, use that instead of the default one mapping = new_mapping - + extra_items = list(set(items) - mapping.keys()) extra_items.sort(key=lambda i: (i.disc, i.track, i.title)) extra_tracks = list(set(tracks) - set(mapping.values())) @@ -401,9 +406,13 @@ def _recommendation( else: # No conclusion. Return immediately. Can't be downgraded any further. # but allow plugins to modify the recommendation - new_rec_list = plugins.send("recommendation", results=results, org_rec=Recommendation.none) + new_rec_list = plugins.send( + "recommendation", results=results, org_rec=Recommendation.none + ) # take the first recommendation from a plugin - if len(new_rec_list) > 0 and isinstance(new_rec_list[0], Recommendation): + if len(new_rec_list) > 0 and isinstance( + new_rec_list[0], Recommendation + ): return new_rec_list[0] return Recommendation.none