xob0t / Google-Photos-Toolkit

Userscript to filter, search, organize, or delete your Google Photos library
MIT License
78 stars 3 forks source link

Export and import media album info #3

Open xob0t opened 3 months ago

xob0t commented 3 months ago

Suppose you want to reupload you media from a Pixel device, but downloading, deleting and uploading will remove all reuploaded media from all albums. To solve this, album info for each item can be extracted and then imported to restore the album assignment.

oryjkov commented 3 weeks ago

Yeah, that would be amazing! :)

Right now this tool is really handy to re-upload any google photo media that is not in an album, which in my case, was responsible for about 50% of storage. The rest would require keeping the album associations like you're proposing here.

I suppose this could just be a CSV that gets exported by the tookit before doing a move, then ingested after re-upload to automate restoring the existing albums?

Have you thought of what is sufficient to uniquely identify photos? Filename won't cover all cases (but might be OK if it could ignore any possible collisions before doing anything to the files). Does the "undocumented api" export file checksums? That would be nice :)

xob0t commented 3 weeks ago

I suppose this could just be a CSV that gets exported by the tookit before doing a move, then ingested after re-upload to automate restoring the existing albums?

Yes, but i'm thinking json instead of csv

Have you thought of what is sufficient to uniquely identify photos? Filename won't cover all cases (but might be OK if it could ignore any possible collisions before doing anything to the files). Does the "undocumented api" export file checksums? That would be nice :)

Filename + size would be enough I guess. Checksums would be nice, but api does not expose them.


There is a way to do it with the current capabilities of the script, but it requires more manual action.

  1. Make sure every media item in your library belongs to at least one album. Use "Exclude albums" filter, select all of them, select action "add to album" You may encounter #2, just run it again, create a new album, until none are left.
  2. Download a single album, delete all its media, reupload
  3. Again use "Exclude albums" filter in the same way, now all your reuploaded items will be grouped in an album.
  4. Repeat for every album

I have not tested it myself, but it should work.

oryjkov commented 3 weeks ago

I have a POC in my fork that worked for me to get down to 0 bytes of google photo quota usage, while keeping all the photos, and seemingly in the correct albums. There are some downsides - more on them later. @xob0t let me know if you have any interest in merging it in, but be warned I don't have much experience with JS.

The workflow I was using is as follows:

  1. Add all photos that take up space to a new album and at the same time use the new feature to download a JSON file that contains info about all existing albums and all photos. This is generated automatically in the "Albums" GPTK source. I just select all albums and filter on "Takes up space". Make sure to keep the file that this step downloads, "albums.json". It is used in a later stop.
  2. Download all media from the new album.
  3. Delete all media in that album and purge Trash.
  4. Upload all media in step 2 using a pixel 1-5 phone.
  5. Re-assign the "new" media to the original albums: Use the "Library" source and filter on "Date uploaded" to pick up the items uploaded in step 4 only. Then select "Upload album mapping" and pass in the file "albums.json" from step 1. Click Submit. Before any items are added to albums, there will be another confirmation step and a new file, "actions.json" will be downloaded. It should be inspected to verify what the app is about to do.
  6. Click Submit and the app goes through all the media files and restores them to existing albums (shared and non-shared albums work).

Downsides:

xob0t commented 2 weeks ago

@oryjkov great, i'll take a look when i get the time!