Skip to content

Instantly share code, notes, and snippets.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@raresct
raresct / api_wrapper.py
Last active December 13, 2015 22:08
zipf_lastfm
class LastFmApi:
def __init__(self, api_key=None):
self.api_key = api_key
def call(self, method=None, artist=None, limit=None, user = None, api_key=None):
if api_key is None:
api_key = self.api_key
addr = 'http://ws.audioscrobbler.com/2.0/?'
aritst, user = [urllib2.quote(x) if x else '' for x in [artist, user]]
addr += '&api_key={}&method={}&artist={}&user={}&limit={}'.format(api_key, method, artist, user, limit)
addr +='&format=json'