Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Delete duplicate entries from Google Play Music user playlist
from gmusicapi import Mobileclient
# Get gmusicapi: https://github.com/simon-weber/Unofficial-Google-Music-API
# This script iterates through all your playlists, and deletes any playlist entries that
# have a duplicate later on in the same playlist.
api = Mobileclient()
logged_in = api.login('email@sharklasers.com', 'nice try :P')
playlists = api.get_all_user_playlist_contents()
leading_dupes = []
for playlist in playlists:
entries = playlist['tracks']
def have_i_dupe_ahead(entry, entries, idx):
for t in entries[(idx+1):]:
if entry['trackId'] == t['trackId']:
return True
return False
for idx, entry in enumerate(entries):
isdupe = have_i_dupe_ahead(entry, entries, idx)
if isdupe:
leading_dupes.append(entry)
entry_ids = [entry['id'] for entry in leading_dupes]
api.remove_entries_from_playlist(entry_ids)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.