I’ve already made this applescript and it works great, it finds the lyrics for the selected tracks and imports them to the lyrics field in iTunes. That being said, some of the operations take a while so I wanted to add a progress indicator. I learned that I had to do this using Xcode. So, I built the interface for the progress window and plugged in my code, but now I’m getting these weird errors and the script won’t run. It’s saying “can’t get selection. (-1728)” as well as “Can’t make mySel into type reference. (-1700)” if I use mySel as a variable reference to “selection”. Any ideas as to why these errors are generating, and also, these errors in Xcode suck and maybe I’m missing something but they don’t seem to help at all. Is there a better way to understand these messages and at least show a line number?
property my_title : "Get Lyrics"
on launched theObject
tell application "iTunes"
set myChoice to button returned of (display dialog "If lyrics data already exists:" buttons {"Cancel", "Replace", "Ignore"} default button 2 with title my_title)
try
set mySel to selection
if mySel is {} then
try
set mySel to current track
if not (exists (database ID of current track)) then
error
end if
on error
display dialog return & "No tracks selected and no song currently playing..." buttons {"Cancel"} default button 1 with icon 0 giving up after 15 with title my_title
return
end try
end if
end try
set len to (length of mySel)
set error_tracks to ""
set trackSuccess to 0
set trackIgnore to 0
with timeout of 3600 seconds
repeat with i from 1 to len
tell item i of my mySel
if lyrics is "" or myChoice is "Replace" then
set thisArtist to artist
set thisSong to name
set songResult to (my getSongResult(thisArtist, thisSong))
if songResult is "Not found" then
set error_tracks to error_tracks & "
¢ " & thisArtist & " - " & thisSong
else
set lyrics to songResult
set trackSuccess to trackSuccess + 1
end if
else if myChoice is "Ignore" then
set trackIgnore to trackIgnore + 1
end if
end tell
end repeat
end timeout
end tell
end launched
Model: Macbook Pro
AppleScript: 2.2.1
Browser: Firefox 3.0.5
Operating System: Mac OS X (10.5)