My personal lyric scraper
No. They got hit with the 'copyright' thing, and lyrics can only be previewed via program API, but viewed in full via their website. They've made it very difficult to copy and paste as well. That's why I made the script below. It may or may not be of use to you.
This isn't an 'automatic' lyrics grabber, I review all my lyrics before adding it. Also, I'd recommend at least a little experience in AppleScripts before diving in.
I made this script to grab lyrics. Read the comments at the top of the bit for some info. It should work for you, but if it doesn't, try cleaning up your song title and artist tags. Save this to your ~/Library/iTunes/Scripts/ folder, and create an application keyboard shortcut in System Preferences -> Keyboard -> Keyboard Shortcuts, left pane, select the item 'Application Shortcuts' and click the "+" to the right below the panes.
![]()
Does the lyrics wiki have any way that enables songs in iTunes to auto-add the lyrics when a song is played or does it have to be done manually?
No. They got hit with the 'copyright' thing, and lyrics can only be previewed via program API, but viewed in full via their website. They've made it very difficult to copy and paste as well. That's why I made the script below. It may or may not be of use to you.
This isn't an 'automatic' lyrics grabber, I review all my lyrics before adding it. Also, I'd recommend at least a little experience in AppleScripts before diving in.
I made this script to grab lyrics. Read the comments at the top of the bit for some info. It should work for you, but if it doesn't, try cleaning up your song title and artist tags. Save this to your ~/Library/iTunes/Scripts/ folder, and create an application keyboard shortcut in System Preferences -> Keyboard -> Keyboard Shortcuts, left pane, select the item 'Application Shortcuts' and click the "+" to the right below the panes.


Code:
(*This 'Lyrics via LyricWiki' based on Doug Adams of dougscripts.com
[B]Modified by sammich. Using this script carries no warranty whatsoever.
[/B]
This script requires that you create a workflow (and save it as .workflow).
Recreate the workflow in the screenshot below:
http://img.skitch.com/20100506-k6j5us6fm38itaj4e6tptmekhj.jpg
Then go about halfway down the script and type in the path of the workflow.
This script will grab the current playing song and search for it at lyrics.wikia.org
omitting any text inside brackets or certain special characters. It will parse the
search page and give a list of hits. Select a hit to retrieve the lyrics for that page.
A list with the lyrics will appear, and press enter to save it to the song.
This is a personal script and has enhancements only to my
library. Feel free to modify this code to suit your library.
*)
tell application "iTunes"
if player state is playing then
set sel to current track
tell sel to set {tname, tartist} to {get name, get artist}
else if selection is not {} and (count items of selection) is 1 then
set sel to item 1 of selection
tell sel to set {tname, tartist} to {get name, get artist}
else
return
end if
set currentsong to database ID of current track
-- checks against a playlist of good lyrics in library
(*
set goodlist to playlist "** Good Lyrics" -- replace this with your playlist name and remove comment brackets
set posi to player position
set mylist to get database ID of every track in goodlist
if mylist contains currentsong then
set result to display dialog "Lyrics for this song are good. Go ahead and look anyway?"
end if
*)
end tell
if tname is "" or tartist is "" then
tell application "iTunes" to display dialog "The track does not have enough information to search LyricWiki." buttons {"OK"} with icon 0 with title my_title
return
end if
set remove_backet to offset of "[" in tname
if remove_backet is greater than 0 then
set tname to characters 1 thru (remove_backet - 2) of tname as text
end if
set remove_backet to offset of "(" in tname
if remove_backet is greater than 0 then
set tname to characters 1 thru (remove_backet - 2) of tname as text
end if
set listartist to words of tartist
set tartist to ""
repeat with artword in listartist
if artword contains "Feat" then
exit repeat
end if
set tartist to tartist & " " & artword
end repeat
if character 1 of tartist is " " then set tartist to characters 2 thru ((length of tartist)) of tartist as text
set theurl to "http://lyrics.wikia.com/Special:Search?search=" & tartist & "+" & tname & "&go=1"
set theurl to my replace_chars(theurl, " ", "+")
set resultslist to extract_search_results(theurl, tname, tartist)
if item 1 of resultslist is equal to "terminate" then return
set opt to (choose from list resultslist with prompt ("Results for: " & tname & ", " & tartist) as text OK button name "Use this result")
if opt is false then return
do shell script "echo \"" & opt & "\" > /tmp/lyrurl"
-- TYPE IN THE LOCATION OF YOUR .workflow
do shell script "automator /location_of_scrapeLyrics.workflow"
set foo to (open for access ("/tmp/lyrics"))
set txt to (read foo for (get eof foo) as Unicode text)
close access foo
set displayLyrics to paragraphs in txt
set final to {}
set startrecording to false
repeat with listitem in displayLyrics
if listitem contains "Ringtone to your Cell" and startrecording = true then
exit repeat
end if
if startrecording is equal to true then
set listitem to listitem & "
"
set final to final & listitem
end if
if listitem contains "Ringtone to your Cell" then
set startrecording to true
end if
end repeat
tell application "iTunes"
set opt to (choose from list final with prompt (tartist & return & "\"" & tname & "\"") as text OK button name "Use Lyrics for Track" with empty selection allowed)
if opt is false then return
try
set final to final as text
set final to characters 1 thru ((length of final) - 1) of final as text
set sel's lyrics to (final as text)
end try
end tell
on replace_chars(txt, srch, repl)
set AppleScript's text item delimiters to the srch
set the item_list to every text item of txt
set AppleScript's text item delimiters to the repl
set txt to the item_list as string
set AppleScript's text item delimiters to ""
return txt
end replace_chars
on extract_search_results(resultURL, tname, tartist)
set limiter to 1 -- limits to 10 results
try
set scrape to do shell script "curl -L " & quoted form of resultURL & " | grep mw-search-result-title"
on error
set dialogResult to display dialog "Song does not exist on lyrics.wikia.com." buttons {"Cancel", "OK"} default button "OK" cancel button "Cancel" giving up after 15 default answer tname & " " & tartist & " - " & resultURL
set resultlist to {"terminate"}
return resultlist
end try
set resultlist to {}
set somelist to paragraphs of scrape
repeat with listitem in somelist
set limiter to limiter + 1
set classpos to offset of "class=" in listitem
set href to characters 14 thru (classpos - 3) of listitem as string
set href to replace_chars(href, "'", "'")
set href to replace_chars(href, "%20", "_")
set href to replace_chars(href, "%27", "'")
set href to replace_chars(href, "%28", "(")
set href to replace_chars(href, "%29", ")")
set href to replace_chars(href, "%3A", ":")
set resultlist to resultlist & href
if limiter is greater than or equal to 10 then exit repeat
end repeat
return resultlist
end extract_search_results