#!/usr/bin/perl package iPhoto; use Foundation; our $dbfile = '/Users/gid/Pictures/iPhoto Library/AlbumData.xml'; our $iphoto; our $lok; our $mil; sub loaddb () # Loads the iPhoto library as a plist file { return if($iphoto); $iphoto = NSDictionary->dictionaryWithContentsOfFile_($dbfile); die "Can't load plist file" unless($iphoto and $$iphoto); return $iphoto; } sub keyword_from_id ($) # Converts a keyword ID into a keyword string { my $id = pop; loaddb() unless($iphoto); $lok = $iphoto->objectForKey_("List of Keywords") unless($lok); my $obj = $lok->objectForKey_("$id"); return $obj->cString if($obj and $$obj); return undef; } sub list_of_keywords () # Gets the list of keywords object { loaddb() unless($iphoto); $lok = $iphoto->objectForKey_("List of Keywords") unless($lok); return undef unless($lok and $$lok); return $lok; } sub master_image_list () # Gets the master image list { loaddb() unless($iphoto); return $mil if($mil); $mil = $iphoto->objectForKey_("Master Image List"); return undef unless($mil and $$mil); return $mil; } 1;