Created
April 23, 2018 05:19
-
-
Save uogbuji/31803078f9f0921341c7ebf9c72596a0 to your computer and use it in GitHub Desktop.
Notes on managing Google Music from Python
This file contains hidden or 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
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