I am in need of some help modifying some existing Applescript. I am trying to write a script that will go through all the lyrics in my iTunes library and create a playlist of songs that have explicit lyrics. I got Doug Adam’s “No Lyrics to Playlist” scripts and tried to modify it.
After reading some of the primers in this website I tried a few things.
It works if it looks for only one word. I can’t figure out how to get it to look for a list of possible words, any of which would add the song to the playlist.
I have tried the following:
-
Adding a variable and giving it a string - {“", "”, "p*ssy’} - but without the astriks, obviously.
-
Putting the string right in the “if” statement.
-
Listing the words in the “if” statement separated by “or”.
All fail to produce a single song in the playlist.
Here is the script that is working now (only one word searched for).
property my_title : "Explicit Lyrics to Playlist"
-- you can change the name of the "Explicit Lyrics" playlist here:
property playlistName : "Explicit Lyrics"
-- but make sure you change it in "Clean No Lyrics Paylist", too.
tell application "iTunes"
set musicLibrary to (get view of front browser window)
set musicLibraryName to (get name of musicLibrary)
display dialog "This script will create playlist \"" & playlistName & "\", search \"" & musicLibraryName & "\" for songs with explicit lyrics and add them to the \"" & playlistName & "\" playlist." buttons {"Cancel", "OK"} default button 1 with title my_title
if (not (exists playlist playlistName)) then
set new_playlist to make new playlist with properties {name:playlistName}
else
set new_playlist to playlist playlistName
end if
repeat with t from 1 to (index of last track of musicLibrary)
try
with timeout of 30 seconds
set aTrack to (track t of musicLibrary)
try
set lyr to (get lyrics of aTrack)
set dbid to (get database ID of aTrack)
if lyr contains "*****" and not (exists (some track of new_playlist whose database ID is dbid)) then duplicate aTrack to new_playlist
end try
end timeout
end try
end repeat
-- beep
display dialog "Done creating playlist \"" & playlistName & "\"." buttons {"OK"} default button 1
end tell
I am far from a programmer and I would really appreciate any help I can get. Thanks in advance!
AppleScript: 2.1.2
Browser: Safari 533.21.1
Operating System: Mac OS X (10.6)