-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathechonest.py
More file actions
37 lines (27 loc) · 909 Bytes
/
echonest.py
File metadata and controls
37 lines (27 loc) · 909 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import os
import simplejson
import urllib
import urllib2
import logging
from pyechonest import config, artist, song
logging.basicConfig(level=logging.DEBUG)
config.ECHO_NEST_API_KEY="OCQQQWJBKZXHKPXHZ"
def prompt():
userinput = raw_input("Gimme an artist: ")
if not userinput:
exit()
print dance_songs(get_artist_id(userinput))
def get_artist_id(artist_name):
result = artist.search(name=artist_name)
if not result:
return False
return result[0].id
def dance_songs(artist_id, dance=0.6, maxresults=10):
results = song.search(artist_id=artist_id,
min_danceability=dance,
results=maxresults,
sort='danceability-desc',
buckets=['audio_summary'])
return results
if __name__ == '__main__':
prompt()