Skip to content

Instantly share code, notes, and snippets.

@aceat64
Created January 17, 2017 03:55
Show Gist options
  • Save aceat64/7134e8f98d146fb04b6c8a6d051bd45f to your computer and use it in GitHub Desktop.
Save aceat64/7134e8f98d146fb04b6c8a6d051bd45f to your computer and use it in GitHub Desktop.
Delete duplicate files from google music
#!/usr/bin/python
from gmusicapi import Mobileclient
import sys, json
api = Mobileclient()
logged_in = api.login('[email protected]', 'password_or_app_password_if_using_2fa', Mobileclient.FROM_MAC_ADDRESS)
if logged_in:
count = 0
dupes = 0
songs = api.get_all_songs()
song_set = set()
songIds_to_delete = []
for song in songs:
count = count + 1
song_tuple = (song['title'], song['album'])
if song_tuple in song_set:
print("Found duplicate song!\n\tTitle: {s[title]}\n\tAlbum: {s[album]}".format(s=song))
dupes = dupes + 1
songIds_to_delete.append(song['id'])
else:
song_set.add(song_tuple)
print("Found "+str(dupes)+" duplicate songs out of "+str(count)+" total")
print("Deleting duplicate songs now!")
# api.delete_songs(songIds_to_delete)
@aceat64
Copy link
Author

aceat64 commented Jan 17, 2017

Be sure to set the right username and password. If everything looks good, uncomment the last line to actually delete the songs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment