[Pythonmac-SIG] ScriptingBridge vs. AppScript

Ned Deily nad at acm.org
Fri Oct 10 05:59:37 CEST 2008


In article 
<fa198ccc0810091945w7a9f9e70qb07a1825ef01c113 at mail.gmail.com>,
 "Jon Smith" <smithharder at gmail.com> wrote:
> 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(
> )

FWIW, appscript seems to have no problems for me returning a track list 
of length 21361.  You're not quite doing an Apple-to-app(le)script 
comparison, though.  I get a somewhat faster response from iTunes if I 
construct an appscript reference similar to your SB one:

   app('iTunes').sources()[0].playlists()[0].tracks()

This is using the pre-release appscript 0.19 with the python.org python 
2.5.2 on 10.5.5 Intel.

I see your track count is 38447.  2**16 > 38447 > 2**15, so could there 
possibly be some overflow problem somewhere?

-- 
 Ned Deily,
 nad at acm.org



More information about the Pythonmac-SIG mailing list