INTERACT FORUM
More => Old Versions => JRiver Media Center 20 for Windows => Topic started by: Humbledore on July 25, 2015, 05:26:18 pm
-
Hi,
I found this post from mark_h, dated 2012-05-09, in order to achieve an album average rating value:
Global variables were added to MC a couple of builds back, which has opened up a new world of functionality within MC.
Here is my method for generating album ratings using variables.
Create a smartlist and copy this string into the import/export dialogue:
[Media Type]=[Audio] [=save(0,v_tracks[album artist (auto)][album])1]=1 [=save(math(1+load(v_tracks[album artist (auto)][album])),v_tracks[album artist (auto)][album])1]=1 [=save(0,v_albumratingsum[album artist (auto)][album])1]=1 [=if(compare([rating],=,0),save(-1,v_albumratingsum[album artist (auto)][album]),)1]=1 [=if(compare(load(v_albumratingsum[album artist (auto)][album]),>,-1),save(math([rating]+load(v_albumratingsum[album artist (auto)][album])),v_albumratingsum[album artist (auto)][album]),)1]=1 ~sort=[Album Artist (auto)],[Album],[Track #],[Media Type],[Disc #],[Name]
Add an expression column 'Album Rating'
if(compare(load(v_albumratingsum[album artist (auto)][album]),>,0),formatnumber(math( load(v_albumratingsum[album artist (auto)][album]) / load(v_tracks[album artist (auto)][album]) ),2),0)
Notes:
v_albumratingsum[album artist (auto)][album] is the variable that holds the album average, or -1 if tracks remain unvoted for.
v_tracks[album artist (auto)][album] contains the number of tracks in the album
The expression column could be moved into a user field, but by leaving the actual calculations in a smartlist you can refresh the ratings at any time, eg after you've made rating changes. Views that want to display them or smartlists that want to use them can call the generating smartlist to ensure the ratings are correct and ready for use.
Enjoy!
Mark
Is this still the preferable method to achieve an album average rating value or has it become 'easier'?
I tested the code and noticed two things I would like to change:
1. Rounding the sum to one digit.
2. Ignoring non rated songs, i.e if a ten songs album has five non rated songs (0 stars) and five 3 stars songs, then the average album rating should be 3.
Besides that it would be nice if I can use an Album Thumbnails view sorted on the album average rating value...
Thanks!
-
Variables are the only way to currently average anything over a whole album
You can round the results for sure with formatnumber(n,1), you could ignore non rates songs too id probably use is empty(n,1) to check for either missing or zero
-
Thanks ferday, I'll try if I can implement these changes.
So I guess then, that there is still no easy/user friendly way to achieve album thumbnail views showing album ratings. Let's hope for MC 21...
-
You can round the results for sure with formatnumber(n,1), you could ignore non rates songs too id probably use is empty(n,1) to check for either missing or zero
I think I succeeded to implement formatnumber(n,1) but to ignore non rating tracks by using empty(n,1) I need some additional help with... Where shall I put this condition, and what is the exact definition?
And how to view the average rating value in an album thumbnails view? And perhaps with some desirable graphical stars...
Thanks!
-
My guess (haven't had time to test) is replace the iscompare(load(v...),>,0) with !isempty(load(v...),1)
The compare is asking for it to be greater than 0, the !isempty(n,1) is testing for NOT (0 or empty)
Edit: reading his expression above, it looks like non-rated gets a -1 rather than an empty. If this is true you'll have to test for !iscompare(load(v...),<=,0) this means if NOT less than or equal to zero
To use it in thumbnails you'll have to make a custom field rather than an expression column
What I usually do in these things is make the custom field "simple"
load(v...) / load(v...) ignoring the if() part
I've made my v_numtracks into a smartlist of its own, then I can call it at will to do calculations in (ideally) other smart lists or fields and expression columns depending on the situation
I think you can then use the custom field in the thumbnail. You could make the custom field a star field as well...I'm not sure as I don't really do thumbnail views but I seem to recall its possible now. If you use a star field you'll want to round your output since we don't use half stars
I don't do ratings at all so I can't do a direct test but I could rate a few albums and try later when I'm not working
In case it helps, there's a small error in his explanation above. V_albumratingsum does NOT hold the average, it holds the SUM, then the math function load() / load () is doing the average. Variables are cool but they are black boxes...we don't outright define them in MC like we would in C or excel so I don't always understand why they work but they do
-
So I guess then, that there is still no easy/user friendly way to achieve album thumbnail views showing album ratings. Let's hope for MC 21...
If that's all you want, you can... Quite easily. In fact, I think it does it by default, but...
In Standard View, edit the Thumbnail Text:
(http://glynor.com/img/screenshots/MC20/StandardView-Categories-Thumbnail_Text.png)
Add something like this:
[Name] If(IsEmpty(RatingStars()),, / ◦ RatingStars())
This will result in:
(http://glynor.com/img/screenshots/MC20/StandardView-Categories-AvgAlbumRating.png)
Where the stars shown are album averages.
-
If that's all you want, you can... Quite easily. In fact, I think it does it by default, but...
Ah, thanks glynor, quite elegant :) I didn't know there was a RatingStars field...
But what I can notice is that your code snippet isn't able to show half stars at non integer/whole number values. Is it possible as well?
And is it also possible to get a corresponding number/figure value for use in other views, for sorting, filtering and so on?
-
Read my last post, I believe it's all there....
-
Read my last post, I believe it's all there....
Thanks ferday!
I'll maybe give it a try later on although I probably will discover it's a little too tricky/time consuming for me to get into that much of code right now...
-
And is it also possible to get a corresponding number/figure value for use in other views, for sorting, filtering and so on?
Categories automatically average Ratings (and other fields) when the results are essentially "(Varies)" (otherwise, they'd always say "Varies" which isn't very useful). When used or displayed within a Category, some fields sum (like [Track #], for example) and some show averages.
If you wanted to show a number, you could just use the raw [Rating] field like this:
[Name]
[Track #] Tracks If(IsEmpty(RatingStars()),, / ◦ RatingStars() [Rating])
(http://glynor.com/img/screenshots/MC20/StandardView-Categories-AvgAlbumRating-2.png)
If you switch the Categories List Style from Thumbnails to Details, you can display all sorts of statistics:
(http://glynor.com/img/screenshots/MC20/StandardView-Categories-List_Style_Stats-small.png)
Click to embiggen. (http://glynor.com/img/screenshots/MC20/StandardView-Categories-List_Style_Stats.png)
But, if you want to use them on any single-file entry, rather than a Category, then you have to calculate them yourself as described above.
-
Categories automatically average Ratings (and other fields) when the results are essentially "(Varies)" (otherwise, they'd always say "Varies" which isn't very useful). When used or displayed within a Category, some fields sum (like [Track #], for example) and some show averages.
Thanks glynor, I take a look at this after my holiday!
-
My guess (haven't had time to test) is replace the iscompare(load(v...),>,0) with !isempty(load(v...),1)
The compare is asking for it to be greater than 0, the !isempty(n,1) is testing for NOT (0 or empty)
Edit: reading his expression above, it looks like non-rated gets a -1 rather than an empty. If this is true you'll have to test for !iscompare(load(v...),<=,0) this means if NOT less than or equal to zero
I postponed my holiday, bad weather... So then I gave the code a try, but unfortunately, I cannot exclude non rated tracks from the average calculation, I don't get it right. I believe I need help with the exact syntax for this to work (and for me to understand a bit more of the expression language)...
Thanks!
-
Just make it more difficult.... simply averaging the track ratings to come up with an album rating is not really accurate, the time of the track must be considered.
-
Just make it more difficult.... simply averaging the track ratings to come up with an album rating is not really accurate, the time of the track must be considered.
Good point, but I think that is more a matter of preferences and the principal of the evaluation. For me the time of a track is of secondary/minor importance and can simply be ignored, at least in general.
-
I've hacked on this a little and I think I've got it doing Album Rating as an average of only those tracks that have a rating. So if you have 10 tracks and only 2 are rated, in only considers the ratings from those 2 tracks. Here's the smartlist definition:
[Media Type]=[Audio]
[=save(0,v_albumratingsum[album artist (auto)][album])1]=1
[=if(compare([rating],>,0),save(math([rating]+load(v_albumratingsum[album artist (auto)][album])),v_albumratingsum[album artist (auto)][album]),)1]=1
[=save(0,v_rated_tracks[album artist (auto)][album])1]=1
[=if(compare([rating],>,0),save(math(1+load(v_rated_tracks[album artist (auto)][album])),v_rated_tracks[album artist (auto)][album]),)1]=1
~sort=[Album Artist (auto)],[Album],[Track #],[Media Type],[Disc #],[Name]
...and the Expression Column for Album Rating:
formatnumber(math( load(v_albumratingsum[album artist (auto)][album]) / load(v_rated_tracks[album artist (auto)][album]) ),2)
Give it a try and let me know how it works.
Brian.
-
I've hacked on this a little and I think I've got it doing Album Rating as an average of only those tracks that have a rating. So if you have 10 tracks and only 2 are rated, in only considers the ratings from those 2 tracks.
Brilliant, it's working! :D I just modified the calculation to round off to one digit instead of two.
Thanks a lot blgentry!
-
Give it a try and let me know how it works.
Brian.
it works great for me! one question though. is there a way to make it factor '0' values somehow. seems to me now a 2 "4" star album with many '0' starts still gets a 4 while i want it to me much lower rated :D
thx
Z