Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export and import media album info #3

Open
xob0t opened this issue Mar 31, 2024 · 5 comments
Open

Export and import media album info #3

xob0t opened this issue Mar 31, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@xob0t
Copy link
Owner

xob0t commented Mar 31, 2024

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.

@xob0t xob0t added the enhancement New feature or request label Mar 31, 2024
@oryjkov
Copy link

oryjkov commented Jun 8, 2024

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
Copy link
Owner Author

xob0t commented Jun 9, 2024

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 20000 items per album limit is not accounted for #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
Copy link

oryjkov commented Jun 10, 2024

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:

  • This is some random javascript trying to add a bunch of your photos to the shared albums that you're a member of. There is potential for embarrassment.
  • Re-adding photos to shared albums generates notifications to all album participants.
  • Photos that were already stored using "space saver" get compressed further losing some quality. Unless a pixel 1 device is used that can back up in original quality.
  • Description is lost
  • Favorite markings are lost
  • Since the album mappings are based only on the (uppercase) file names, identical files won't work. Those (should) be filtered out automatically in step 1 - it picks just one file, so running these steps again will reduce each group of duplicates further. (I have not tested it as there was only one duplicate file name in my collection).
  • This might not work for massive photo collections as all the mappings are kept in memory. In my case the mapping file was under 10MB so it was easy.
  • Photos without a proper creation timestamp in their EXIF end up being dated by google photos as if they were taken at the time of re-upload.

@xob0t
Copy link
Owner Author

xob0t commented Jun 12, 2024

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

@jcdauchy
Copy link

jcdauchy commented Jan 4, 2025

Thanks @oryjkov and @xob0t, I have a different use case where I need to create albums for uploaded photos. I can create a JSON file with a an array of "Album name" and list of productID of photos to be included in this album.

I will start with @oryjkov code and try to make it work with my use case. I have never coded in javascript so it will take me some time !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants