# Highlight weight-applying plugins at candidate selection

**URL:** <https://discourse.beets.io/t/highlight-weight-applying-plugins-at-candidate-selection/601>\
**Category:** Help\
**Created:** [January 24, 2019, 7:42pm UTC](https://discourse.beets.io/t/highlight-weight-applying-plugins-at-candidate-selection/601 "2019-01-24T19:42:31Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![8h2a](https://avatars.discourse-cdn.com/v4/letter/8/4491bb/32.png) [@8h2a](https://discourse.beets.io/u/8h2a)\
**Post date:** [January 24, 2019, 7:42pm UTC](https://discourse.beets.io/t/highlight-weight-applying-plugins-at-candidate-selection/601/1 "2019-01-24T19:42:31Z")

</div>

Is there a way, during import when the cadidates list is shown, to display which plugin added a positive/neutral/negative weight (red/green colors + plugin names?) and also to show which plugin(s) added a particular candidate?  
For example, if I have a plugin that i trust more than others then I want to know if this plugin added its weight to certain candidates or if it added new candidates.

If this isn’t currently possible, could anyone point me in the right direction so that I can make this possible?

---

<div class="post-metadata">

**Author:** ![adrian](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.beets.io/adrian/32/4_2.png) [@adrian](https://discourse.beets.io/u/adrian)\
**Post date:** [January 24, 2019, 8:51pm UTC](https://discourse.beets.io/t/highlight-weight-applying-plugins-at-candidate-selection/601/2 "2019-01-24T20:51:59Z")

</div>

Not currently, no! In fact, while I’m definitely having a slow day, I can’t at the moment think of any plugins we currently have that can affect the matching weight. There is `chroma`, which provides MBIDs—that currently shows up as `id` in the list. Did you have a specific plugin in mind?

---

<div class="post-metadata">

**Author:** ![8h2a](https://avatars.discourse-cdn.com/v4/letter/8/4491bb/32.png) [@8h2a](https://discourse.beets.io/u/8h2a)\
**Post date:** [January 24, 2019, 9:13pm UTC](https://discourse.beets.io/t/highlight-weight-applying-plugins-at-candidate-selection/601/3 "2019-01-24T21:13:26Z")

</div>

Well, there is my own plugin [https://github.com/8h2a/beets-barcode](https://github.com/8h2a/beets-barcode).  
In the case of a barcode, I know that this is exactly the correct release and I want to know whenever that plugin favours a specific candidate.  
Other than that, only the `chroma` plugin comes to mind atm.  
I can see that this might be a bit of a special use-case.  
I will just try and figure out if I can add this information to `disambig_string`.

(Also I have at least one more plugin planned that would also change the weight and would benefit from such a UI change)

---

<div class="post-metadata">

**Author:** ![adrian](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.beets.io/adrian/32/4_2.png) [@adrian](https://discourse.beets.io/u/adrian)\
**Post date:** [January 24, 2019, 11:22pm UTC](https://discourse.beets.io/t/highlight-weight-applying-plugins-at-candidate-selection/601/4 "2019-01-24T23:22:05Z")

</div>

Got it! Actually, this should be happening already—it just might not be apparent. I see you’re using the distance key `album_id`:

> <https://github.com/8h2a/beets-barcode/blob/a21c0ca333306c254f0d8a5c60301423d802b0e3/beetsplug/barcode.py#L215>

Here’s the code for generating that penalty string:

> <https://github.com/beetbox/beets/blob/6d020e3d2ba675b1e4a21e8c1b753ec88134ca4f/beets/ui/commands.py#L198-L211>

As you can see, it somewhat naively strips off prefixes from all the keys. So when your penalty is triggered, it’s just showing “id”. Maybe it would make sense to just use a different name for the penalty?

---

<div class="post-metadata">

**Author:** ![8h2a](https://avatars.discourse-cdn.com/v4/letter/8/4491bb/32.png) [@8h2a](https://discourse.beets.io/u/8h2a)\
**Post date:** [January 24, 2019, 11:55pm UTC](https://discourse.beets.io/t/highlight-weight-applying-plugins-at-candidate-selection/601/5 "2019-01-24T23:55:44Z")

</div>

Oh, I see.  
I suppose that would solve my problem as well.  
I initially didn’t know what that string did and used `album_id` because I thought it would fit well.  
Thank you very much!

edit: So the `distance_key` has no other purpose than to show the reason of the penalty?

---

<div class="post-metadata">

**Author:** ![8h2a](https://avatars.discourse-cdn.com/v4/letter/8/4491bb/32.png) [@8h2a](https://discourse.beets.io/u/8h2a)\
**Post date:** [January 25, 2019, 1:38am UTC](https://discourse.beets.io/t/highlight-weight-applying-plugins-at-candidate-selection/601/6 "2019-01-25T01:38:08Z")

</div>

On second thought, it might not solve my problem.  
This only prints the `distance_key` if there’s actually a penalty applied.  
So I can see those candidates that were penalized, but not those that are preferred (or even added) by that plugin. Even then it only shows the plugin name only if there’s not too many different penalties (because of the `limit`).  
This also means that there’s no indication if there’s only a single candidate.

Appending the plugin name to the `data_source` would make it show the plugin name, however that might not be the cleanest solution.

Allowing negative penalties could solve this issue though. (Is there a reason why they are not allowed? We could count and show negative penalties similar to the others but with a different color)

So in summary, opposite-penalties would be nice, but simply changing the `data_source` would solve my issue with the least amount of code changes.  
Unless there’s another way that I’m not seeing here.

Edit: I could of course also add another property to the AlbumInfo, but showing that would require changes in the beets core.

---

<div class="post-metadata">

**Author:** ![adrian](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.beets.io/adrian/32/4_2.png) [@adrian](https://discourse.beets.io/u/adrian)\
**Post date:** [January 25, 2019, 1:52am UTC](https://discourse.beets.io/t/highlight-weight-applying-plugins-at-candidate-selection/601/7 "2019-01-25T01:52:11Z")

</div>

I like the idea of adding to the data source field! Another thing we could consider adding to the beets importer UI is a special field just for showing a “note” during import time. This could be separate from the data source and just serve as a hint to the user.

“Negative penalties” are an interesting idea. But I think you can see how that would make some things we do in beets feel “backwards.” Internally, it’s nice to know that there’s a minimum distance—0.0 (i.e., 100% similarity). If penalties can go in both directions, for example, it’s possible to go _below_ distance 0.0.

---

<div class="post-metadata">

**Author:** ![8h2a](https://avatars.discourse-cdn.com/v4/letter/8/4491bb/32.png) [@8h2a](https://discourse.beets.io/u/8h2a)\
**Post date:** [January 25, 2019, 1:54am UTC](https://discourse.beets.io/t/highlight-weight-applying-plugins-at-candidate-selection/601/8 "2019-01-25T01:54:51Z")

</div>

Thank you for your input and quick responses!

For now I just added it to the `data_source` field and (using `ui.colorize`) it even looks nice, so I’ll just keep it like that:  
 ![image](https://canada1.discourse-cdn.com/flex029/uploads/beets/original/1X/64719743af07cca597e61f1846987d342f5e1737.png)

---

<div class="post-metadata">

**Author:** ![8h2a](https://avatars.discourse-cdn.com/v4/letter/8/4491bb/32.png) [@8h2a](https://discourse.beets.io/u/8h2a)\
**Post date:** [January 25, 2019, 1:58am UTC](https://discourse.beets.io/t/highlight-weight-applying-plugins-at-candidate-selection/601/9 "2019-01-25T01:58:09Z")

</div>

> [@adrian](#):
>
> a special field just for showing a “note” during import time.

Would plugins add their own “notes” to the candidates (or maybe the imported album instead) (which then gets displayed if the user wishes to display notes from that particular plugin)?  
Or did you have something else in mind?

---

<div class="post-metadata">

**Author:** ![adrian](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.beets.io/adrian/32/4_2.png) [@adrian](https://discourse.beets.io/u/adrian)\
**Post date:** [January 25, 2019, 2:06am UTC](https://discourse.beets.io/t/highlight-weight-applying-plugins-at-candidate-selection/601/10 "2019-01-25T02:06:35Z")

</div>

Awesome! Yeah, that’s exactly what I had in mind for a “notes” field.
