英文:
Oops: Need to delete photos from Google Photos
问题
I've used to Google Photos API to back up a bunch of old photos (31,748 of them) on my local server to Google Photos. Unfortunately, I messed up the process. Now I need to delete all 31,748 photos. (I only want to delete the photos that this app created, not all of my photos.) Unfortunately it appears from various previous questions here that Google Photos API does not have a method for deleting (and they have in fact closed all such requests, saying this is not what the API is intended for!). I'm wondering if anyone has any creative ideas? I have the IDs of all the photos I want to remove.
英文:
I've used to Google Photos API to back up a bunch of old photos (31,748 of them) on my local server to Google Photos. Unfortunately, I messed up the process. Now I need to delete all 31,748 photos. (I only want to delete the photos that this app created, not all of my photos.) Unfortunately it appears from various previous questions here that Google Photos API does not have a method for deleting (and they have in fact closed all such requests, saying this is not what the API is intended for!). I'm wondering if anyone has any creative ideas? I have the IDs of all the photos I want to remove.
答案1
得分: 1
I came up in an imperfect solution. I search for all photos that the app uploaded using:
nextpagetoken = ''
itemids = []
while True:
results = service.mediaItems().search(
body={'filters': {'excludeNonAppCreatedData': True}, 'pageSize': 100, 'pageToken': nextpagetoken}).execute()
items = results.get('mediaItems', [])
for item in items:
itemids.append(item['id'])
nextpagetoken = results.get('nextPageToken', '')
if not nextpagetoken:
break
Then I take groups of 500 of them and add them to an album. Those albums are small enough to open in my browser without issue (unlike the 20,000-picture album). Then I just select the first one, scroll to the bottom, hold Shift and select the last one, then hit the Trash button and confirm. It takes about 30 seconds per 500 photos.
英文:
I came up in an imperfect solution. I search for all photos that the app uploaded using:
nextpagetoken = ''
itemids = []
while True:
results = service.mediaItems().search(
body={'filters': {'excludeNonAppCreatedData': True}, 'pageSize': 100, 'pageToken': nextpagetoken}).execute()
items = results.get('mediaItems', [])
for item in items:
itemids.append(item['id'])
nextpagetoken = results.get('nextPageToken', '')
if not nextpagetoken:
break
Then I take groups of 500 of them and add them to an album. Those albums are small enough to open in my browser without issue (unlike the 20,000-picture album). Then I just select the first one, scroll to the bottom, hold Shift and select the last one, then hit the Trash button and confirm. It takes about 30 seconds per 500 photos.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论