[Pythonmac-SIG] accessing iPhoto star rating through appscript?

Dethe Elza delza at livingcode.org
Thu Apr 19 00:28:52 CEST 2007

On 18-Apr-07, at 2:14 PM, Daniel Thorpe wrote:

> Hi everyone...
> Does anyone know if it's possible to access the star rating of a
> photo from iPhoto using appscript? After looking in the iPhoto
> dictionary and not seeng any reference to it, I have a feeling it is
> not exposed through AppleScript.
> If anyone has found a way to get the number of stars, I'd love to  
> know!

You don't strictly need AppleScript for this (unless you want data  
that has been changed since iTunes was last started, while it is  
running).  The ratings are stored in an XML file:  ~/Music/iTunes/ 
iTunes Music Library.xml

It's in plist format, so you can use plistlib (part of the standard  
library on OS X), or you can use the XML tool of your choice to parse  
the file and extract the ratings.  Each track has a <dict> element  
containing keys and values.  You'll be looking for <key>Rating</key>  
followed by <integer>100</integer> where the integer corresponds to  
the star rating. The rating appears to be 20 * # of stars (5 stars =  
100, 4 stars = 80, etc.)  Tracks which are not rated don't appear to  
have a Ratings key, so don't make assumptions about every song having  
that key.



A miracle, even if it's a lousy miracle, is still a miracle.  --Teller

More information about the Pythonmac-SIG mailing list