• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Itunes - persistent ids not unique (or, managing double integers)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Itunes - persistent ids not unique (or, managing double integers)


  • Subject: Re: Itunes - persistent ids not unique (or, managing double integers)
  • From: has <email@hidden>
  • Date: Sun, 12 Mar 2006 15:20:05 +0000

Andrew Bush wrote:

>>iTunes returns the "persistent ID" as a "double integer", but as Chris
>>said over two years ago, AppleScript converts this to "real" upon
>>receiving it.  I don't know how you could work around it.

One option would be to use a language that supports larger integers. For example, Python includes a 'long' type that can represent integers of any size.


>turns out that the persistent ids stored in the xml file are alphanumeric

It's hexadecimal, as Matt says:

#!/usr/bin/python
print long('27C0F56185B30A90', 16) # -> 2864559162211371664


BTW, the reason your AppleScript matches multiple tracks when filtering by persistent ID is due to you passing it a real. In this case, iTunes seems to do a real-real comparison, so you get multiple false matches due to rounding errors. If you do supply it a double integer in the filter clause, you'll get the correct result. For example, the following will work in the next release of appscript [1]:

#!/usr/bin/env pythonw

from appscript import *

tracks = app("iTunes").playlists["Library"].tracks

id = tracks[1].persistent_ID.get()

print id
# 2864559162211371664

print tracks.filter(its.persistent_ID == id).name.get()
# [u'Schoenb:Verklarte Nacht (str. orch)']


HTH

has

[1] Doesn't work in the current release, unfortunately, as I screwed up on the code for packing Python longs. I've fixed this in the next release, which should be out in another week or so (still polishing its Intel support), or I can supply a patch to the current release on request.
--
http://freespace.virgin.net/hamish.sanderson/
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Build Development versus Deployment changes results of simple Applescript lines
  • Next by Date: Re: iCal: How to retrieve a list of events in chronological order?
  • Previous by thread: Re: Build Development versus Deployment changes results of simple Applescript lines
  • Next by thread: Ending/Aborting/Exiting A Script?
  • Index(es):
    • Date
    • Thread