Return to Snippet

Revision: 4326
at December 24, 2007 13:56 by mandric


Updated Code
#!/usr/bin/perl -w
# To install the Flickr perl library on OSX with macports I do:
# sudo port install p5-flickr-api
# On Linux there's a similar package.
#
# Then to get Flickr::Photoset I do:
# sudo perl -MCPAN -e 'install Flickr::Photoset'


use Data::Dumper;
use Flickr::Photoset;
use Flickr::Photo;
use LWP::Simple;
use strict;

my $params = { api_key => 'your api key'};
my $info = {};

my $photoset = Flickr::Photoset->new($params);

# specify a photoset
if ($photoset->id({id => '72057594072478931'})) {
  my $title = $photoset->title;
  my $owner = $photoset->owner->real_name;
  my $photos = $photoset->photos;
  foreach my $p ( @$photos ) {
  my $id = $p->id;
  my $sizes = $p->sizes;
    foreach my $s (@$sizes) {
      if ( $s->{'label'} eq 'Original') {
        $info->{$id} = {
          source => $s->{'source'},
          title  => $p->title,
          server => $p->server
        };
        my $ret = getstore(
                    $s->{'source'},
                    $p->title.'_'.$id.'.jpg'
                  );
        print 'response was '.$ret.' for '.$p->title."/n";
      }
    }
  }
}

Revision: 4325
at December 22, 2007 17:03 by mandric


Updated Code
#!/usr/bin/perl -w
# On OSX with macports intalled do sudo port install p5-flickr-api
# to install the right lib.

use Data::Dumper;
use Flickr::Photoset;
use Flickr::Photo;
use LWP::Simple;
use strict;

my $params = { api_key => 'your api key'};
my $info = {};

my $photoset = Flickr::Photoset->new($params);

# specify a photoset
if ($photoset->id({id => '72057594072478931'})) {
  my $title = $photoset->title;
  my $owner = $photoset->owner->real_name;
  my $photos = $photoset->photos;
  foreach my $p ( @$photos ) {
  my $id = $p->id;
  my $sizes = $p->sizes;
    foreach my $s (@$sizes) {
      if ( $s->{'label'} eq 'Original') {
        $info->{$id} = {
          source => $s->{'source'},
          title  => $p->title,
          server => $p->server
        };
        my $ret = getstore(
                    $s->{'source'},
                    $p->title.'_'.$id.'.jpg'
                  );
        print 'response was '.$ret.' for '.$p->title."/n";
      }
    }
  }
}

Revision: 4324
at November 27, 2007 12:20 by mandric


Initial Code
#!/usr/bin/perl -w

use Data::Dumper;
use Flickr::Photoset;
use Flickr::Photo;
use LWP::Simple;
use strict;

my $params = { api_key => 'your api key'};
my $info = {};

my $photoset = Flickr::Photoset->new($params);

# specify a photoset
if ($photoset->id({id => '72057594072478931'})) {
  my $title = $photoset->title;
  my $owner = $photoset->owner->real_name;
  my $photos = $photoset->photos;
  foreach my $p ( @$photos ) {
  my $id = $p->id;
  my $sizes = $p->sizes;
    foreach my $s (@$sizes) {
      if ( $s->{'label'} eq 'Original') {
        $info->{$id} = {
          source => $s->{'source'},
          title  => $p->title,
          server => $p->server
        };
        my $ret = getstore(
                    $s->{'source'},
                    $p->title.'_'.$id.'.jpg'
                  );
        print 'response was '.$ret.' for '.$p->title."/n";
      }
    }
  }
}

Initial URL

                                

Initial Description

                                

Initial Title
Backup a flickr photoset

Initial Tags
backup, perl

Initial Language
Perl