Benno Richters
Benno Richters

Reputation: 15683

Accessing older photos using the Picasa API

Is it possible to get a list of photos from Picasa (or Google Plus that still uses the Picasa API) that are older than a certain date? I would like to get all photos from today a year ago from a large album, the "InstantUpload" album.

These are the things I looked into:

Upvotes: 4

Views: 473

Answers (1)

Ruud Helderman
Ruud Helderman

Reputation: 11018

EDIT: googlecl has been discontinued. Its deprecated OAuth version is no longer accepted by Picasa. The approach described below no longer works. You may find an alternative in Picasa Web Albums Data API.


I automated my own Picasa-related tasks with googlecl. I am using it on Linux, but there is a Windows version too. Yes, it's a command line tool; don't let that scare you off, you should be able to call the tool and capture its output from your favorite programming language (Java, C#, whatever).

Running googlecl for the very first time on your machine requires you to log on with your Google account, but after you have done that once, googlecl will remember your authentication and will not bother you ever again.

So your album is named InstantUpload. The following command will download a list of photos (date/time published + URL).

google picasa list --title="InstantUpload" --fields=published,url-direct --delimiter=" " > FullList.txt

AFAIK, there are no command line options to filter on a certain date range. You can filter on tags, but that would require you to assign a date-like tag to every photo in your album. Unless the download time of the list bothers you (and you are having some really good reason not to split up that single big album into multiple smaller ones), I would suggest to do the filtering yourself, immediately following the download.

I find CLI convenient, so I will demonstrate some simple shell scripting. But of course you can do the filtering in any programming language you like.

First, let's retrieve the UTC date of one year ago (formatted yyyy-mm-dd):

maxdate=$(date -u --date="1 year ago" +%F)

Use your favorite filter tool (grep, sed, awk, perl) to filter the list; keep only the lines with publish date < maxdate.

awk "\$1 < \"$maxdate\" { print \$2; }" FullList.txt > FilteredList.txt

(AWK is available for virtually every OS.)

You can even automate downloading the photos themselves. Make sure you cd to an appropriate data folder first.

while read url; do
    wget "$url"
done < FilteredList.txt

Put it all together in a shell script file, and a single call is enough to do all the hard work for you.

Upvotes: 2

Related Questions