[Pythonmac-SIG] Adding a track to an iTunes playlist (appscript)

has hengist.podd at virgin.net
Thu Oct 20 12:08:06 CEST 2005

Alastair Rankine wrote:

>On 20/10/2005, at 6:26 PM, David wrote:
> > app('Itunes').sources['Library'].playlists['Library'].duplicate
> > ( a_track, to=a_playlist )
> >
> > and many variations of it. But all I get is an error saying "Too 
> > many direct arguments".
> >
> > Can anyone spot what I'm doing wrong?
>Yep, duplicate is a method of the application itself, not the 

Indeed. Like AppleScript, appscript uses some special tricks to allow you to specify the command's direct argument in more than one way, either as 'application.command(directRef)' (the literal form) or as 'directRef.command()' (convenience form; converted to literal form under the hood). What the OP's actually writing is 'directRef.command(anotherDirectRef)', hence the [somewhat cryptic] error.

The Application Commands chapter in the appscript manual has a section on special case behaviours. I'll amend it in the next release to better explain this particular error.

>You need something like:
>a_track = app('Itunes').playlists['Library'].tracks[0]
>a_playlist = app('Itunes').playlists['Whatever']
>app('Itunes').duplicate(a_track, to=a_playlist)

Yup. Or:

a_track = app('Itunes').playlists['Library'].tracks[0]
a_playlist = app('Itunes').playlists['Whatever']



More information about the Pythonmac-SIG mailing list