MacPython/iTunes
This wiki is in the process of being archived due to lack of usage and the resources necessary to serve it — predominately to bots, crawlers, and LLM companies. Edits are discouraged.
Pages are preserved as they were at the time of archival. For current information, please visit python.org.
If a change to this archive is absolutely needed, requests can be made via the infrastructure@python.org mailing list.
Does anyone know how to add a track to a playlist using appscript?
Maybe something like this:
def add to playlist(a, t, pl ):
- a.duplicate( t, to=pl )
Find a connected ipod making no assumptions about the name of the ipod:
from appscript import *
def find_ipod( a ):
- for src in a.sources.get():
- if src.kind.get() == k.iPod:
- return src
- if src.kind.get() == k.iPod:
ipod = find_ipod( app('Itunes') )
Find the library making no assumptions about the name of the library (e.g. for non-english versions of itunes it's not "Library"):
from appscript import *
def find_library( a ):
- for src in a.sources.get():
- if src.kind.get() == k.library:
- return src
- if src.kind.get() == k.library:
library = find_library( app('Itunes') )
Create a new playlist on a certain source (i.e. either the library or an ipod, as returned from one of the functions above).
src.make( new=k.user_playlist, with_properties={k.name: 'My new playlist'} )