Last active
August 5, 2016 19:18
-
-
Save hughrawlinson/b7bd83fe7476d31b0a26980eb67e5c8b to your computer and use it in GitHub Desktop.
Spotipy for MicroPython
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 http_client | |
import ujson | |
endpoint = 'https://api.spotify.com/v1' | |
def get(url): | |
print(url) | |
r = http_client.get(url) | |
r.raise_for_status() | |
return ujson.loads(r.text) | |
def albums(id): | |
# if typeof id = 'list': format query properly | |
return get(endpoint+'/albums/'+id) | |
def albums_tracks(id): | |
return get(endpoint+'/albums/'+id) | |
def artists(id): | |
# if typeof id = 'list': format query properly | |
return get(endpoint+'/artists/'+id) | |
def artists_albums(id): | |
return get(endpoint+'/artists/'+id+'/albums') | |
def artists_top_tracks(id): | |
return get(endpoint+'/artists/'+id+'/top-tracks') | |
def artists_related(id): | |
return get(endpoint+'/artists/'+id+'/related') | |
def search(type,query): | |
return get(endpoint+'/search?type='+type+'&q='+query) | |
def tracks(id): | |
# if typeof id = 'list': format query properly | |
return get(endpoint+'/tracks/'+id) | |
def users(id): | |
return get(endpoint+'/users/'+id) | |
if __name__ == "__main__": | |
print(search('track','gold')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment