Skip to content

Instantly share code, notes, and snippets.

@mbrownnycnyc
Last active August 29, 2015 14:18
Show Gist options
  • Save mbrownnycnyc/707aa5b7c3660a1e0f34 to your computer and use it in GitHub Desktop.
Save mbrownnycnyc/707aa5b7c3660a1e0f34 to your computer and use it in GitHub Desktop.
Quick gmusicapi to export all track titles from gmusic to a csv.
from gmusicapi import Mobileclient
api = Mobileclient()
api.login('[email protected]', 'AppSpecificPassword')
all_gmusic_tracks = api.get_all_songs()
len(all_gmusic_tracks)
import csv
#https://unofficial-google-music-api.readthedocs.org/en/latest/reference/mobileclient.html?highlight=track#gmusicapi.clients.Mobileclient.get_all_songs
with open('c:\gmusictracks.csv', 'wb') as myfile:
fieldnames = ['artist', 'album', 'title']
writer = csv.DictWriter(myfile, fieldnames=fieldnames)
writer.writeheader()
wr = csv.writer(myfile, quoting=csv.QUOTE_ALL)
for track in all_gmusic_tracks:
song_entry = [track['artist'].encode('ascii', 'ignore'),track['album'].encode('ascii', 'ignore'),track['title'].encode('ascii', 'ignore')]
wr.writerow(song_entry)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment