xob0t / Google-Photos-Toolkit

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

[Feature Idea] Any way to search for all photos "Shared by a Google user"? #8

Open jindalshreyansh opened 1 month ago

jindalshreyansh commented 1 month ago

My library consist of photos that I saved from various shared album and partner account. Now, I have filtered photos not owned by me using gptk, can I futher filter them by ownership of specific person?

xob0t commented 1 month ago

theoretically possible, but would require sending a request to get each file's info, so it would be slow

and be vary of the ownership filter, it produces inconsistent results

jindalshreyansh commented 1 month ago

Ownership filter worked fine for me, it separated all files not owned by me in a separate album. Could you guide what request to send in order to get photos owned by specific people.

xob0t commented 1 month ago

It would not be possible to just get all media owned by "x", the only way is to scan the library, then for each media item send a request to get that info, and filter based on it.

xob0t commented 1 week ago

@jindalshreyansh @leocrawford

Here is a little POC script to find and delete "shared by x" items. Goes over the whole library one item at a time. If item's sharedByUserName matches sharedByName, moves the item to trash. Paste it to your browser's console. Reload the page to stop the script.

let nextPageId = null;
const sharedByName = 'John';
do {
  const page = await gptkApi.getItemsByUploadedDate(nextPageId);
  if (!page?.items) console.error('No items found on the page!');

  for (const item of page.items){
    if (item.isOwned) continue
    const extInfo = await gptkApi.getItemInfoExt(item.productId);
    if (extInfo.sharedByUserName == sharedByName){
      await gptkApi.moveItemsToTrash([extInfo.mediaId]);
      const fullInfo = { ...item, ...extInfo };
      console.log('item moved to trash', fullInfo);
    }
  }
  nextPageId = page.nextPageId;
} while (nextPageId);
console.log("DONE")
leocrawford commented 1 week ago

Thank you so much. That's really helpful. In the end I archived by date uploaded, restored those taken by my partners phone, and deleted those in archive - but this would have been much better, and is what I'll use next time (if there is a next time).

I'm also rebuilding my own library from scratch, using my own API key (rather than rclones) so I can share albums, rather than rely on partner sharing. SO much learnt. Your tool has been an invaluable part of fixing my own mistakes, so thank you.