fp2flickr: Moving galleries from Fotopic to Flickr

699 words

Perhaps, like me, you’ve decided that Flickr is the bee’s knees when it comes to putting photos online. Perhaps, also like me, you have pictures online using other services. You may have been a little bit lax about keeping or indexing local copies. You might want to have everything on Flickr, but find the task of moving everything daunting.

If that other service is FotoPic.net, then I might be able to help you. fp2flickr is an adaptation of the sample Perl script which comes with the Flickr::Upload module. You supply it with a Fotopic collection URL (such as http://john-hartnup.fotopic.net/c429852.html), and it will scrape out all the pictures and their titles, download them, and upload them to Flickr.

For the script to work, you’ll need Perl, and you’ll need to install the Flickr::Upload and HTML::TreeBuilder modules. To do this, use the CPAN shell:

# perl -MCPAN -e shell;
(stuff may happen)
cpan> install Flickr::Upload
(lots of stuff will happen: use common sense to answer questions)
cpan> install HTML::TreeBuilder
(lots more stuff will happen)

Run fp2flickr with the “–auth” flag first, to get an authentication token.

Then either use that token on the command line, or put it in $HOME/.flickrrc as documented below.

I suggest that for each collection, you assign a unique tag with the “–tag” flag. That way, you can use Flickr’s browser interface to manipulate the collection as a batch, e.g. to place all the pictures in a Flickr set.

e.g.

$ ./fp2flickr --tag clifton2004 http://john-hartnup.fotopic.net/c429852.html

Download

fp2flickr-0.1.tar.gz

Documentation

NAME

fp2flickr - Upload photos to flickr.com

SYNOPSIS

fp2flickr [–auth] –auth_token <auth_token> [–title <title>] [–description description] [–public <0|1>] [–friend <0|1>] [–family <0|1>] [–tag <tag>] <fotopic collection_url…>

DESCRIPTION

Fetches images from a collection at www.fotopic.net and uploads them to the Flickr.com service. Heavily based on flickr_upload, from the Flickr::Upload distribution. Flickr::Upload is a prerequisite.

The program requires that the Fotopic collection’s owner has enabled “Allow access to the ‘Original’ image'’ in the “Photo Facilities'’ area of the administration pages.

OPTIONS

–auth
The --auth flag will cause flickr_upload to generate an authentication token against it’s API key and secret (or, if you want, your own specific key and secret). This process requires the caller to have a browser handy so they can cut and paste a url. The resulting token should be kept somewhere like ~/.flickrrc since it’s necessary for actually uploading images.
–auth_token <auth_token>
Authentication token. Required.
–title <title>
Title to use on all the images. Optional.
–description <description>
Description to use on all the images. Optional.
–public <0|1>
Override the default is_public access control. Optional.
–friend <0|1>
Override the default is_friend access control. Optional.
–family <0|1>
Override the default is_friend access control. Optional.
–tag <tag>
Images are tagged with tag. Multiple --tag options can be given, or you can just put them all into a single space-separated list.
–key <api_key>
–secret <secret>
Your own API key and secret. This is useful if you want to use flickr_upload in auth mode as a token generator. You need both key and secret. Both key and secret can be placed in ~/.flickrrc, allowing you to mix flickr_upload with your own scripts using a single API key and authentication token.
<photos…>
List of photos to upload. Uploading stops as soon as a failure is detected during the upload. The script exit code will indicate the number of images on the command line that were not uploaded. For each uploaded image, a Flickr URL will be generated. flickr_upload uses asynchronous uploading so while the image is usually transferred fairly quickly, it might take a while before it’s actually available to users. flickr_upload will wait around for that to complete, but be aware that delays of upwards of thirty minutes have (rarely) be know to occur.

CONFIGURATION

To avoid having to remember authentication tokens and such (or have them show up in the process table listings), default values will be read from $HOME/.flickrrc if it exists. Any field defined there can, of course, be overridden on the command line. For example:

# my config at $HOME/.flickrrc
auth_token=334455
is_public=0
is_friend=1
is_family=1

BUGS

Chris Beauregard admitted that error handling could be better in flickr_upload. This is worse.

AUTHOR

Christophe Beauregard, cpb@cpan.org is the original author of flickr_upload.
John Hartnup, john.h@rtnup.net adapted it.

SEE ALSO

flickr.com

the Flickr::Upload manpage

One Response to “fp2flickr: Moving galleries from Fotopic to Flickr”

  1. Andy Says:

    This is great… Just what I was after. It worked a charm.

    As I don’t have many descriptions on fotopic, I made a small modification to allow it to use the filename as the flickr name (instead of “Image”). This does require that the gallery has the “show filenames” option set. I’ve happily uploaded many photos to flickr now.

    I also hacked apart the script and am running a version which is downloading all my fotopic to a local disk so I can burn them all to a CD.

    Thanks for a great little script.

Leave a Reply