Hello,
I am currently trying to write something so I can export my iPhoto library into zenphoto. For images it is all working fine, I basically put the iPhoto title and description in the relevant IPTC fields and zenphoto picks it up. For videos it is more problematic as they have no IPTC, so what I have been doing is creating two associated text files .title and .desc e.g. for movie.flv my script would create movie.title and movie.desc.
What I would like to be able to do is get these bits of information into zenphoto for videos. I can see two ways of doing this:
1) Alter zp-core so that on import if the file is a video then read in these files and populate the database
2) Write a script that finds the new *.title and *.desc files and update the database directly (simpler but not as elegant).
Has anyone got any hints on how to do this or the best way to proceed?
There is a similar problem of what to do with the album description in iPhoto, at the moment I just create a file in the relevant folder called AlbumDesc.txt
Comments
`//create meta filename
$metafilename = substr($filename, 0, strripos($filename, '.')).".meta";
//Check if meta file exists
if(file_exists($metafilename))
{
$file_handle = fopen($metafilename, "r");
while (!feof($file_handle) ) {
$line_of_text = fgets($file_handle);
$parts = explode('=', $line_of_text,2);
$result[$parts[0]]=$parts[1]
}
fclose($file_handle);
}`
And the meta file would be name for example movie.meta for movie.flv. The contents would look something like this:
title=This is a title
desc=This is a description
Haven't had a chance to check this code.
`if(file_exists($this->localpath."/AlbumDesc.txt")) $this->setDesc(file_get_contents($this->localpath."/AlbumDesc.txt"));`
To give a bit of context:
`if ($new) {
$title = $this->get('title');
$this->set('title', substr($title, 0, -4));
$this->setDateTime(strftime('%Y/%m/%d %T', filemtime($this->localpath)));
if(file_exists($this->localpath."/AlbumDesc.txt")) $this->setDesc(file_get_contents($this->localpath."/AlbumDesc.txt"));
}
$this->save();`
I would suggest to try to make this as a plugin and/or a standalone script without hacking the core. A iPhoto importer is a good idea but surely only of interesst of Mac users and (sadly..:-))) a minority.
The problem is of labeling videos and albums automatically when uploaded to zenphoto which is a much more generalized problem which relates to most photo library software e.g. Picasa.
So there is two steps for me
On home computer
iphoto -> directory structure (Quite a specialised problem, but I have solved that bit)
On server
directory structure (from whatever photo program) -> zenphoto with video metadata and Album descriptions automatically added.
The idea would be that I could rsync a directory structure on my local machine with the one on the server and everything would be sorted out automagically!
How extensive is the plugin structure? Is it possible to hook into the metadata and album creation functions, from a quick look it doesn't look like it.
You can't directly hook into the core functions/methods for the admin, but you could use them to write your own functions for the importer and for example generate a plugin admin option as a button to execute the sync function. Of course mainly the plugins are to extend the theming part of zenphoto.
We have an article about plugins on our user guide page. Please take a look there, too.
1) Search for all meta files
2) Process them
3) Updated the database with the relevant fields.
By the way, the changes to functions.php for the video metadata work fine if I change $filename to $imageName.
The album description doesn't work. I think maybe I have put it in the wrong place.
----edit----
Fixed I needed to put the album line in setDefaults in album.php.