Reconstructing photo albums from a Flickr data export
As every Flickr user knows, a year ago or so the service became subscription-based.
Initially I decided to stay with them as it was an handy service, but then I found myself not using it that much.
Moreover, they recently increased the monthly fee, so I opted to download the photos and store them locally.
Flickr allows to download all your data fairly easily, dividing it in ZIP archives of 500 photos each, so I downloaded by
26000+ photos. Problem is the pics are not divided into albums, so - especially if you have a lot of pics -
you get a huge mess which is very difficult to manage.
Luckily, in the downloadable data Flickr also provides all the information to programmatically reconstruct all the
structures. I was able to successfully move the files into different directories, divided by album name. I hope
sharing this experience will be useful to anyone who either is moving away from Flickr or just downloading the
data to keep a local copy.
In the downloaded data, there is an albums.json file, which has all album information in this structure:
Ain’t this perfect? Well, not exactly. You can’t just use the codes in the ‘‘photos’’ array as they are to find
the files belonging to an album, because:
The extension (JPG, MOV, PNG, …) is not provided
Files in the data export have names including the title, such as dublin-castle_5303007241_o.jpg
So, a little bit of programming is needed. Here’s my commented Perl script which does the job. This assumes that
you are in a directory containing:
All the downloaded photos/videos in a photos subdirectory
An empty albums subdirectory, where albums directories will be created
The script itself
For the rest, it’s mostly self-explanatory but I provided comments here and there.
The code relies on Mojo::File and Mojo::JSON
to achieve a clean and elegant approach to the solution of the task.