FlickrTouchr.py – keep your flickr album and favourites on an iPod Touch or iPhone

Posted on January 21, 2008, under general, photography.

One of the great things I really like about the iPod touch is that it makes an excellent portable viewer for photos. In return for sacrificing 1GB of potential music storage, I get about 2,000 browseable, zoomable photos onto something that’s always in my pocket. Cool!

Flickr sets on an Ipod     Flickr favourites on an Ipod

To make the process easier, here’s a python script to synchronise the photos on an ipod from a flickr account. It’s at http://www.stdlib.net/~colmmacc/flickrtouchr.py.txt. It should run on any *nix platform (personally I’m running it on a Mac) and there’s some kind of a chance it might even work on Windows (but who knows).

The whole thing is a single python file, as implementing the flickr API calls myself rather than use any of various python flickr libraries (as they each seem poorly maintained) seemed easier. One of the reasons I’m even putting it online is that beyond anything else, it may be useful as an example of a truly minimal python implementation with the flickr API.

You run the script like so;

    flickrtouchr directory-name

and after it asks you to authenticate against your flickr account, it will progress through syncing your entire flickr account into a directory hierarchy. It keeps a small cache of authentication data in the directory too. It will be organised like;

    directory-name/set-name/[photos]
    directory-name/other-set-name/[photos]
    directory-name/No Set/[photos]
    directory-name/Favourites/[photos]

If you have the same photo in multiple sets it will use hard-links to preserve local disk-space. It also only downloads the most optimal version of the photograph available for the iPod touch/iPhone screen. Everytime you run it, it downloads the missing photos and new sets. Once you configure iTunes to synchronise photos from a folder, rather than iPhoto, it works great.

iTunes syncing from a folder

Of course it will work with any other device or software that takes photo from a hierarchy of folders. Happy flickring.

12 Replies to "FlickrTouchr.py – keep your flickr album and favourites on an iPod Touch or iPhone"

gravatar

Paul Mison  on January 28, 2008

Nice script. I was planning to do this by having a Flickr set inside iPhoto, but this also lets you do things with other people’s photos (namely, your favourites), and it also saves me getting everything up and running, so I thought I’d give it a go.

However, it’s breaking on a photo of mine with a non-ASCII (UTF8) title, giving the error

Traceback (most recent call last):
File “/Users/blech/Desktop/touchr.py”, line 288, in
print photo.getAttribute(“title”) + ” … in set … ” + dir
UnicodeEncodeError: ‘ascii’ codec can’t encode character u’\xed’ in position 3: ordinal not in range(128)

I’ve got a vague idea of how to fix it, and I may come back with a patch, but for now I thought I’d at least make you aware of the issue. Thanks for the script anyway (and you’re right about unmaintained libraries- well, Ruby’s Flickr libs are in disrepair too, so I’m not entirely surprised Python’s the same way).

gravatar

colmmacc  on January 29, 2008

Thanks for the bug report Paul, the fix is;

--- flickrtouchr.py.txt	2008-01-28 23:51:13.000000000 +0000
+++ flickrtouchr.py.txt 2008-01-28 23:49:52.000000000 +0000
@@ -285,7 +285,7 @@
             # Grab the photos
             for photo in dom.getElementsByTagName("photo"):
                 # Tell the user we're grabbing the file
-                print photo.getAttribute("title") + " ... in set ... " + dir
+                print photo.getAttribute("title").encode("utf8") + " ... in set ... " + dir
                 # Grab the id
                 photoid = photo.getAttribute("id")

And I’ve updated the version online :-)

gravatar

Dennis Bonilla  on May 6, 2008

Is this resource still being maintained?
I ran into the following issue when trying to run it.

Traceback (most recent call last):
File “/Users/dbonilla/Desktop/pics/flickrtouchr.py”, line 222, in ?
url = flickrsign(url, config["token"])
File “/Users/dbonilla/Desktop/pics/flickrtouchr.py”, line 131, in flickrsign
query = urlparse.urlparse(url).query
AttributeError: ‘tuple’ object has no attribute ‘query’

gravatar

Dennis Bonilla  on May 8, 2008

I appear to only receive that error on a 10.4 machine. The script ran flawlessly on OS X 10.5.2. Thank you!

gravatar

Larry Rosenstein  on June 6, 2009

That error appears if you run the script on a Python older than 2.5. (OS X 10.4 ships with 2.3.x.) I got it to run on 2.3 by changing:

query = urlparse.urlparse(url).query

to:

query = urlparse.urlparse(url)[4]

gravatar

fozbaca  on June 6, 2009

All my photos are downloading corrupted. I’m using Python 2.6.2 on Windows7RC. Any suggestions?

gravatar

tozĂ©  on June 10, 2009

my favorites downloaded without problems, but when it got to my own photos it would spit back this

Failed to get original for photo id xxxxxxxxxx
Failed to retrieve photo id xxxxxxxxxx

I’m running the script on 10.5.6
Thank you

gravatar

Backing up Flickr « Petersen Did It  on August 17, 2009

[...] helped the trust in the “cloud” at all. So what can you do? Well Dan Benjamin took the FlickrTouchr script which allowed you to download a flickr set to your ipod and modified it to backup your all [...]

gravatar

bonny  on September 16, 2009

Thank you! I’m on a Mac OS X 10.4 and flickredit did not back up my photos (even though it claimed success). Thought I would try this – thanks @larry rosenstein as well who fixed the python 2.3 issue..

gravatar

Peters Linkschleuder – Der Schockwellenreiter  on November 5, 2009

[...] hier geht jemand einen anderen Weg (auch mit Hilfe von Python und FlickrTouchr): Backing Up [...]

gravatar

climent  on September 2, 2010

I get a new error with the script:

Traceback (most recent call last):
File “flickrtouchr.py”, line 288, in
pages = int(dom.getElementsByTagName(“photo”)[0].parentNode.getAttribute(“pages”))
IndexError: list index out of range

Any idea what the problem might be?

gravatar

climent  on September 2, 2010

Oh, wait… it was the auth token, had expired.

Leave a Comment