dougscripts.com

July 31 2008 - 2:50 pm

AppleScript Bug or Feature in iTunes 7.7.1

I think I have found a rather unusual AppleScript bug (or perhaps feature; one never knows) in iTunes 7.7.1. It affects several scripts that may need to reference a track using a persistent ID. When attempting to reference a single track with a whose clause, the track reference is returned coerced as a list. This requires that an additional step be taken to extricate the single item (the track reference) from the list. I have filed a bug report. It is reproducible with this script:

tell application "iTunes"
	set t to item 1 of selection
	set p to (get persistent ID of t)
	log ("p: " & p)
	set the_track to (some track of library playlist 1 whose persistent ID is p)
	-- the result is a list
	(*
		{file track id 33083 of library playlist id 10591 of source id 46}
		*)
	log the_track
end tell

Site contents © 2001 - 2022 (that's right: 2001) Doug Adams and weblished by Doug Adams. Contact support AT dougscripts DOT com. About.
All rights reserved. Privacy.
AppleScript, iTunes, iPod, iPad, and iPhone are registered trademarks of Apple Inc. This site has no direct affiliation with Apple, Inc.
The one who says "it cannot be done" should not be interrupting the one who is doing it.