2023-02-06, 23:13
(2023-02-06, 22:26)sagrath Wrote: YES!!!!!!!!!!!!!!!! yesyesyesyes!!!!!!!!!!!
THATS IT!!!!!!!!!!!!!!! @jbinkley60 you are a GENIOUS!!!!!!!!!!!!
It is working EXACTLY as I envisioned. The music starts, the calculations are executed and are only applied when the music changes or stops (either by user intervention or "naturally" when reaching the end).
And your last suggestion made me see where I was going wrong:
In the other codes, the song data was constantly being consulted, so the values were saved in the wrong song. With your suggestion I realized that the data should be consulted only once, and only be consulted again if the music changes. (actually I had thought about it before, but at some point I forgot lol).
Anyway: Here is the final code. now I'm going to apply the tweaks to hide the notifications and also to disable the addon (for those who don't want to "rank" their songs at some point).
Glad it's working for you. I noticed that you didn't use the current_id variable and reused song_id on lines 83 and 90. Your way will work as long as you maintain the order of operation (i.e. update the original song_id) and then get a new value for song_id from the new song). I kept the variables separate to avoid maintaining this level of strictness in code. Overloading variables like this is fine as long as you maintain the proper execution sequence. I also noticed that you dropped the code which checks to ensure the music playing is in the Kodi music database. I'd suggest adding that back in.
Quote:PS. This is not over yet, after including the settings, I'm planning to include a "album rating" in this code. Where the Album Rating will be calculated by averaging the notes of the songs. What you think?
This actually should be pretty easy. Get the ratings from all of the tracks in an album, average the ratings and assign the result to the album. One question, is there a range on your userratings (i.e. 0 to some value) or will longer songs naturally have a higher potential rating due to a longer play time ?
Thanks,
Jeff