Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Rate iTunes songs on a wider scale Apps
While playing around with AppleScript and song ratings (based on a program for saving ratings in the Comment tag), I realised that iTunes can handle any rating within the range 0 to 100. You can set it to larger or smaller values than this, but it will be changed to either limit.

This can provide flexibility in terms of ratings: you are not limited to five (or six, although I use no stars as 'unrated') discrete ratings. When you sort by rating, iTunes will take into account the actual value, not the displayed number of stars. The AppleScript code required to set the rating of the currently playing song to 95% is:
tell application "iTunes"
  set rating of current song to 95
end tell
Note that values less than 100 will display 4 stars, even if they are greater than 90 -- values are rounded down to the next lowest multiple of 20.
    •    
  • Currently 2.80 / 5
  You rated: 1 / 5 (5 votes cast)
 
[12,244 views]  

Rate iTunes songs on a wider scale | 32 comments | Create New Account
Click here to return to the 'Rate iTunes songs on a wider scale' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Rate iTunes songs on a wider scale
Authored by: SC_shooter on Feb 01, '05 11:22:36AM

Why would you want to do this? I may be wrong (probably am) but you can't display this or even set up a playlist based the '95'.

Paul



[ Reply to This | # ]
Rate iTunes songs on a wider scale
Authored by: stcanard on Feb 01, '05 12:29:22PM

I think the suggestion is that iTunes internal algortihms will take this into account.

So, for instance, although you can't see this, if you check Party Shuffles "Play higher rated songs more often", a song with a rating of 95 will be played very slightly more often than one with a rating of 90



[ Reply to This | # ]
Rate iTunes songs on a wider scale
Authored by: SC_shooter on Feb 01, '05 03:17:50PM

Thanks for enlightening me.

It's a shame that iTunes won't let you choose to display and set the ratings with either the stars or the numeric rating. I'm not sure that I would go back and reset the rating on my library (~2500 songs) but it would nice to be able to do so in the iTunes display, if I wanted.



[ Reply to This | # ]
Rate iTunes songs on a wider scale
Authored by: kramrm on Feb 01, '05 01:22:22PM

I had found out about this a while back while changing ratings using the Salling Clicker.

The following ratings are given though iTunes
0 stars = 0
1 star = 20
2 stars = 40
3 stars = 60
4 stars = 80
5 stars = 100

I had manually set a track to be 75. My play list was greater than 3 stars. This didn't include 3 star songs (rated at 60) but did include the songs rated 75, even though iTunes displayed them as 3 star songs.



[ Reply to This | # ]
fine tuned, dynamic rating
Authored by: BlackJack on Feb 01, '05 05:27:25PM
I am using 2 AppleScripts to rate the currently playing song +5 if i like it better than the song before or -5 if not. That way the rating is more dynamic and it will force songs down again when they are heard too often.

Of course, this does require the discipline to rate as often as possible. Using Hotkeys or assigned mouse buttons (MX 700) does help. Romeo/Salling Clicker and a Bluetooth phone come in handy too.

The script for Rating +5:

tell application "iTunes"
	set this_track to current track
	set current_rate to rating of this_track
	if current_rate is equal to 0 then set current_rate to 50
	set new_rate to current_rate + 5
	if new_rate mod 2 is 1 then set new_rate to new_rate + 1
	if new_rate is greater than 100 then set new_rate to 100
	set rating of this_track to new_rate
end tell

As you can see, songs rated up always recieve an even score - this was intended for building a "hot tracks" playlist, but i haven't done this yet.

[ Reply to This | # ]
fine tuned, dynamic rating
Authored by: taxi on Feb 02, '05 08:17:19AM
Yeah, that's the sort of stuff I like!

I'd like to have a remote control that I can press a (+) or (-) button to say "Yeah I still dig this song! Keep playing it" or "Nah, I'm kinda getting over this tune. There's only so many times I can hear about Golder Gaytimes..." and have a fluid rating system.

I've written a program which sits on the screen and allows percentage rating, you can find it at this page

[ Reply to This | # ]
fine tuned, dynamic rating
Authored by: TMSIDRSchnapper on Feb 03, '05 07:58:46AM

Is there any way to do this automatically via Applescript?

E.g. when a song starts playing, decrease it's rating by 5. And when a song is finished playing, increase its rating by 10.

So your favourites would be rated up by 5 as soon as you let them finish, while songs that you skipped will get a lower rating by the time. Sounds pretty handy, uh?



[ Reply to This | # ]
fine tuned, dynamic rating
Authored by: taxi on Feb 04, '05 07:38:10AM
There's apparently no way to find out when a song has just finished.

What you could do is have an application that controls iTunes, and you only use it to change songs. When the song changes (which you can only tell by polling every n seconds) and you didn't cause it, then up the rating. If you skip the song, drop the rating.

You could do this quite easily in AppleScript Studio. I'll (possibly) write this over the next couple of days. Subscribe to my RSS feed and I'll post an entry when I'm done.

[ Reply to This | # ]
fine tuned, dynamic rating
Authored by: robartsd on Mar 23, '05 01:35:49AM

If the script saves the ID and play count for the current track, then it only needs to see if the play count has been incremented when it sees a new track playing. iTunes doesn't increment the play count that you skip before it finishes playing.



[ Reply to This | # ]
fine tuned, dynamic rating
Authored by: taxi on Feb 06, '05 06:51:45AM
Done! See iTunes AutoRater.

[ Reply to This | # ]
Rate iTunes songs on a wider scale
Authored by: Eponymous on Feb 04, '05 12:14:06AM

Read "The Paradox of Choice" to see why you might not want to do this.



[ Reply to This | # ]
Rate iTunes songs on a wider scale
Authored by: taxi on Feb 06, '05 06:51:58AM

I don't think I've got it in my library. Can you elaborate on why having a wider range of possible ratings is bad?

With some of the comments that have been posted, like the idea to have a fluid rating system that up-rates songs that you listen to the whole song (or most of it) and down rates songs you skip them, finer grained ratings seem like a good idea.

I was already finding that I rated a heap of songs at 100%, and within that there were songs that weren't my 'absoloute' favourite-ist. (!)

I suspect that the size of my (and most other people's) iTunes collections are more likely to provide an example of "The Paradox of Choice" (from what I can gather from reading the Amazon.com review).

This is not intended as a flame - if there is a particular reason why that book is relevant to this tip/idea/argument, I'd love to hear it.



[ Reply to This | # ]
Rate iTunes songs on a wider scale
Authored by: DougAdams on Feb 01, '05 11:23:44AM

This a fine tip, but mind this caveat: you cannot view the actual rating value anywhere except by AppleScript. So while you can sort your tracks according their actual rating value (ie, not a factor of 20), you won't be able to view that number in iTunes.



[ Reply to This | # ]
Rate iTunes songs on a wider scale
Authored by: sjmills on Feb 01, '05 12:52:08PM
That doesn't really matter so much. Are Finder labels meaningless if you only see the color and not the label name? No. It's the same thing. You're seeing a generalization of the actual rating in iTunes and of the actual label name in Finder. Besides, the rating will mean something to a script that does things based on the value and not how many stars it displays.

[ Reply to This | # ]
Rate iTunes songs on a wider scale
Authored by: KingDoom on Feb 01, '05 01:59:55PM

Can anyone modify this script to provide a prompt for your rating? That way you don't have to create separate scripts for each rating you want to assign. Thanks.



[ Reply to This | # ]
Rate iTunes songs on a wider scale
Authored by: duffster on Feb 01, '05 02:44:57PM
I'm no great AppleScripter, but here's what I came up with:

tell application "iTunes"
	set TrackRating to rating of current track as integer
	display dialog "Rating for this song:" default answer TrackRating
	set dialogInfo to result
	set NewRating to text returned of dialogInfo as integer
	set selectedButton to button returned of dialogInfo
	get selectedButton
	set rating of current track to NewRating
end tell
Everyone is encouraged to modify and improve upon this script. Please do, but post back!

[ Reply to This | # ]
Rate iTunes songs on a wider scale
Authored by: KingDoom on Feb 01, '05 05:02:15PM

Worked great for me, thanks!



[ Reply to This | # ]
Rate iTunes songs on a wider scale
Authored by: Eravau on Feb 01, '05 05:34:42PM
I've been using the following script for a year or two. I have it saved as n doing the modifications in case the next track starts playing (thus changing the "current track") while you're still deciding what to rate the past one. Lastly, if you rate the track 10 or less it automatically deactivates that track (unchecks it) and moves the playhead position to one second from the end of an application and have a keyboard shortcut assigned to it so that I can pop up the rating dialog no matter what application I'm in at the moment. It's similar to the above, but with a few additional features. My rating dialog box shows the artist and song title. It refereces the track being modified by ID rather than "current track" whethe track. I did this mostly because I assume that if I (or you) would rate something that low, you probably don't really want to hear it again. Feel free to modify to taste.
tell application "iTunes"
    set curr_rating to the rating of the current track as text
    set curr_track to the name of the current track
    set curr_artist to the artist of the current track
    set curr_dur to the duration of the current track
    set curr_dbid to the database ID of the current track
end tell
set rate_dialog to (display dialog ("Rate "" & curr_track & "" by " & curr_artist) default answer curr_rating buttons {"Rate", "Cancel"} default button 1)
set new_rating to text returned of rate_dialog
if button returned of rate_dialog is "Rate" then
    tell application "iTunes"
        set rating of every track of playlist 1 whose database ID is curr_dbid to new_rating as number
        if new_rating < 11 then
            set played date of every track of playlist 1 whose database ID is curr_dbid to current date
            set enabled of every track of playlist 1 whose database ID is curr_dbid to false
            if the database ID of the current track is curr_dbid then
                set player position to (curr_dur - 1)
            end if
        end if
    end tell
end if


[ Reply to This | # ]
Rate iTunes songs on a wider scale
Authored by: Eravau on Feb 01, '05 05:38:32PM
Also, if you don't want to rate the currently playing track, but instead want to rate the selected track, change any occurance of "current track" (lines 2-6 of the script) to "selection".

[ Reply to This | # ]
Rate iTunes songs on a wider scale
Authored by: robartsd on Mar 23, '05 01:45:31AM

Here's my first script to set the rating. This one is for a selection (supporting multiple tracks). The default rating is the average of the current ratings.


tell application "iTunes"
	set dialogText to ""
	set adverageRating to 0
	set myTracks to get {name, rating} of selection
	repeat with myTrack from 1 to length of first item of myTracks
		set dialogText to dialogText & "Track: " & item myTrack of first item of myTracks & "
			Rating: " & item myTrack of second item of myTracks & "
"
		set adverageRating to adverageRating + (item myTrack of second item of myTracks)
	end repeat
	set adverageRating to {adverageRating / (length of second item of myTracks)} as integer
	set reply to display dialog dialogText default answer adverageRating
	if button returned of reply is "OK" then
		set rating of selection to text returned of reply as integer
	end if
end tell


[ Reply to This | # ]
Rate iTunes songs on a wider scale
Authored by: Eravau on Feb 01, '05 05:42:37PM

Sorry about the munging of the intro paragraph above. It should read:

I've been using the following script for a year or two. I have it saved as an application and have a keyboard shortcut assigned to it so that I can pop up the rating dialog no matter what application I'm in at the moment. It's similar to the above, but with a few additional features. My rating dialog box shows the artist and song title. It refereces the track being modified by ID rather than "current track" when doing the modifications in case the next track starts playing (thus changing the "current track") while you're still deciding what to rate the intended one. Lastly, if you rate the track 10 or less it automatically deactivates that track (unchecks it) and moves the play head position to one second from the end of the track. I did this mostly because I assume that if I (or you) would rate something that low, you probably don't really want to hear it again. Feel free to modify to taste.



[ Reply to This | # ]
Rate iTunes songs on a wider scale
Authored by: KB3HFP on Feb 01, '05 08:37:28PM

Very interesting. Does anyone know if this works with the iPod as well?

I just put together a quick freeware AppleScript Studio app that works with this functionality but want to figure out if it's iPod-compatible before I write up a quick web page for it.



[ Reply to This | # ]
AppleScripts
Authored by: duffster on Feb 02, '05 01:23:19AM
I've tried using iTune's BPM feature, but find it to be a hastle and not worth the time to figure the BPM of all of my songs, especially since the BPM does not necessarily seem to always correlate with the energy of all songs. So why not have the BPM show the rating on a 0-100 scale? That's what I've decided to use it for, and if anyone wants to follow suit, then here are some AppleScripts that do just that: First, we need to convert all existing BPM values to the associated rating. This script will do that, but it takes a while to run, especially for large libraries. The good news is that you only should need to run it once.

tell application "iTunes"
	set lib to library playlist 1
	repeat with i from 1 to (count file tracks of lib)
		log i
		set TrackRating to (a reference to rating of track i of lib) as integer
		set bpm of track i of lib to TrackRating
	end repeat
end tell
Now to modify my previous script, which allows the user to change a rating...

tell application "iTunes"
	set TrackRating to rating of current track as integer
	display dialog "Rating for this song:" default answer TrackRating
	set dialogInfo to result
	set NewRating to text returned of dialogInfo as integer
	set selectedButton to button returned of dialogInfo
	get selectedButton
	set rating of current track to NewRating
	set bpm of current track to NewRating
end tell
Of course, this script can be placed in ~/Library/iTunes/Scripts for easy access. Unfortunately it will only change the value on a track which is playing, but that works for me, as I might need my memory jogged to just remember how over-/under-rated a track was using the five star system. The only "problem" with this system that I have found is that changing the rating using the traditional iTunes method of clicking the stars will change the actual rating back to a multiple of 20, while leaving the BPM rating at the old value. I'd appreciate any modifications to either of these scripts, as well as any feedback from those who might use it. :-)

[ Reply to This | # ]
AppleScripts
Authored by: SC_shooter on Feb 02, '05 09:46:39AM

That sounds like a great idea to me. I couldn't care less about the BPM field. I could just use it for the rating.

This might be a good idea for a Tiger widget - an iTunes controller that lets you change the numeric rating of the current song also.

Paul



[ Reply to This | # ]
Rate iTunes songs on a wider scale
Authored by: DougAdams on Feb 02, '05 11:35:56AM
Here is a script that will display the Rating of the Current Track (or selected track if no track is playing), and also allow you to change it to any number between 0 - 100:
tell application "iTunes"
	if player state is not stopped then
		set thisTrack to current track
	else
		if selection of front window is not {} then
			set thisTrack to item 1 of (selection of front window)
		else
			display dialog "No track is playing or selected." buttons {"Cancel"} default button 1 with icon 2
		end if
	end if
	
end tell

do_rating("", thisTrack)

to do_rating(addenda, thisTrack)
	tell application "iTunes"
		set new_rating to text returned of (display dialog addenda & (thisTrack's name) & " is Rated:" default answer (get thisTrack's rating) default button 2)
		try
			new_rating as integer is greater than or equal to 100
			set thisTrack's rating to new_rating as integer
		on error
			my do_rating(("You must enter a number between 0 - 100..." & return & return), thisTrack)
		end try
	end tell
end do_rating
Save it with Script Editor in your home > Library > iTunes > Scripts folder.

[ Reply to This | # ]
Rate iTunes songs on a wider scale
Authored by: DougAdams on Feb 03, '05 11:41:35AM
This script has been updated here.

[ Reply to This | # ]
Rate iTunes songs on a wider scale
Authored by: cchristner on Feb 02, '05 11:40:59AM

Hi,

If it'll save you time, here's what I do to save ratings to Comments:

1. Set the Library to display on Ratings

2. Select all songs of the same rating and drag them into a playlist (not a smart playlist)

3. Run an iTunes applescript called (I believe) Append to Comments to add a unique rating to the comments field. I'm on a Mac, so for a 5-star song (for example) I use the code 5 then five apple characters (option + shift + k) and another 5 (i.e., 5*****5).

4. Later, if I need to restore my ratings for some reason, there's another AppleScript that'll search comments and put the found items in a playlist.

Works well and the scripts can be found at http://www.malcolmadams.com/itunes/index.php.

--Chris



[ Reply to This | # ]
Doesn't work for me
Authored by: TC!! on Feb 03, '05 06:07:38AM

I had to change it to use current track instead of current song or it wouldn't work.
This is excellent for me as a workaround for iTunes not having a keyboard shortcut for rating songs like iPhoto does.

Here is my version of the code which works:
tell application "iTunes"
set rating of current track to 95
end tell



[ Reply to This | # ]
Use this for keyboards Shortcuts
Authored by: TC!! on Feb 03, '05 08:28:56AM

Further to my other reply I realised this can be used to create keyboard shortcuts for rating songs.
If you create 6 scripts, which rate from 0 to 100 in steps of 20 + call them rate0, rate1, etc. Then place them in the directory ~/Library/iTunes/scripts
then they will appear in a menu in iTunes.
You can then use System Preferences to add keyboards shortcuts to iTunes for each of those menu items.
So for example apple+shift+0 for rate0.

I remember seeing a hint somewhere to remove the shift from these keyboard shortcuts but can't find it now, anybody?



[ Reply to This | # ]
Use this for keyboards Shortcuts
Authored by: DougAdams on Feb 03, '05 08:36:25AM
Rate iTunes songs on a wider scale
Authored by: TC!! on Feb 03, '05 01:32:26PM

Ok, it is possible to get it to work with just cmd-0, etc.
Open up ~/Library/Preferences/com.apple.itunes.plist

Search for the text you used in the menu, for example Rate and you will find something like this:
<dict>
<key>Rate0</key>
<string>@$0</string>
</dict>

If you delete the dollar so you are left with @0 then you get cmd-0 as the shortcut!! Do the same for all of them and you can now rate songs in iTunes using the same keyboard shortcuts as iPhoto.



[ Reply to This | # ]
Rate iTunes songs on a wider scale
Authored by: DougAdams on Feb 04, '05 06:50:10AM
Info on setting iTunes Script menu Shortcuts is here.

[ Reply to This | # ]