i can’t for the life of me figure out why i get this error, “iTunes got an error: Unknown object type. (-2700)”
here is the code (sry, it’s a little long):
property contentNaa : "Title-Album-Artist"
on launched theObject
(**iSuck**)
end launched
on playThing()
set play_thing to ""
try
tell application "iTunes"
if player state is playing then
set play_thing to ("true" as string)
else
set play_thing to ("false" as string)
end if
end tell
end try
if play_thing is "true" then
set image of image view 11 of window "main" to load image "pause"
else
set image of image view 11 of window "main" to load image "play"
end if
end playThing
on jdp()
try
tell application "iTunes"
set nam to name of current track
set artis to artist of current track
set albu to album of current track
end tell
end try
if contentNaa is "nam" then
try
set contents of text field "naa" of window "main" to artis
set contentNaa to ("artis" as string)
end try
else if contentNaa is "artis" then
try
set contents of text field "naa" of window "main" to albu
set contentNaa to ("albu" as string)
end try
else if contentNaa is "albu" then
try
set contents of text field "naa" of window "main" to nam
set contentNaa to ("nam" as string)
end try
else
try
set contents of text field "naa" of window "main" to contentNaa
set contentNaa to ("nam" as string)
end try
end if
end jdp
on shuffleC()
set shuffler to ""
try
tell application "iTunes"
set shuffler to shuffle of current playlist
if shuffler is true then
set shuffler to ("false" as string)
else
set shuffler to ("true" as string)
end if
end tell
end try
if shuffler is "false" then
set image of image view 9 of window "main" to load image "on_shuffle"
else
set image of image view 9 of window "main" to load image "shuffle"
end if
end shuffleC
on repeatC()
set repeat_type to ""
try
tell application "iTunes"
set arepeat to the song repeat of current playlist
set repeat_type to ""
if arepeat is one then
set repeat_type to ("one" as string)
else if arepeat is off then
set repeat_type to ("off" as string)
else
set repeat_type to ("all" as string)
end if
end tell
end try
if repeat_type is "one" then
set image of image view 8 of window "main" to load image "on_repeat_one"
else if repeat_type is "off" then
set image of image view 8 of window "main" to load image "on_repeat"
else
set image of image view 8 of window "main" to load image "repeat"
end if
end repeatC
on idle theObject
set text color of text field "naa" of window "main" to "black"
tell application "Finder"
set x to name of every process
end tell
if "iTunes" is in x then
try
jdp()
playThing()
shuffleC()
repeatC()
on error err
log err
end try
tell application "iTunes"
set timer to ""
if player state is playing then
set timer to "10"
else
set timer to "20"
end if
end tell
return timer
else
return 10
set image of image view 11 of window "main" to load image "play"
set contents of text field "naa" of window "main" to contentNaa
end if
end idle
on clicked theObject
(*Add your script here.*)
end clicked
on artwork()
try
tell application "iTunes"
set trackthing to current track
set theArt to data of artwork 1 of trackthing
end tell
set tempartwork to ("" & (path to me) & "Contents:Resources:" & "thing.pict") as file specification
set file_reference to (open for access tempartwork with write permission)
set eof file_reference to 512
write theArt to file_reference starting at 513
close access file_reference
set tempartwork1 to (tempartwork as string)
set theposixpath to (POSIX path of tempartwork1)
set image of image view "artworkP" of window "artworkWindow" to load image theposixpath
on error err
--close access file_reference
set image of image view "artworkP" of window "artworkWindow" to load image "case"
error err
end try
end artwork
on remove_markup(this_text)
log "Started cleaning text"
set myAllowed to {"://", "@"}
set {myTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, {"<"}}
set these_items to text items of this_text
set AppleScript's text item delimiters to {">"}
repeat with my_item in these_items
if length of text items of my_item is greater than 1 then
if (text item 1 of my_item) is not in myAllowed then
set my_item's contents to (text item 2 of my_item)
else
set my_item's contents to ("<" & (text items of my_item)) as text
end if
end if
end repeat
set AppleScript's text item delimiters to myTID
set clean_text to these_items as text
--return clean_text
log "Text Cleaned"
set new_clean_text to ""
set y to 0
repeat with lin in clean_text
set num to (ASCII number of lin)
if y is 12 then
--log "y is 6"
set new_clean_text to new_clean_text & (ASCII character of num)
else
set y to (y + 1)
--log y
end if
end repeat
log "Removed first 12 lines"
set contents of text view "lyricText" of scroll view "lyricT" of window "lyric" to new_clean_text
end remove_markup
on awake from nib theObject
artwork()
try
tell application "iTunes"
set artis to artist of current track
set nam to name of current track
end tell
set ur to "http://www.azlyrics.com/lyrics/"
set new_artis to ""
set new_nam to ""
repeat with char1 in artis
set num1 to (ASCII number of char1)
if num1 is greater than 62 and num1 is less than 91 then set num1 to (num1 + 32)
if num1 is greater than 47 and num1 is less than 58 then set new_artis to new_artis & (ASCII character of num1)
if num1 is greater than 96 and num1 is less than 123 then set new_artis to new_artis & (ASCII character of num1)
end repeat
repeat with char2 in nam
set num2 to (ASCII number of char2)
if num2 is greater than 62 and num2 is less than 91 then set num2 to (num2 + 32)
if num2 is greater than 47 and num2 is less than 58 then set new_nam to new_nam & (ASCII character of num2)
if num2 is greater than 96 and num2 is less than 123 then set new_nam to new_nam & (ASCII character of num2)
end repeat
set new_url to (ur & new_artis & "/" & new_nam & ".html") as string
log new_url
set myHtml to do shell script "curl " & new_url
log "Curled url"
set {myDels, AppleScript's text item delimiters} to {{""}, {"</head>"}}
set myText to text item 2 of myHtml
set AppleScript's text item delimiters to myDels
log "Starting Remove_markup"
set myText to remove_markup(myText)
--remove_markup()
on error err
log "Lyrics not found"
set contents of text view "lyricText" of scroll view "lyricT" of window "lyric" to "Lyrics not found"
--display dialog err
end try
--remove_markup()
end awake from nib
an alternative solution to this would be a way to make all errors or dialog box’s not appear…anyone know how to do that?
thxs!