Restricting maximum rating value

I am using some code that I found on here that allows ratings numbers to be displayed as stars in the Ratings column.

$if(%rating winamp%,$repeat($char(10032),%rating winamp%),$if(%rating wmp%,$repeat($char(9733),%rating wmp%),$if(%rating mm%,$repeat($char(10026),%rating mm%),$repeat($char(10061),$if2($ifgreater($regexp(%popularimeter%,'^.+\|(\d{1,3})\|\d+',$1),196,5,$ifgreater($regexp(%popularimeter%,'^.+\|(\d{1,3})\|\d+',$1),128,4,$ifgreater($regexp(%popularimeter%,'^.+\|(\d{1,3})\|\d+',$1),64,3,$ifgreater($regexp(%popularimeter%,'^.+\|(\d{1,2})\|\d+',$1),1,2,$ifgreater($regexp(%popularimeter%,'^.+\|(\d)\|\d+',$1),0,1,))))),0)))))

It works very well, but I would like to limit the maximum number of stars to 5, and display a message in the column if a number greater than 5 is entered into the ratings field (to warn that it is an invalid value).

I wouldn't know how to add any extra code to the complicated code above without breaking it, so I would appreciate some help. Thanks.

Maybe @Doug_Mackie (the original autor of this code) can explain how you could achieve your alternate message.

At least for values in %popularimeter% every number greater then 196 will result in 5 stars. I don't see how you can get anything bigger then 5 stars with the above code.

Maybe the code has to be limited to 255 as max value with something like in this example:

I'm not talking about altering the rating code to scale differently to give different results. I just mean a simple function that says if value in this column is above 5, show <error> (or whatever) instead of showing like 8 or 9 stars or whatever the value is.

This is a very simple and basic command that I could probably manage to figure out if I was dealing with a simple formula rather than the complex one shown above.

Sorry Lem, but I wrote that script nine years ago and I don't remember much about it except that it was hell to figure out! I myself stopped using ratings long ago because I found that my judgment was not very reliable. Often I would find that my initial rating was not even close to my rating on re-listening to the track a few years later.

I don't recall that my script would allow more than five stars in the Mp3Tag version in use at that time. A while back I think that Florian announced some changes to how ratings work internally but I have been unable to find that reference. [Anyone else know where to look?]

As for validating the rating inputs, as far as I know Mp3Tag scripting does not include the ability to show conditional messages.

1 Like

Which version of the rating do you actually use?
The code is so longish as it has to cater for the 3 rating incarnations in the shape of
%popularimeter%
%rating mm%
%rating wmp%
So one could shorten the expression considerably, if it did not have to take care of all variations.

In a quick&dirty version this might show some effekt:
$ifgreater($len($if(%rating winamp%,$repeat($char(10032),%rating winamp%),$if(%rating wmp%,$repeat($char(9733),%rating wmp%),$if(%rating mm%,$repeat($char(10026),%rating mm%),$repeat($char(10061),$if2($ifgreater($regexp(%popularimeter%,'^.+\|(\d{1,3})\|\d+',$1),196,5,$ifgreater($regexp(%popularimeter%,'^.+\|(\d{1,3})\|\d+',$1),128,4,$ifgreater($regexp(%popularimeter%,'^.+\|(\d{1,3})\|\d+',$1),64,3,$ifgreater($regexp(%popularimeter%,'^.+\|(\d{1,2})\|\d+',$1),1,2,$ifgreater($regexp(%popularimeter%,'^.+\|(\d)\|\d+',$1),0,1,))))),0)))))),4,Warning,%popularimeter%)

In general: the expression transforms the display but relies on an existing value. So it cannot be used to warn while data is being input.
So I would assume that it would be much easier to use a filter and list the invalid values, esp. as the formats vary depending on the target. E.g. a value greater than 5 is perfectly ok for the native format of POPULARIMETER. If this is supposed to get serious, it would be necessary to implement some kind of syntax check.

What about 3 additional columns with the content of

%popularimeter%
%rating mm%
%rating wmp%

and then simply sort this columns (by a click on the column header).
You will see the values bigger then 255 or whatever value represents more then 5 stars in your environment.