Wednesday, March 10, 2021

On This Day, Google Photos Edition

A First World Problem

With so many meetings and events being held on Zoom I found I had a new first world problem: what photo should I select for my background?

After a bit of experimentation I arrived at a solution: I'd look at    photos that I taken on the current date going back a few years, and pick from one of those.

While I did this to help narrow the photos to pick from, it had surprising side effects. I found it instructive and inspirational to look back through the years and see where I was traveling and what projects I was working on. Picking a background became a useful little exercise in itself.

The Manual Solution

Convincing Google Photos to show photos taken on a particular day took a bit of experimentation. I found what works best is to search for date spelled out and quoted like so: "March 10, 2010". Yes, the quotes are necessary. Attempts use other formats didn't work reliably.

The Automated Solution

Naturally, I got tired of searching by hand. So I made an app for that. I give you: https://code.benjisimon.com/on-this-day/.

This little web app is slow and buggy. Most of the coding effort was spent getting OAuth2 authentication to work, and even then it's struggling with token-refreshing. I also spent more time than I'd like to admit puzzling out how to call the searchMediaItems method on the PhotosLibraryClient. Ultimately, I figured out how to get it to accept the specific date and result size I was targeting.

Still, as rough as the app is, it meets the need. I can now visit the on-this-day, and after a few moments, I see photos I took going back to 2010.

I'm now using this to set my desktop background on a daily basis. I'm telling you, this little walk down memory lane is surprisingly enlightening.

Check out the code for on-this-day over at github. If you're looking for OAuth and Google Photo PHP API SDK examples, this code may be instructive. Or maybe it's a cautionary tale. Either way, I hope you find the code and site useful.

No comments:

Post a Comment