Google Photos integration

Why?

Throw your photos in Obsidian / link to photos
Cameras are the most frictionless sensors to capture the physical world

It would be nice if we can filter which photos are sync in the vault, especially automatically with the semantic

This is obviously not as fully featured as what you’re asking for, but if you want an easy way to embed Google Photos into your notes, this is what I do.

It lets you take a Google Photo link, and add it to a note as either:

  • a text link
  • a thumbnail with the image data hosted externally on Google Photos
  • or a thumbnail with the thumbnail image saved locally in your vault.

Clicking any of the above will take you to the fullsize photo in Google Photos.

1 Like

Cool :slight_smile:

also played a bit with the API

const photo = async () => {
    document.body.style.cursor = "wait";
    const url = "https://photoslibrary.googleapis.com/v1/mediaItems:search";
    const fs = require('fs');
    const photoAuthToken = fs.readFileSync('/Users/louisbeaumont/Documents/brain/.env', 'utf8')
        .split("\n")
        .filter(line => line.startsWith("GOOGLE_PHOTO_AUTH_TOKEN"))[0]
        .split('"')[1];
    const response = await fetch(url, {
        method: "POST",
        headers: {
            "Authorization": "Bearer " + photoAuthToken,
            "Content-Type": "application/json",
        },
        body: JSON.stringify({
            filters: {
                contentFilter: {
                    includedContentCategories: [
                        "PEOPLE",
                    ]
                }
            }
        })
    }).then(response => response.json());
    console.log("Response:", response);
    document.body.style.cursor = "default";
    return response.mediaItems.slice(0, 5).map((item) => `![${item.filename}](${item.baseUrl})`);
}
module.exports = photo;

Sadly, multimodal semantic search is not available in the API (i.e. I can’t ask “give me my pics with this person at this place” in full text)

I’ll probably implement semantic search myself then with OpenAI CLIP or some other multimodal model

1 Like

That’s fantastic!! I can’t wait to try this out!

How did you enable token access? I only see the ability to connect via OAuth2.

As an aside, even though it’s not a standard .env format, if you use JSON in that file it makes your life a lot easier to parse and access the keys/data:

const conf = JSON.parse(fs.readFileSync(app.vault.adapter.basePath + '/.env'))
1 Like

Google Photo documentation is not very good and IDK how to use cleanly npm deps with Templater so I just cloned this

And console logged the token (dirty manual solution, hopefully the token does not expire)
(unfortunately can’t use service account or API key with Google Photo API)

PS: thanks for the json tip, my solution to store token is quite dirty indeed xD

1 Like

@louis030195 and anyone else interested in this topic:

I have created a Google Photos plugin which let’s you insert Google Photos images directly into Obsidian. When you select an image, it will save and embed a low-res thumbnail with a link back to the full-res image on Google Photos.

If your note title has a detectable date, you can have the plugin default to showing you only photos from that date. There is a toggle at the top to show all photos instead.

The plugin is currently under review by Obsidian team, but you can install and test out immediately using BRAT.

My plugin repo is here:

2 Likes

Amazing

Trying to imagine this integrated in canvas - navigate your life as an infinite graph / cluster

1 Like

Can you give me an example of how you’d use it in Canvas? It sounds cool to implement, but I’m not sure what you’d do with it in a canvas.

There is already codeblock support, and you can add the filters like you had in your original post (currently only supports JSON format):

```photos
{
  "filters": {
    "contentFilter": {
      "includedContentCategories": [
        "PEOPLE"
      ]
    }
  }
}
```

So if canvases support codeblocks then you can add those.

@AlanG ! I don’t believe!
A couple days I was thinking how great with I can use my google photos with obsidian and you rock!

I was trying to install, but I had this warning…
Screenshot 2022-12-20 at 21.42.16

Best!

1 Like

Thanks for letting me know! I’ve never made a plugin before, so I hadn’t published it correctly.

This is now fixed and I can confirm it’s working for me in BRAT in a test vault.

Please let me know if it works for you.

Amazing! it works perfectly!

1 Like