Re: iTunes: database ID equivalent for playlists?
Re: iTunes: database ID equivalent for playlists?
- Subject: Re: iTunes: database ID equivalent for playlists?
- From: has <email@hidden>
- Date: Fri, 15 Apr 2005 11:06:18 +0100
Stephen Jonke wrote:
>I found out the hard way that the "index" of a playlist is subject to change.
Correct. This is documented in the AppleScript Language Guide.
>if you create a playlist that ends up prior to some previous one you are keeping track of via index, then the index of the former changes and you end up pointing at some other playlist.
You couldn't just keep track of playlists by full reference? iTunes is very good in this respect: returned references use IDs throughout so are very stable. If you're creating new playlists, just store the returned references in variables and reuse them any time you need to refer to that particular playlist or any of its content.
>It doesn't look like there is a playlist equivalent to the "database ID" of tracks, or am I just missing it?
You're missing it, but this is iTunes' fault, not yours. In this case its a simple mistake in its dictionary: while it declares that all elements can be specified by id, it completely forgets to declare an id property on any of its classes. (Assuming it's not fixed in the latest version, feel free to file a bug on this.) So even if you do think to write:
tell application "iTunes" to set myID to id of playlist 1 of source "library"
you'll find it fails to compile. You can sort of get around this by typing [with real chevrons]:
tell application "iTunes" to set myID to <<class ID >> of playlist 1 of source "library"
though AS turns <<class ID >> into id when it compiles, which means you need to change it back each time you recompile. Probably the easiest thing is simply to move the 'id of' bit outside the 'tell app "iTunes"' block so that AS compiles it using its own terminology:
tell application "iTunes" to set myPlaylist to playlist 1 of source "library"
set myID to id of myPlaylist
To select an element by id, just use the standard by-id reference form:
tell application "iTunes" to get playlist id myID of source "library"
HTH
has
--
http://freespace.virgin.net/hamish.sanderson/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden