Here's some information about a personal coding itch I scratched recently, on the off chance that it helps someone else out there. Certainly my Google skills didn't turn up anyone else who had solved the same problem.
Problem Description
You have a Mac
somewhere where you use Apple's excellent
iPhoto to manage your huge digital photography collection.
However, you don't have (and most likely don't want) a spiffy but locked-down and feature-light
Apple TV to display them on your TV, instead preferring the excellent and far more versatile open-source
mythtv.
Mythtv has mythgallery which displays pictures
from a normal filesystem reasonably well, but the poor thing has little to no understanding of the complexities of Apple's "iPhoto Library" on-disk layout. I'm talking Albums basically, plus an understanding of "Originals" versus "Modified". I just want it to be how it looks in iPhoto, but on my big LCD screen in front of the couch, controlled with my myth remote. Is that too much to ask??!
Research/Analysis
Can't find anyone else with this issue so figure "how hard can it be?". Not very, it turned out, at least to get something working, if ugly.
The perl
Mac::iPhoto looks like a good place to start, but since it hasn't been touched since 2003 it certainly doesn't do anything much useful on my current (7.1.3) iPhoto Library.
It uses
Mac::PropertyList to do the parsing of the xml file, which doesn't seem to work either. After much fiddling it looks like the AlbumData.xml file in the iPhoto Library actually
is invalid - it doesn't have the proper header. First hack Mac::PropertyList to accept the dodgy header, but later decide to keep that standard and put the hack into my script instead.
Design
Decide to make a directory next to the iPhoto Library which is full of symlinks pointing into the actual library. Directories in this tree will correspond to Albums in iPhoto, and the links will be named such that the alphabetical order used by mythgallery corresponds to the order in iPhoto.
Try and get this working on the linux box and also via Samba but in the end it's simplest to run the code and create the symlink tree
on my mac and then
rsync both the iPhoto Library and the symlink tree across to the linux box.
Don't use samba, it stuffs up the annoying ":" that iPhoto uses in paths, at least for me. rsync handles it fine, it's not even that Mac-specific one to my knowledge, just whatever is on my Ubuntu box.
Code
You'll need
Mac::iPhoto 0.1-timg, which is the modification of 0.1 available on cpan to work with iPhoto 7.1.3, and Mac::PropertyList 1.31 from cpan. I guess I should put my code on CPAN, but just wanted to get it all up here for now.
Once that's available, you will of course need the actual
iPhotoToDirectories script. It's all hard-coded - but you wouldn't have made it this far if you couldn't edit it to work in your situation :)
Operation
You'll need
the same directory structure on both the mac and the linux box as the symlinks get created on the mac but are de-referenced on the linux box.
Once it's all in place, run iPhotoToDirectories on your mac whenever you want. It takes a long time, so I wouldn't script it. Maybe an overnight cronjob if you keep your Mac on all night. I don't so I just run it when I remember.
Then rsync both the iPhoto Library and the symlink tree to the linux box.
Finally, chmod -R a+rx the linux directories if the uid on your mac is different from your myth user.
And then, assuming mythgallery can navigate to that symlink directory, it should work and the browsing should be significantly more useful than it was before browsing the raw directory.
Known issues
- Mac::iPhoto's parsing is amazingly slow, ie. ~30mins for me
- hard-coded paths
- ampersands (&) in album names break things
- empty albums should be not put into output
- sorting could be much improved
- would be nice to understand Events too, hmmm...
- lots more UNknown issues, for sure. Let me know!
But hey it
works! And with a full-time life that's enough for me right now.