2013 Aug 4

How to download whole Flickr album

There are third party app to download a complete album set. But you need to find them, select one, register, then log with you credentials... And finaly get a [possibly bad] result.

One short way is to use few GNU/Linux tools. Be aware that this works as in August 2013 and is subject to break if the Flickr code change. However it is easy to understand an improve. It's a quick-an-ugly solution.

Get the original file

Example with the Lionel's Nosy Komba album.

  1. First step, get the album web page and do the following with all available pages (could be parsed from the first one but is it really needed?)
    wget http://www.flickr.com/photos/88206719@N00/sets/72157633679672808/
     wget http://www.flickr.com/photos/88206719@N00/sets/72157633679672808/page2/
  1. Then change the source code to be easily readable by grep. We get one picture (id) json data description per line.
    sed -i 's/\("id":\)/\n\1/g' *.html*
  1. Now we export all available pictures to an external file
    grep Original *.html* |sed -n 's#.*"label":"Original",.*url":"\(.*\)\(_o.jpg\).*#\1\2#p' | sed -n 's#\\##gp' >> pics
  1. We can check that we have the correct number of URLs (it's written on the album summary at flickr.com)
    cat pics |wc -l
    141
  1. And finally, download them in a batch!
    wget -i pics
  1. Once wget has finished, we get the result:
    Total wall clock time: 10m 2s
    Downloaded: 143 files, 350M in 9m 14s (648 KB/s)

I don't handle errors, wget does it for us (143 files instead of 141)

Get the large resolution

If you don't need to download the original pics, it is far more easy to get them. Flickr export your original file in several resolutions which have specific file extensions.

For example, to download them 1024px, you just have to add _b to the file name. The current "issue" is that the original file and higher resolutions even have a different name... I don't say that _b will always work, but it was for several album and about a thousand a pictures today.

Here is a short code to do this from scratch:

wget http://www.flickr.com/photos/88206719@N00/sets/72157633679672808/
wget http://www.flickr.com/photos/88206719@N00/sets/72157633679672808/page2/
grep -r  "data-defer-src" * | sed -n 's#.*data-defer-src="\(.*\)\(\.jpg\).*#\1_b\2#p' >> pics
wget -i pics

And that's all! To know more about file resolutions, read the doc!

Please, don't forget to save the album license on your folder.