Backup a flickr photoset


/ Published in: Perl
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.