backing up ratings and playlists to id3 tags
hi there,
has anyone come up with an elegant solution for backing up itunes info that isn't stored in id3 tags to id3 tags. i am thinking in particular of ratings and playlists.
i use media centre on an old pc as a jukebox and find it very frustrating that the ratings from it which are stored in id3 tags aren't visible in itunes. similarly if I do rate a track on my ibook the data isn't backed up to the id3 tags.. A script that synchs a comment like "rating= ***" with the itunes stars rating would be lovely.
m
[552 byte] By [
mollw] at [2007-11-9 13:54:30]

# 1 Re: backing up ratings and playlists to id3 tags
The next update of the package Restore Library 2-Step ( http://www.malcolmadams.com/itunes/scripts/scripts04.shtml#restorelibrary2step) is going to be able to store ratings, along with all the playlist a track appears in. Look for it in about a week.
# 2 Re: backing up ratings and playlists to id3 tags
hi doug,
i've tried the script and have a request!! Any chance of changing it so that it works only on selected tracks rather than the whole library? It seems to get a bad case of indigestion on my 20,000 tracks!!
I'm now firmly of the opinion that comments is the only safe place to keep info, at least until apple start using id tags properly. How hard would it be to write a script to store mood/tempo/setting as well as rating in the comments field. I'm thinking of scripts that would allow you to pick e.g. "mood' from a set of predefined terms and add text to the comments field along the linses [MOOD=mellow]. (the difficulty would be if it already existed of course). You'd want sth simple that would work to allow you to charaterize songs with the minimum fuss as you listened to them.
You'd end up with a pretty full comments field i suppose, (with its [RATING=90], [PLAYLISTS=blah blah], [MOOD=mellow] etc) and its a real shame to replicate the functionality of the id3 tag fields, but it would be so useful to find a way to categorise tracks to allow for simple playlist creation.
m
mollw at 2007-11-15 17:26:05 >

# 3 Re: backing up ratings and playlists to id3 tags
Selected tracks is ALSO a part of the update. I hope to get cracking on it very very soon. Thanks for your encouragement!
I agree with your comments comment, but ID3 Tag v2.x comments hold 256 characters, which can be quite a lot of information. Not bad.
Another alternative, which I abandoned early on, is to create an additional extraneous text file with the info you wanted preserved. This just turned into a lot of work, and added more confusion. You could use a FileMake or AW database for that sort of thing, but that also turns into a lot of scripting.
Anyway, I hope to be updating the Restore scripts in a matter of days.
# 4 Re: backing up ratings and playlists to id3 tags
... unless of course there was a programme available in Mac OS X that gave full access to id3 tags. Then we could just script access to the tags and back up ratings and so on to the tags (which is where they should go).
I've looked high and low, but no prog seems to give the same sort of full access to all fields in the tag that e.g. Media Center does under Windows. Anyone come across one?
Meanwhile Doug keep plugging away. i'm waiting with baited breath for the new version of Restore
m
mollw at 2007-11-15 17:28:09 >

# 5 Re: backing up ratings and playlists to id3 tags
MP3 Rage was the best I found.
# 6 Re: backing up ratings and playlists to id3 tags
MP3 Rage was the best I found.
Note that iTunes' rating tag is handled internally by iTunes; it is not the same as the "official" ID3 rating tag.
# 7 Re: backing up ratings and playlists to id3 tags
I nearly started writing a script to store the ratings for each file in its Comments tag for safe-keeping (since I've lost all of my ratings more than once).
I hope that you've made some progress, or that someone else has a good idea for storing the ratings somewhere besides the fragile iTunes database. (other than religiously backing up the database each day - at least once)
--
Andrew Elliston
# 8 Re: backing up ratings and playlists to id3 tags
This script will be ready in a couple of days. If you would like to beta test, send me a private message.
# 9 Re: backing up ratings and playlists to id3 tags
actually I've kind of written sth that stores ratings as
?100? for 5 star,
?080? for 4 star etc. Works pretty well.
As a companion I also have sth that adds a keyword to the comments in the form
??keywords blah blah??
It all works pretty well. Can post it if you are interested
mollw at 2007-11-15 17:33:13 >

# 10 Re: backing up ratings and playlists to id3 tags
Sure...you can post or PM your method for me (and others). I'd like to see it so that I can maybe find out why mine isn't working.
# 11 Re: backing up ratings and playlists to id3 tags
script for adding a keyword follows.
I use keywords beginning with ? for playlists... crude but it works
hope I've worked out how to use tags properly for this messge!!
michael
tell application "iTunes"
(*
this script adds the keyword to the front of the comments as keyword_delimiter & keyword & keyword_delimiter & space e.g. ??keyword??
*)
set keyword_delimiter to "??"
set rating_delimiter to "??"
copy (a reference to (get view of front window)) to thePlaylist
if selection exists then
set using_selection to true
copy (count selection's items) to idx
else -- its the whole playlist
display dialog "it's the whole playlist!! your forgot to select anything..."
set selectedTracks to (get a reference to thePlaylist)
copy (count thePlaylist's tracks) to idx
end if
set appendum to text returned of ?
(display dialog "Enter:" default answer "" default button 2 with icon 1)
-- set appendumend to button returned of ?
-- (display dialog "Append new text Before current comments or After current comments?" buttons {"Cancel", "Before", "After"} with icon 1)
repeat with i from 1 to idx
if using_selection then
copy item i of selection to thisTrack
else
copy track i of selectedTracks to thisTrack
end if
-- thisTrack now set
-- add the keyword to the comment
if thisTrack's comment does not contain (keyword_delimiter & appendum & keyword_delimiter) then
set thisTrack's comment to (keyword_delimiter & appendum & keyword_delimiter & " " & (get thisTrack's comment))
-- now we have to put the rating back to the front
if thisTrack's comment contains rating_delimiter then
set current_comment to thisTrack's comment as string
get current_comment
set old_delimiter to AppleScript's text item delimiters
set AppleScript's text item delimiters to rating_delimiter
if item 1 of current_comment is real then
set new_comments to (rating_delimiter & text item 1 of current_comment & rating_delimiter & " " & text item 2 of current_comment) as string
else
try
set new_comments to (rating_delimiter & text item 2 of current_comment & rating_delimiter & " " & text item 1 of current_comment & text item 3 of current_comment) as string
on error
set new_comments to (rating_delimiter & text item 2 of current_comment & rating_delimiter & " " & text item 1 of current_comment) as string
end try
end if
set AppleScript's text item delimiters to old_delimiter
set thisTrack's comment to new_comments
end if
end if
end repeat
display dialog "Done!" buttons {"Thanks"} default button 1 with icon 1 giving up after 300
end tell
mollw at 2007-11-15 17:35:12 >

# 12 Re: backing up ratings and playlists to id3 tags
and here is the rating code. Note that I've kind of got it working so that ratings always come before keywords and that keywords only get added if they don't already exist in the comment.
tell application "iTunes"
activate
-- first we set the possible list of ratings as text
set rating_delimiter to "??"
set rating_text_list to {rating_delimiter & "000" & rating_delimiter, rating_delimiter & "020" & rating_delimiter, rating_delimiter & "040" & rating_delimiter, rating_delimiter & "060" & rating_delimiter, rating_delimiter & "080" & rating_delimiter, rating_delimiter & "100" & rating_delimiter}
-- logic to determine whether a selection is active or whether we are dealing with a playlist
copy (a reference to (get view of front window)) to thePlaylist
if selection exists then
set using_selection to true
copy (count selection's items) to idx
else -- its the whole playlist
display dialog "it's the whole playlist!! your forgot to select anything... cancel if you selected the whole library!!!"
set using_selection to false
set selectedTracks to (get a reference to thePlaylist)
copy (count thePlaylist's tracks) to idx
end if
-- and now we loop adding the rating to the beginning of the comment for each track
repeat with i from 1 to idx
if using_selection then
copy item i of selection to thisTrack
else
copy track i of selectedTracks to thisTrack
end if
-- thisTrack now set
-- first we clean the comments field up. ratings always go first. So we find all words containing the rating delimiter (?? probably), memorize them, delete them and put the first one found at the beginning of the track's comment
if thisTrack's comment contains rating_delimiter then
set current_comment to thisTrack's comment as string
get current_comment
set old_delimiter to AppleScript's text item delimiters
set AppleScript's text item delimiters to rating_delimiter
set rating_text_list_index to ((get thisTrack's rating) / 20 + 1)
if item 1 of current_comment is real then
set new_comments to (item rating_text_list_index of rating_text_list & text item 2 of current_comment) as string
else
try
set new_comments to (item rating_text_list_index of rating_text_list & text item 1 of current_comment & text item 3 of current_comment) as string
on error
set new_comments to (item rating_text_list_index of rating_text_list & text item 1 of current_comment) as string
end try
end if
set AppleScript's text item delimiters to old_delimiter
set thisTrack's comment to new_comments
end if
-- if there is no rating in the comment and the track is rated, let's update the comment
if (thisTrack's comment) does not contain rating_delimiter and (thisTrack's rating) is not equal to 0 then
set rating_text_list_index to ((get thisTrack's rating) / 20 + 1)
set thisTrack's comment to (item rating_text_list_index of rating_text_list & " " & (get thisTrack's comment))
end if
end repeat
display dialog "Done!" buttons {"Thanks"} default button 1 with icon 1 giving up after 300
end tell
mollw at 2007-11-15 17:36:17 >

# 13 Re: backing up ratings and playlists to id3 tags
sorry it's getting messy but just to note the character I use to indicate a keyword that is a playlist is in fact pi (option and p). For some reason pi doesn't come out on this forum.
m
mollw at 2007-11-15 17:37:13 >

# 14 Re: backing up ratings and playlists to id3 tags
Thank you so much! The scripts seem to be working just fine. Until or unless I run across a more foolproof or robust solution, this will keep me from stressing out about my iTunes libraries (which seem to become corrupted far too easily).
Have you worked on restoring the ratings by pulling them out of the comments?
Thanks again,
Andrew Elliston
# 15 Re: backing up ratings and playlists to id3 tags
hi andrew,
you're most welcome.
automating recovering ratings: no I didn't bother to.. I just find all ??100?? by typing it in the iTunes browse text entry box then set their ratings as 5 star, then find all ??080?? and set them as four star and so on. It wouuld probably be trivial to automate, but as I don't really have to restore them very often I haven't bothered.
I need to write an extra bit that automates the process of adding keywords generated from playlist to each track in the playlist, but I'm kind of waiting for 2-step backup and restore to be released.. (hint hint)
I do need to write sth to strip out keywords a bit more easily though because I want to pare down the number I use.
Ideally I'll create a script with a set of selectable options in a dialogue so you can characterize tracks from a limited number of clickable options.
I envisage a mood (aggressive, meditative, calm, dance,..) keyword that you just select from a dialogue box.
Possibly a tempo keyword (ultrafast, fast moderate, slow, crawling), and maybe a settting keyword (cycling, working, dance). Maybe also a keyword for subgenres (symphony, concerto, ambient, techno, west-coast, ...).
But haven't really thought that bit through yet. The aim is to find a way to play suitable random tracks from a large collection.
... if I ever get round to it...
m
mollw at 2007-11-15 17:39:22 >

