Skip to content

Instantly share code, notes, and snippets.

@xeBuz
Last active February 13, 2018 13:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xeBuz/4389610 to your computer and use it in GitHub Desktop.
Save xeBuz/4389610 to your computer and use it in GitHub Desktop.
Get artists and tracks w/playcounts form Lastfm user.
#!/usr/bin/python2
# -*- coding: utf-8 -*-
import pylast
api_key = '189c5354198342a01be847e595afbb14'
username = 'eikiu'
api = pylast.LastFMNetwork(api_key = api_key)
user = pylast.User(username, api)
library = user.get_library()
for artist in library.get_artists():
print artist.item.name + " (" + str(artist.playcount) +")"
tracks = library.get_tracks(artist = artist.item.name, limit=None)
for track in tracks:
print "\t" + track.item.title + " - plays: " + str(track.playcount)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment