Ok, so my script gets lyrics from a website, and then iwant them to appear in a scrollview/text view thing.
this is my code:
on idle theObject
using terms from application "iTunes"
tell application "iTunes"
set cur_track to the name of the current track as string
set cur_artist to the artist of the current track as string
set theSong to cur_track
set theArtist to cur_artist
set theSong to lowercase(theSong)
set theArtist to lowercase(theArtist)
set ASTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to {" "}
set theSong to text items of theSong
set theArtist to text items of theArtist
set AppleScript's text item delimiters to {"-"}
set theSong to theSong as Unicode text
set theArtist to theArtist as Unicode text
set AppleScript's text item delimiters to {""} -- Not really needed here, but we're not using any error handling on the shell script, so.
get "http://www.lyricsdir.com/" & theArtist & "-" & theSong & "-lyrics.html"
do shell script "/usr/bin/curl --user-agent '' " & quoted form of result
set theLyrics to result
set AppleScript's text item delimiters to {"<div id=\"lyrics\">"}
set theLyrics to (last text item of theLyrics) as Unicode text
set AppleScript's text item delimiters to {"</div>"}
set theLyrics to first text item of theLyrics
set AppleScript's text item delimiters to {"<br />"}
set theLyrics to text items of theLyrics
set AppleScript's text item delimiters to {""}
set theLyrics to text 2 thru -1 of (theLyrics as Unicode text) -- removes a newline
-- proper way to set the delimiters back (that's why you "saved" them earlier!)
set AppleScript's text item delimiters to ASTID
tell window "mainWindow"
set the contents of text view "lyrics_text" of scroll view "lyrics_box" to theLyrics--this is where i get the error.
end tell
on lowercase(someText)
return do shell script "/usr/bin/python -c \"import sys; print unicode(sys.argv[1], 'utf8').lower().encode('utf8')\" " & quoted form of someText
end lowercase
end idle