Created
January 17, 2017 03:55
-
-
Save aceat64/7134e8f98d146fb04b6c8a6d051bd45f to your computer and use it in GitHub Desktop.
Delete duplicate files from google music
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Be sure to set the right username and password. If everything looks good, uncomment the last line to actually delete the songs.