Hazel + Google Photos API

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

Hazel + Google Photos API Tue Sep 24, 2019 9:43 am • by lnjustin
I have synced a folder of photos on my computer to Google Photos. i want to monitor that folder for changes, then use the Google Photos API to search for the added/modified photo in Google Photos, and add the photo to an album depending on the metadata tags in the photo. So, if the Rating tag is 5, add the photo to a 5 star album in Google Photos. What’s the best way to run Google Photos API calls like this from Hazel? It’s a REST based API that used JSON.

I don’t really know if I need to create a JavaScript script of sorts outside of Hazel, and then have Hazel call that script? But I would need to pass parameters to the script somehow. Or if I can just do it all in an embedded script in hazel? Any direction on how to go about this using Hazel would be much appreciated! I think I can code it up once I figure out the framework and environment I should be using to use the API.
lnjustin
 
Posts: 10
Joined: Sun Dec 23, 2018 3:43 pm

Re: Hazel + Google Photos API Tue Sep 24, 2019 10:03 am • by Mr_Noodle
It shouldn't matter whether a script is embedded or external. It determines where the script is stored. By the way, we are talking about the "Run shellscript" action here.

You can set up javascript as the "shell". Hazel will pass in the path to the file that matched the rule as the first argument. Not sure if that is enough for you or not.
Mr_Noodle
Site Admin
 
Posts: 8363
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Hazel + Google Photos API Tue Sep 24, 2019 10:07 am • by lnjustin
Ok thanks. I think that’s enough for now. I still need to learn a bit more about how to do this. But your response seems to suggest it should be possible, so I won’t be wasting my time learning how to use the Google Photos API. Thanks!
lnjustin
 
Posts: 10
Joined: Sun Dec 23, 2018 3:43 pm

Re: Hazel + Google Photos API Tue Sep 24, 2019 12:37 pm • by lnjustin
Well, now I’m wondering why you mentioned run shellscript as the command rather than just run JavaScript? I don’t really know which of those I need to use. If I run JavaScript via shell script it’s looking like I will need some node.js stuff for it to work first.
lnjustin
 
Posts: 10
Joined: Sun Dec 23, 2018 3:43 pm

Re: Hazel + Google Photos API Wed Sep 25, 2019 9:59 am • by Mr_Noodle
"Run shellscript" can run scripts in whatever language you provide an interpreter for. The "Run Javascript" action is odd in that it will run JavaScript but in a special context that is the same as "Run AppleScript". It's basically like AppleScript but using JavaScript instead. It allows you to send Apple Events to other apps to communicate with them which is probably not applicable here.
Mr_Noodle
Site Admin
 
Posts: 8363
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support