
Score2Rating
Source (link to git-repo or to original if based on someone elses unmodified work):
pretty accurate intervals. (In the future, the intervals might become changeable).
This is mostly usable to give you a starting point for using the new rating system in Amarok 1.4.
Tracks that already have a rating will only be updated if the calculated rating is higher.
If you have kdialog installed, a nice progressbar will be displayed showing how the script progresses.
It is recommended that you back up your database (the statistics table at least) before
running this script. It should do no harm, but you can never be too safe...
Requirements:
Amarok 1.4-beta3 or newer
Ruby 1.8 (not sure about the version, 1.6 _might_ work, I didn't test it.)
====================================
WARNING! READ THIS BEFORE UPGRADING FROM v2.0!
v2.0 had a packaging bug that will remove all other scripts when you uninstall it.
This can be fixed by (instead of uninstalling) manually removing the files "README" and "score2rating.rb" from your ~/.kde/share/apps/amarok/scripts folder and then restarting Amarok.
YOU HAVE BEEN WARNED!
====================================
2006-07-27 (v3.0)
I'm an idiot. I made the script WAY to advanced from the beginning.
I can't believe I didn't come to think about this earlier.
Anyhow. instead of running 4 dcop calls per track (and some more), this version runs a grand total of 9 dcop calls (one per rating) to Amarok and 10 to update and close the optional progress bar KDialog. It doesn't even care about the problemous file names. On my computer with my ~1000 track music collection, this is more than 500 times faster, seriously. It's all about SQL Magic!
(This new version is tested successfully with both MySQL and SQLite, but not PostgreSQL. If you've run it successfully with PgSQL, pop me a note, preferably via email.)
2006-07-26 (v2.5)
This should REALLY fix the problems some people are having by escaping all (?) special characters that confuse the dcop query commands (', " and `). The most common problem seems to have been files with "double quotes" in their file names. (I was able to reproduce the error).
This version also adds better error handling so the script can finish cleanly even if it encounters an error.
2006-07-16 (v2.2)
Sorry about this version mess, but I found a bug with the conversion (tracks with score 100 wouldn't get any rating).
2006-07-16 (v2.1)
This release should fix the errors some people get by also escaping backticks. (It works for me now, and I could reproduce it before the fix.)
It also fixes a packaging bug from 2.0, which would make uninstalling the script remove all other installed scripts.
2006-07-12 (v2.0)
Finally the script works again, much because of a patch I got from Elliot Pahl (halcyonCorsair).
The script now also updates ratings of tracks that already have a rating (but only if the new rating is higher).
Additionaly, a KDialog progressbar was added.
2005-12-20 (v1.2)
Removed the unneeded .svn dir from the package file...
Ratings & Comments
16 Comments
Where can I get those stars ratings? I have amarok 1.4.8, but the ratings are not there.
Your scrip works but I have one problem. Do you know of a script that will automatically score the song or can you tell me how to create one
Hi I have downloaded 2.2 and this error is shown on 25%: /home/manuel/.kde/share/apps/amarok/scripts/score2rating/score2rating.rb:46:in `Float': invalid value for Float(): "" (ArgumentError) from /home/manuel/.kde/share/apps/amarok/scripts/score2rating/score2rating.rb:46 from /home/manuel/.kde/share/apps/amarok/scripts/score2rating/score2rating.rb:40:in `each' from /home/manuel/.kde/share/apps/amarok/scripts/score2rating/score2rating.rb:40 from /home/manuel/.kde/share/apps/amarok/scripts/score2rating/score2rating.rb:24:in `loop' from /home/manuel/.kde/share/apps/amarok/scripts/score2rating/score2rating.rb:24 THX for Help TOD
This SHOULD be fixed in v2.5, at least you will be given an error report to send to me (if it doesn't work).
Hi I get the folow error on 25%: /home/manuel/.kde/share/apps/amarok/scripts/score2rating.rb:46:in `Float': invalid value for Float(): "" (ArgumentError) from /home/manuel/.kde/share/apps/amarok/scripts/score2rating.rb:46 from /home/manuel/.kde/share/apps/amarok/scripts/score2rating.rb:40:in `each' from /home/manuel/.kde/share/apps/amarok/scripts/score2rating.rb:40 from /home/manuel/.kde/share/apps/amarok/scripts/score2rating.rb:24:in `loop' from /home/manuel/.kde/share/apps/amarok/scripts/score2rating.rb:24 THX for Help TOD
got error code around 18% / 19% sh: -c: line 0: unexpected EOF while looking for matching ``' sh: -c: line 1: syntax error: unexpected end of file /home/vincent/.kde/share/apps/amarok/scripts/score2rating.rb:46:in `Float': invalid value for Float(): "" (ArgumentError) from /home/vincent/.kde/share/apps/amarok/scripts/score2rating.rb:46 from /home/vincent/.kde/share/apps/amarok/scripts/score2rating.rb:40:in `each' from /home/vincent/.kde/share/apps/amarok/scripts/score2rating.rb:40 from /home/vincent/.kde/share/apps/amarok/scripts/score2rating.rb:24:in `loop' from /home/vincent/.kde/share/apps/amarok/scripts/score2rating.rb:24 Any help is welcome ;-)
Must be a problem with the filenames in your collection. Probably one of them contains a ` (backtick), which makes the script confused. I'll look into it.
This should be fixed in v2.2 (and v2.1, 2.2 just fixes a conversion bug), I tried it and got it to work successfully.
Hi, sorry but the error is still here: /home/ds/.kde/share/apps/amarok/scripts/score2rating/score2rating.rb:46:in `Float': invalid value for Float(): "" (ArgumentError) from /home/ds/.kde/share/apps/amarok/scripts/score2rating/score2rating.rb:46 from /home/ds/.kde/share/apps/amarok/scripts/score2rating/score2rating.rb:40 from /home/ds/.kde/share/apps/amarok/scripts/score2rating/score2rating.rb:24 Greetings m0nk
Jocke, it's a good idea to use exception handling to catch such runtime errors. --Mark
I'm getting ruby errors with 1.4-svn (build date March 21) - has something changed with the script manager? /home/dangle/.kde3.5/share/apps/amarok/scripts/score2rating/score2rating.rb:34:in `Float': invalid value for Float(): "" (ArgumentError) from /home/dangle/.kde3.5/share/apps/amarok/scripts/score2rating/score2rating.rb:34 from /home/dangle/.kde3.5/share/apps/amarok/scripts/score2rating/score2rating.rb:32 from /home/dangle/.kde3.5/share/apps/amarok/scripts/score2rating/score2rating.rb:21 Regards, Christie
apparently the script isn't tested on recent versions and isn't being supported... I'll see if I can find out what's going on and post a fix later, if anyone's interested.
I don't know if you have found a solution. Anyway changing line 33 into sqlurl = url.gsub( /'/, '\'\'' ) solved the problem for me.
Hello, As I have version 1.3.6 (which doesn't contain the field 'rating' in the 'statistics' table from the database) I didn't make use of your script but I looked at the source and I have a little question. When you do case foo when 0...5 (...) when 5...10 (...) isn't the 5 ambigious ? Tahnk you :) PS: I noticed that your tarball contains the .svn directory (5Ko~)
I had to wrap the intervals, else some ratings would stay nil (I don't really get why). As I'm comparing a float with integers, it's kind of logical. (Although, I got the same behaviour when I converted the score to an integer too...) Thanks for noticing the .svn dir, I'll remove it as soon as I get home... (I'm in school now, and I don't really want to publish a WinRAR-created bz2 file here... ;) ) I panicked for a while when I thought that the password was saved there, but it wasn't... phew.
Actually, no. 5...10 is the range [5,10[. 5..10 is [5,10] though.