Wednesday, February 17, 2010

picasa gdata API and face recognition

Tonight I wanted to download a list of photos from picasaweb with a particular person in them, using the "subjectids" field. I don't see any official way to do this, but here's how I managed it:

In picasaweb (in my web browser), I loaded up the page showing all the photos my friend was in. At the bottom, there was a little "RSS" link. That link looked like this:

http://picasaweb.google.com/data/feed/base/user/credentiality?alt=rss&kind=photo&subjectids=SOME_BIG_LONG_STRING_OF_CHARACTERS&authkey=A_SHORTER_STRING&hl=en_US

I loaded that link in my browser, and it gave me the option to keep it as a live bookmark.

Instead, I trimmed the URL down and plunked it in this little python gdata script:


#!/usr/bin/python

import gdata.photos.service
import gdata.media
import gdata.geo

gd_client = gdata.photos.service.PhotosService()

gd_client.email = 'MY_EMAIL_ADDRESS'
gd_client.password = 'MY_PASSWORD'
gd_client.source = 'exampleCo-exampleApp-1'
gd_client.ProgrammaticLogin()

print "logged in"

photos = gd_client.GetFeed('/data/feed/base/user/credentiality?kind=photo&subjectids=THE_SAME_BIG_LONG_STRING')

for photo in photos.entry:
print photo.content.src


That printed out a list of URLs to the images I wanted.

3 comments:

avigmati said...

thank you.

soku said...

Is this working still? I have trouble with this in .net, somebody can try this?

Anonymous said...

Worked fine for me just now. Did you remember to change "credentiality" to your username in the GetFeed call?