Skip to content

Instantly share code, notes, and snippets.

@uogbuji
Created April 23, 2018 05:19
Show Gist options
  • Save uogbuji/31803078f9f0921341c7ebf9c72596a0 to your computer and use it in GitHub Desktop.
Save uogbuji/31803078f9f0921341c7ebf9c72596a0 to your computer and use it in GitHub Desktop.
Notes on managing Google Music from Python
import sys
from gmusicapi import Mobileclient
playlistname = sys.argv[1]
email = sys.argv[2]
passwd = sys.argv[3]
api = Mobileclient()
api.login(email, passwd, Mobileclient.FROM_MAC_ADDRESS)
plc = api.get_all_user_playlist_contents()
target = next((p for p in plc if p['name'] == playlistname))
print('Pulling library...', file=sys.stderr)
library = { i['id']: i for i in api.get_all_songs() }
tracknames = set()
for t in target['tracks']:
if t['trackId'] in library:
l = library[t['trackId']]
title = l.get('title')
dupmsg = '[duplicate]' if title in tracknames else ''
tracknames.add(title)
print(l.get('artist'), '/', l.get('albumArtist'), '-', l.get('title'), dupmsg)
else:
#pass
print('Library mismatch:', t)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment