iPhoto Library integration

If you have a suggestion for a feature, post it here

iPhoto Library integration

Postby pmos69 » Wed Apr 22, 2009 10:00 am

Integration with iPhoto whould be a nice feature (for OSX, of course)
In the meantime, since sharing the iPhoto directories directly was such a mess, I hacked up a really bad applescript to create a directory with symlinks to the events (rolls) of iPhoto.

It reads the iPhoto library AlbumData.xml and gets the events and filepaths.

It's really, really slow, and not optimised at all, but it can work as a "stop gap" measure, I guess.

script follows:

set f to ((path to pictures folder as text) & "iPhoto Library:AlbumData.xml")
set ppath to POSIX path of f
set ppath2 to POSIX path of (path to home folder as text)
set ppath2 to ppath2 & "Links/"
set rmstr to "rm -rf " & ppath2 & "*"
do shell script rmstr

set TheEvents to {}

tell application "System Events"
set pfile to property list file ppath
copy property list item "List of Rolls" of pfile to TheEvents
set total to {value} of every property list item of TheEvents
set alist to item 1 of total
set myitems to property list item "Master Image List" of pfile

repeat with roll in alist
set aname to |RollName| of roll

set aname to my ReplaceText(aname, "/", "-")
set mkdirstr to "mkdir " & ppath2 & "\"" & aname & "\"/"
do shell script mkdirstr
end try

set efotos to |KeyList| of roll
repeat with x from 1 to count of efotos
set temp to item x of efotos
set thefoto to value of property list item temp of myitems
set fotopath to |ImagePath| of thefoto
set fotoname to my extractname(fotopath)
set lnstr to "ln -ns \"" & fotopath & "\" \"" & ppath2 & aname & "/" & fotoname & "\""
do shell script lnstr
end try
end repeat
end repeat
end tell

on extractname(fName)
set {TID, text item delimiters} to {text item delimiters, "/"}
set fName to last text item of fName
set text item delimiters to TID
return fName
end extractname

on ReplaceText(theString, fString, rString)
set current_Delimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to fString
set sList to every text item of theString
set AppleScript's text item delimiters to rString
set newString to sList as string
set AppleScript's text item delimiters to current_Delimiters
return newString
end ReplaceText
Posts: 147
Joined: Mon Jan 19, 2009 3:37 pm

Re: iPhoto Library integration

Postby pmos69 » Wed Apr 22, 2009 11:29 pm

much faster in python. (about 20 seconds for my 10k+ foto library)
Of course the intention should be to avoid creating all these symlinks and do it in a PMS virtual dir.

script follows: -------------------------

import plistlib,os

thelib = plistlib.readPlist(os.path.expanduser('~/Pictures/iPhoto Library/AlbumData.xml'))
linksPath = os.path.expanduser('~/iPhotoLinks')

try: os.system('rm -rf ' + linksPath + '/*')
except: pass

try: os.mkdir(linksPath)
except: pass

e = dict()
for event in thelib['List of Rolls']:
e[event.RollID] = event.RollName.encode('utf8').replace("/","-")
try: os.mkdir(linksPath + '/' + e[event.RollID])
except: pass

for photo in thelib['Master Image List'].values():
try: os.symlink(photo.ImagePath, linksPath + "/" + e[photo.Roll].decode('utf8') + "/" + os.path.basename(photo.ImagePath))
except: pass

--------------------------: script ends
Posts: 147
Joined: Mon Jan 19, 2009 3:37 pm

Return to Feature Suggestions

Who is online

Users browsing this forum: No registered users and 3 guests