gapi-querier icon indicating copy to clipboard operation
gapi-querier copied to clipboard

Add command that creates an album with all not-in-album photos

Open maximan3000 opened this issue 2 years ago • 4 comments

It would be much better to create another album that accumulates all photos you need to sort/remove. Solution: add command that creates an album and fills it with photos Pros:

  1. You can immediately see all photos that are not in albums instead of clicking on links
  2. You can easyly add any photo to another album or delete it using google-photos app in any time/place

maximan3000 avatar Nov 01 '22 22:11 maximan3000

Would love to see this @jonagh! Would you give me a quick onboarding to the source code, and I can try to add this feature?

FdelMazo avatar Jan 21 '23 19:01 FdelMazo

Ya sure. The reason I didn't do this was 1) I didn't want it for my own purposes, 2) I wanted to avoid getting write permissions, just so it was "safer". But, I totally see how putting the photos into an album could be useful for many.

Regarding the code...

  • The authentication is handled for you and will be contained in google's auth api state (import /auth.js to access it). You can look at /helpers/google-photos.js and see an example of the import and the auth.getCachedAccessToken() call.
  • You'll need to create a file to contain your new code and expose the new functionality, this file should be in the /commands/ folder. It needs to export: name, scopes, and an async run(gapi) function (see example.js and findOutOfAlbumPhotos.js in the /commands folder as examples). The name is simply for displaying in the commands dropdown, the scopes is the google API permissions that are required, the user will allow these permissions when they authorize the 'app'. The run function is what will be invoked when the user selects the command from the dropdown and clicks run.
  • See google api docs for API details, including scopes: https://developers.google.com/photos/library/reference/rest/v1/albums/create
  • In order for the new command to be available in the dropdown you'll need to add it to the /commands.js file in the root, just import and include in the exported array, same as is done for findOutOfAlbumPhotos.
  • You may want to modularize some of the code, there is a /helpers folder that I put some code into, this is just as a place to organize some stuff, nothing special about /helpers folder. You might want to add to the existing google-photos.js file (you'd probably need to refactor the exported function so it has a better name, instead of just request) - or just create your own file, or just keep all your functionality in the file you created in /commands.

Hope that was somewhat helpful :)

jonagh avatar Jan 21 '23 20:01 jonagh

Sorry :(

I ended up scratching my itch with another method* and have no need to code this feature for now. Thanks for detailing it for the next person that reads this!

* I wanted to see every non-albumed picture within the photos app to categorize them in new albums. Considering I never used the google photos archive feature I simply archived every albumed picture and ended up having every non-albumed picture in the main photos screen. After classifying those pictures, I de-archived everything!

FdelMazo avatar Jan 31 '23 22:01 FdelMazo

At the moment Google Photos API allows creating photos and albums with API. But even with full write access you can't add photos you already own to the new album.

https://issuetracker.google.com/issues/132274769

Alexkurd avatar Nov 26 '23 16:11 Alexkurd