[Pythonmac-SIG] ScriptingBridge vs. AppScript
Jon Smith
smithharder at gmail.com
Fri Oct 10 04:45:27 CEST 2008
Hi,
I've been using Appscript and have been incredibly happy with it. However
I'm having a ton of problems getting the list of tracks from my library. I
was assuming the problem was with my library/iTunes itself however I can get
the track list with ScriptingBridge. Am I doing something wrong? Why would
ScriptingBridge work and AppScript Timeout? Any ideas.
#!/usr/bin/env python
from ScriptingBridge import *
from appscript import *
def main(argv=None):
itunes =
SBApplication.applicationWithBundleIdentifier_("com.apple.iTunes")
lib = itunes.sources()[0].playlists()[0]
tracks = lib.tracks()
print len(tracks)
tracks2 =
app(u'/Applications/iTunes.app').library_playlists['Library'].file_tracks.get()
print len(tracks2)
if __name__ == "__main__":
sys.exit(main())
Results:
kona:Python joe$ time python tt.py
Python: unknown type name "tdta".
38447
Traceback (most recent call last):
File "tt.py", line 23, in <module>
sys.exit(main())
File "tt.py", line 19, in main
tracks2 =
app(u'/Applications/iTunes.app').library_playlists['Library'].file_tracks.get()
File
"/Library/Python/2.5/site-packages/appscript-0.18.1-py2.5-macosx-10.5-i386.egg/appscript/reference.py",
line 439, in __call__
appscript.reference.CommandError: CommandError -609: connectionInvalid
Failed command:
app(u'/Applications/iTunes.app').library_playlists['Library'].file_tracks.get()
real 2m1.152s
user 0m0.687s
sys 0m0.129s
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pythonmac-sig/attachments/20081009/274a0e2a/attachment.htm>
More information about the Pythonmac-SIG
mailing list