Tuesday, 31. July 2007

flickr::backup and RDF

Thanks to the CPAN Perl community, you can get all your Flickr pics as RDF-if you have linux, its just a few steps away.

The relevant documentation: Perl documentation is excellent. I have seldomly seen such a clean
documentation as Aarons tool and the other tools used. It is minimal, it is simple, it doesn't miss one point.
He has example RDF output and example documentation, how to tie everything together was easy to find out using CPAN.org.

You will need a flickr API key and secret.
At this point, you need also the auth_token of the key, this is trickier to do.
I moved sidewards to get the token, as I coded with flickr before,
I had a PHP application running that I used to get the auth_token.
The php-flickr API was Dan Coulter's phpFlickr Class 2.1.0,
and it has this getToken.php file that you can tweak to do the right thing.
I am sure you can get the same with Perl. Once you got the key, secret, and auth_token, install the libs:

get Perl (well, a typical linux distro depends heavily on Perl, so you probably have it already).

get the CPAN module for Net::Flickr::Backup, I used the perl cpan shell for this (sudo is needed because it installs the perl modules in the shared libs):

> sudo perl -MCPAN -e shell
in the perl shell, install the backup module:
> install Net::Flickr::Backup
Now, it asks you many questions. In my case, pressing return most of the time did a good job.

Once you have it installed (perl will say if it doesn't), you can run the Backup by writing a script.

I created two files, one for the config, one for the perl that runs:

flickrbackup.config: (note: the aaaaaa are used to hide my secret keys)
[flickr]
api_key=1025521456c3212a4f84032049cee7a1
api_secret=aaaaaaaaaaaaaaaa
auth_token=aaaaaa-aaaaaaaaaaaaaa
api_handler=LibXML

#[search]
#tags=cameraphone
#per_page=500

[backup]
photos_root=/home/media/photos/flickrbackup
scrub_backups=1
fetch_medium=0
fetch_square=0
force=0

[rdf]
do_dump=1
#rdfdump_root=/home/asc/photos

runbackup.pl:
use Net::Flickr::Backup;
use Log::Dispatch::Screen;
use Config::Simple;

my $cfg = new Config::Simple(filename=>"flickrbackup.config");

my $flickr = Net::Flickr::Backup->new($cfg);

my $feedback = Log::Dispatch::Screen->new('name' => 'info',
'min_level' => 'info');

$flickr->log()->add($feedback);
$flickr->backup();

Now run the scripts:
>perl runbackup.pl

Lean back and watch the photos + RDF manifest in your filesystem magically. In this case, RDF as a file format is helpful becaue it allowed Aaron to mix different aspects of the metadata.

You may get an error because some XML library misses, my error message contained
"Can't locate XML/LibXML.pm in @INC"
Luckily, this mailinglist post tells you what to do:
>sudo apt-get install libxml-libxml-perl
This may fail with some weird message, I ignored this and run my backup script again.
QR barcode by i-nigma.com/CreateBarcodes

Trackback URL:
https://leobard.twoday.net/stories/4122767/modTrackback

icon

semantic weltbild 2.0

Building the Semantic Web is easier together

and then...

foaf explorer
foaf

Geo Visitors Map
I am a hard bloggin' scientist. Read the Manifesto.
www.flickr.com
lebard's photos More of lebard's photos
Skype Me™!

Search

 

Users Status

You are not logged in.

I support

Wikipedia Affiliate Button

Archive

July 2007
Sun
Mon
Tue
Wed
Thu
Fri
Sat
 1 
 2 
 3 
 4 
 5 
 6 
 7 
 8 
 9 
10
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
28
29
 
 
 
 
 

Credits


austriaca
Chucknorrism
digitalcouch
gnowsis
Jesus
NeueHeimat
route planning
SemWeb
travel
zoot
Profil
Logout
Subscribe Weblog