Skip to content

Instantly share code, notes, and snippets.

@simon-weber
Last active November 27, 2019 21:57
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simon-weber/5007769 to your computer and use it in GitHub Desktop.
Save simon-weber/5007769 to your computer and use it in GitHub Desktop.
approximations of Google Music auto playlists
from operator import itemgetter
from gmusicapi import Api
api = Api()
api.login('me@gmail.com', 'my-password')
# => True
lib = api.get_all_songs()
# This assumes you're using thumbs up/down.
# Change this to, eg, t['rating'] > 3 if you're using 5-star ratings.
thumbs_up = [t for t in lib if t['rating'] == 5]
# This doesn't completely match Google's calculation, but it's certainly a valid interpretation.
# It only seems to differ slightly.
last_added = sorted(lib, key=itemgetter('creationDate'), reverse=True)
free_and_purchased = [t for t in lib if t['type'] == 1]
# Shared with me and Google Play recommends are calculated on the server, but I
# haven't implemented those calls yet.
@mofrank
Copy link

mofrank commented Feb 21, 2013

Ahh.. type == 1 that is what I was missing

Thanks

@imthenachoman
Copy link

will api.get_all_songs get songs that you've thumbsed up but aren't in your library?

@simon-weber
Copy link
Author

will api.get_all_songs get songs that you've thumbsed up but aren't in your library?

Unfortunately, no. Here's the issue to follow for that: simon-weber/gmusicapi#182.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment