Posted By

mandric on 11/27/07


Tagged

backup flickr perl


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

icecreamboyy


Backup a flickr photoset


 / Published in: Perl
 

  1. #!/usr/bin/perl -w
  2. # To install the Flickr perl library on OSX with macports I do:
  3. # sudo port install p5-flickr-api
  4. # On Linux there's a similar package.
  5. #
  6. # Then to get Flickr::Photoset I do:
  7. # sudo perl -MCPAN -e 'install Flickr::Photoset'
  8.  
  9.  
  10. use Data::Dumper;
  11. use Flickr::Photoset;
  12. use Flickr::Photo;
  13. use LWP::Simple;
  14. use strict;
  15.  
  16. my $params = { api_key => 'your api key'};
  17. my $info = {};
  18.  
  19. my $photoset = Flickr::Photoset->new($params);
  20.  
  21. # specify a photoset
  22. if ($photoset->id({id => '72057594072478931'})) {
  23. my $title = $photoset->title;
  24. my $owner = $photoset->owner->real_name;
  25. my $photos = $photoset->photos;
  26. foreach my $p ( @$photos ) {
  27. my $id = $p->id;
  28. my $sizes = $p->sizes;
  29. foreach my $s (@$sizes) {
  30. if ( $s->{'label'} eq 'Original') {
  31. $info->{$id} = {
  32. source => $s->{'source'},
  33. title => $p->title,
  34. server => $p->server
  35. };
  36. my $ret = getstore(
  37. $s->{'source'},
  38. $p->title.'_'.$id.'.jpg'
  39. );
  40. print 'response was '.$ret.' for '.$p->title."/n";
  41. }
  42. }
  43. }
  44. }

Report this snippet  

You need to login to post a comment.