More > Media Center 17
HOWTO: Generate album ratings using variables (+ track count)
mark_h:
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
f.ammollo:
--- Quote from: mark_h on May 09, 2012, 01:56:54 am ---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.
--- End quote ---
Hello,
I was really interesting in trying out what you suggested in this post, and I managed to make it work exactly how you explained it, but only for the part about the smart list and the new expression column.
What I don't really understand is what you exactly mean here:
--- Quote from: mark_h on May 09, 2012, 01:56:54 am ---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.
--- End quote ---
Could you please explain what you mean with a practical example?
What I would like to achieve would be, for example, to have a thumbnail list showing the albums sorted by the "album rating" expression column, but it seems to me that I cannot reference it from a view because it is not a library field. Am I correct?
Thank you very much in advance.
Best regards,
Fabrizio
mark_h:
--- Quote from: f.ammollo on May 29, 2012, 03:24:52 pm ---What I would like to achieve would be, for example, to have a thumbnail list showing the albums sorted by the "album rating" expression column, but it seems to me that I cannot reference it from a view because it is not a library field. Am I correct?
--- End quote ---
You do not need to use library fields for this to work.
What I was trying to describe above is that you create one smartlist that creates the variables and that any views or smartlists that want to use variables would call this smartlist as part of their rules to ensure that the variables are created.
So for instance, in my system I have a smartlist called:
Var: Album Ratings
that calculates the ratings as per my example above.
Then in a view that wished to use album ratings I would use this smartlist as part of the view rules, eg:
Playlists is any Var: Album Ratings
<rest of the rules>
This ensures that the ratings are created and can be used by the view.
In your view you could then create the expression column and reference the variables directly...
Hope that helps.
justsomeguy:
Is there a downside to doing this entirely with a view?
I created a new view called Album Ratings, set the rules for the view to your first expression. I then created a new library field called Rating Albums set it to calculated data and used your second expression for that. I can then use that field in the new view or as a pane category. It seems to work fine.
I did make a small modification to your expression so that tracks in an album with no rating get calculated as 3 stars instead of forcing the album rating to zero. I have a lot of my tracks rated but a huge amount of full albums have some several tracks with no rating. I know this won't give me a perfect representation of the albums rating but it works for me and as I rate more it will work itself out.
Thanks for sharing this.
mark_h:
The only thing to be careful of with library fields is that the album rating data isn't refreshed... so if you change track ratings they won't update the album ratings. To do this you should always call the smartlist as it forces the recalculations...
Navigation
[0] Message Index
[#] Next page
Go to full version