[Pythonmac-SIG] Fun with appscript

has hengist.podd at virgin.net
Sat Aug 28 02:23:42 CEST 2004


Ray Slakinski wrote:

>I just installed appscript, and I'm using it to add mp3 files to a playlist.
>
>To add it to the main Library I used the following command:
>
>t.add('hardDrive:Users:kier:Desktop:hall.mp3')

See the terminology for 'add' (use the RenderAppTerminology applet to 
render it as HTML):

add(...) -- add one or more files to a playlist
	list of Alias -- the file(s) to add
	[to=InsertionLoc] -- the location of the added file(s)
	Result: k.track -- reference to added track(s)

Try:

from Carbon.File import FSSpec

itunes.add(FSSpec('/Users/kier/Desktop/hall.mp3'),
	to=itunes.sources['Library'].playlists['myPlayList'])

HTH

has

--

Notes:

1. The type shown for the 'to' parameter appears to be incorrect (I 
tried using an insertion location and iTunes raised an error), but 
works with a reference to the playlist as you were doing. (Broken 
terminology resources and flawed or buggy implementations can be the 
bane of the application scripter's life, and Apple's own applications 
are less than perfect.)

2. The Apple Event Manager includes coercions for FSSpec->Alias and 
item->list-of-item, which gives some flexibility in what you can pass 
it, so use an FSSpec as that's easiest (I've no idea how to 
instantiate Carbon.File.Alias and the documentation isn't very 
helpful).

3. Unlike the standard 'make' command, there isn't a special case for 
'add' that'd allow you to write insertionloc.add(fss), so for now 
you're stuck with the formal version: app.add(fss, to=insertionloc)

-- 
http://freespace.virgin.net/hamish.sanderson/


More information about the Pythonmac-SIG mailing list