Skip to content

Instantly share code, notes, and snippets.

@atl
Created June 16, 2011 12:53
Show Gist options
  • Save atl/1029173 to your computer and use it in GitHub Desktop.
Save atl/1029173 to your computer and use it in GitHub Desktop.
pyechonest.artist.extract
--- a/pyechonest/artist.py Thu Jun 16 13:40:52 2011 +0100
+++ b/pyechonest/artist.py Thu Jun 16 13:51:16 2011 +0100
@@ -876,3 +876,28 @@
result = util.callm("%s/%s" % ('artist', 'similar'), kwargs)
return [Artist(**util.fix(a_dict)) for a_dict in result['response']['artists']]
+def extract(text='', start=0, results=15, buckets=None, limit=False, max_familiarity=None, min_familiarity=None,
+ max_hotttnesss=None, min_hotttnesss=None):
+ buckets = buckets or []
+ kwargs = {}
+ kwargs['text'] = text
+ if max_familiarity is not None:
+ kwargs['max_familiarity'] = max_familiarity
+ if min_familiarity is not None:
+ kwargs['min_familiarity'] = min_familiarity
+ if max_hotttnesss is not None:
+ kwargs['max_hotttnesss'] = max_hotttnesss
+ if min_hotttnesss is not None:
+ kwargs['min_hotttnesss'] = min_hotttnesss
+ if start:
+ kwargs['start'] = start
+ if results:
+ kwargs['results'] = results
+ if buckets:
+ kwargs['bucket'] = buckets
+ if limit:
+ kwargs['limit'] = 'true'
+ result = util.callm("%s/%s" % ('artist', 'extract'), kwargs)
+ return [Artist(**util.fix(a_dict)) for a_dict in result['response']['artists']]
def extract(text='', start=0, results=15, buckets=None, limit=False, max_familiarity=None, min_familiarity=None,
max_hotttnesss=None, min_hotttnesss=None):
buckets = buckets or []
kwargs = {}
kwargs['text'] = text
if max_familiarity is not None:
kwargs['max_familiarity'] = max_familiarity
if min_familiarity is not None:
kwargs['min_familiarity'] = min_familiarity
if max_hotttnesss is not None:
kwargs['max_hotttnesss'] = max_hotttnesss
if min_hotttnesss is not None:
kwargs['min_hotttnesss'] = min_hotttnesss
if start:
kwargs['start'] = start
if results:
kwargs['results'] = results
if buckets:
kwargs['bucket'] = buckets
if limit:
kwargs['limit'] = 'true'
result = util.callm("%s/%s" % ('artist', 'extract'), kwargs)
return [Artist(**util.fix(a_dict)) for a_dict in result['response']['artists']]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment