This is my first Applescript that I wrote (although I have dabbled in Lotusscript before) to assist with a solution of getting Lyrics to my iTunes songs without copy & paste from a website. I use this script in conjunction with the pearLyrics widget.
I was only able to complete this with the assistance of the Macscripter site by viewing solutions posted here. Thanks all !!
How it works
The script searches the main library for songs without any Lyrics. It excludes video’s, movies and podcasts then builds a new playlist of those songs. The new playlist is then selected and the user is prompted to enter in the amount of time in seconds to play each song for. This is so the widget can access the internet and get the lyrics. Each song in the playlist is played for the amount of time specified. The script ends when the user stops the current song being played or is at the end of the playlist.
If you restart the script and the playlist exists you are prompted to rebuild the playlist. If you select no, the script will continue from where it left off, again prompting for the amount of time to play each song for.
This is only tested with iTunes v7, iMac G5 and pearLyrics v0.5 & v0.6
I would appreciate any feedback and hope this is useful to others.
Cheers
tell application "iTunes"
set the_result to ""
set doit to button returned of (display dialog "This program will make a new playlist of all songs in the main library with no lyrics, then play each song so your pearlyrics widget can get the lyrics." with icon 2 buttons {"Quit", "OK"} default button 2)
if doit is "Quit" then error number -128
if (exists playlist "Tunes No Lyrics") then
set the_result to button returned of (display dialog "The 'Tunes No Lyrics' Playlist Exists - Rebuild the Playlist?" with icon 2 buttons {"Yes", "No"} default button 2)
if the_result is "Yes" then
set view of front browser window to playlist "Tunes No Lyrics"
using terms from application "iTunes"
delete (every track of playlist "Tunes No Lyrics")
with timeout of 600 seconds
display dialog "Building the Playlist 'Tunes No Lyrics'. This may take a while so please be patient." with icon 2 buttons {"OK"} giving up after 30
duplicate (file tracks of library playlist 1 whose lyrics is "" and kind does not contain "video" and kind does not contain "movie" and podcast is not true) to playlist "Tunes No Lyrics"
end timeout
end using terms from
end if
end if
if the_result = "" then
if not (exists playlist "Tunes No Lyrics") then make new playlist with properties {name:"Tunes No Lyrics"}
with timeout of 600 seconds
display dialog "Building the Playlist 'Tunes No Lyrics'. This may take a while, so please be patient." with icon 2 buttons {"OK"} giving up after 130
duplicate (file tracks of library playlist 1 whose lyrics is "" and kind does not contain "video" and kind does not contain "movie" and podcast is not true) to playlist "Tunes No Lyrics"
end timeout
end if
end tell
tell application "iTunes"
set view of front browser window to playlist "Tunes No Lyrics"
display dialog "Enter the Time in Seconds to play the tracks for. You may need longer for modem connections !" with icon 1 default answer "12" buttons {"Cancel", "OK"} default button 2 giving up after 60
copy the result as list to {text_returned, button_pressed}
play
repeat until player state is stopped
delay {text_returned}
next track
end repeat
end tell