[Pythonmac-SIG] controlling iTunes with appscript
Craig Amundsen
cdamundsen at gmail.com
Sat Dec 2 04:45:38 CET 2006
Hi -
I finally had time to play around with appscript, and can now get the
list of tracks. For reasons I don't understand, if I try to get all
the file_tracks in the library, iTunes shoots up to about 80% CPU
utilization and never comes back, even if I set the timeout to 15
minutes. But if I put all the songs in a playlist and get the songs
with
app('iTunes').sources[1].user_playlists['PlaylistOfAllSongs'].file_tracks.get()
it takes a while, but eventually comes back with list of tracks.
> Just FYI if you don't know already, iTunes uses aliases to keep track
> of file locations, so if you're not moving across volumes, you
> shouldn't have to do anything at all.
> You may end up needing to use HFS rather than POSIX paths, or even
> aliases, depending on what iTunes expects.
If I get the location of a track eg,
>>> t.location.get()
macfile.Alias(u'/Volumes/FirewireHD/iTunes/Air/Talkie Walkie/02 Cherry
Blossom Girl.mp3')
the location is definitely a macfile.Alias
I am moving my songs between Volumes, so I do have to do something. If I try:
>>> f = macfile.Alias(u'/Volumes/RAID/iTunes/Air/Talkie Walkie/02
Cherry Blossom Girl.mp3')
>>> t.location.set(f)
I get this error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/aeosa/appscript/reference.py",
line 281, in __call__
raise CommandError(self, (args, kargs), e)
appscript.reference.CommandError: 'NoneType' object has no attribute '__name__'
Failed command:
app(u'/Applications/iTunes.app').sources.ID(41).user_playlists.ID(388392).file_tracks.ID(388445).location.set(macfile.Alias(u'/Volumes/RAID500/iTunes/Air/Talkie
Walkie/02 Cherry Blossom Girl.mp3'))
Any hints would be greatly appreciated.
Thanks,
- Craig
More information about the Pythonmac-SIG
mailing list