Giter VIP home page Giter VIP logo

pyechonest's Introduction

Pyechonest

Tap into The Echo Nest's Musical Brain for the best music search, information, recommendations and remix tools on the web.

Pyechonest is an open source Python library for the Echo Nest API. With Pyechonest you have Python access to the entire set of API methods including:

  • artist - search for artists by name, description, or attribute, and get back detailed information about any artist including audio, similar artists, blogs, familiarity, hotttnesss, news, reviews, urls and video.
  • song - search songs by artist, title, description, or attribute (tempo, duration, etc) and get detailed information back about each song, such as hotttnesss, audio_summary, or tracks.
  • track - upload a track to the Echo Nest and receive summary information about the track including key, duration, mode, tempo, time signature along with detailed track info including timbre, pitch, rhythm and loudness information.

Install

There are a few different ways you can install pyechonest:

  • Use setuptools: easy_install -U pyechonest
  • Download the zipfile from the releases page and install it.
  • Checkout the source: git clone git://github.com/echonest/pyechonest.git and install it yourself.

Getting Started

  • Install Pyechonest
  • Get an API key - to use the Echo Nest API you need an Echo Nest API key. You can get one for free at developer.echonest.com.
  • Set the API key - you can do this one of two ways:
  • set an environment variable named ECHO_NEST_API_KEY to your API key
  • Include this snippet of code at the beginning of your python scripts:
    from pyechonest import config
    config.ECHO_NEST_API_KEY="YOUR API KEY"
  • Check out the docs and examples below.

Examples

All examples assume you have already setup your api key!

Find artists that are similar to 'Bikini Kill':

from pyechonest import artist
bk = artist.Artist('bikini kill')
print "Artists similar to: %s:" % (bk.name,)
for similar_artist in bk.similar: print "\t%s" % (similar_artist.name,)

Search for artist:

from pyechonest import artist
weezer_results = artist.search(name='weezer')
weezer = weezer_results[0]
weezer_blogs = weezer.blogs
print 'Blogs about weezer:', [blog.get('url') for blog in weezer_blogs]

Get an artist by name:

from pyechonest import artist
a = artist.Artist('lady gaga')
print a.id

Get an artist by Musicbrainz ID:

from pyechonest import artist
a = artist.Artist('musicbrainz:artist:a74b1b7f-71a5-4011-9441-d0b5e4122711')
print a.name

Get the top hottt artists:

from pyechonest import artist
for hottt_artist in artist.top_hottt():
print hottt_artist.name, hottt_artist.hotttnesss

Search for songs:

from pyechonest import song
rkp_results = song.search(artist='radiohead', title='karma police')
karma_police = rkp_results[0]
print karma_police.artist_location
print 'tempo:',karma_police.audio_summary['tempo'],'duration:',karma_police.audio_summary['duration']

Get a song's audio_url and analysis_url:

from pyechonest import song
ss_results = song.search(artist='the national', title='slow show', buckets=['id:7digital-US', 'tracks'], limit=True)
slow_show = ss_results[0]
ss_tracks = slow_show.get_tracks('7digital-US')
print ss_tracks[0].get('preview_url')

-alt text

pyechonest's People

Contributors

alex avatar andreasjansson avatar arnkmr4 avatar daubman avatar ingrid avatar jambot avatar markaurelius avatar njl avatar plinton avatar psobot avatar rferguson avatar sebpiq avatar stowell avatar tkell avatar tylerwilliams avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyechonest's Issues

Visiting http://readme.md/ redirected me here

Some wysiwyg editors today auto-links xxx.yyy and that's the reason why I was brought here (Gmail in my case).

I just thought that it would be very cool if it instead redirects you to a random readme page in Github.

Missing country ref for get_tracks() in docstrings (song.py)

References to get_tracks should be

song.get_tracks('id:7digital-xx')

instead of

song.get_tracks('id:7digital')

As it doesn't seem to like 7digital alone

 File "audio.py", line 15, in get_song_data
     track = song.get_tracks('7digital')[0]
 File "build/bdist.linux-x86_64/egg/pyechonest/song.py", line 347, in get_tracks
 File "build/bdist.linux-x86_64/egg/pyechonest/proxies.py", line 159, in get_attribute
 File "build/bdist.linux-x86_64/egg/pyechonest/proxies.py", line 23, in get_attribute
 File "build/bdist.linux-x86_64/egg/pyechonest/util.py", line 252, in callm
 File "build/bdist.linux-x86_64/egg/pyechonest/util.py", line 122, in get_successful_response
pyechonest.util.EchoNestAPIError: (u'Echo Nest API Error 5: bucket - Invalid parameter: bucket "id:7digital" is not one of "song_hotttnesss", "song_hotttnesss_rank", "artist_familiarity", "artist_familiarity_rank", "artist_hotttnesss", "artist_hotttnesss_rank", "artist_discovery", "artist_discovery_rank", "audio_summary", "artist_location", "tracks", "scores", "song_type", "song_discovery", "song_discovery_rank", "song_currency", "song_currency_rank", "id:7digital-US", "id:7digital-AU", "id:7digital-UK", "id:facebook", "id:fma", "id:emi_open_collection", "id:emi_bluenote", "id:emi_artists", "id:twitter", "id:spotify-WW", "id:seatwave", "id:lyricfind-US", "id:jambase", "id:musixmatch-WW", "id:rdio-US", "id:rdio-AT", "id:rdio-AU", "id:rdio-BR", "id:rdio-CA", "id:rdio-CH", "id:rdio-DE", "id:rdio-DK", "id:rdio-ES", "id:rdio-FI", "id:rdio-FR", "id:rdio-IE", "id:rdio-IT", "id:rdio-NL", "id:rdio-NO", "id:rdio-NZ", "id:rdio-PT", "id:rdio-SE", "id:emi_electrospective", "id:rdio-WW", "id:rdio-EE", "id:rdio-LT", "id:rdio-LV", "id:rdio-IS", "id:rdio-BE", "id:rdio-MX", "id:seatgeek", "id:rdio-GB", "id:rdio-CZ", "id:rdio-CO", "id:rdio-PL", "id:rdio-MY", "id:rdio-HK", "id:rdio-CL", "id:twitter_numeric", "id:7digital-ES", "id:openaura", or "id:<CATALOG ID>" [HTTP 400]',)

Last Example in the Readme

The last example isn't working for me.

Traceback (most recent call last):
File "song.py", line 5, in
slow_show = ss_results[0]
IndexError: list index out of range

Request for API Key

Hi,

How to get the API key? When I click the link which is given on the installation page(http://developer.echonest.com/) I have got the error message "This site can’t be reached".

Kindly advise?

Thank you

Regards
Prabu M

DynamicPlaylist instances are created, but no songs generated (Python 2.7)

I'm having trouble getting the Dynamic Playlist object to work. I really want to be able to use a seed_catalog to generate the playlist, but any method to fetch songs e.g. get_lookahead_songs() returns None.

standard_playlist1 = playlist.Playlist(seed_catalog=u'CAZZOPK15261351B73')
print standard_playlist1

>> <Dynamic Playlist - 96d0aed056df4e64997a16c670eae817>

print standard_playlist1.get_lookahead_songs()

>> None

I have tried simple using an artist_id or artist argument, but it's not working.

On the other hand, the static playlist works great through any generation method (artist, artist_id or seed catalog). Based on the documentation and the existence of a deprecated dynamic playlist, is this still something of a work in progress?

Song's foreign_id cache not filled properly, Song.get_foreign_id() not based on tracks

Hello,

Thank you very much for the pyechonest library!!! It is awesome so far : )

To reproduce: call Playlist.static(..., bucket=['id:spotify', 'tracks']) then find that someResultSong.get_foreign_id() returns None although someResultSong.cache['tracks'][0]['foreign_id'] is already filled.

I also noticed that someResultSong.get_foreign_id() also tries to find the foreign_id using only bucket=['id:spotify'](ie.the catalog space) and looking into Song objects... Whereas the right for me would be to have bucket=['id:spotify','tracks'] and look into Song.tracks...

Have a nice day!!! : )

Proposing a PR to fix a few small typos

Issue Type

[x] Bug (Typo)

Steps to Replicate and Expected Behaviour

  • Examine pyechonest/artist.py and observe ingteger, however expect to see integer.
  • Examine pyechonest/artist.py and observe hotttest, however expect to see hottest.

Notes

Semi-automated issue generated by
https://github.com/timgates42/meticulous/blob/master/docs/NOTE.md

To avoid wasting CI processing resources a branch with the fix has been
prepared but a pull request has not yet been created. A pull request fixing
the issue can be prepared from the link below, feel free to create it or
request @timgates42 create the PR.

https://github.com/timgates42/pyechonest/pull/new/bugfix_typos

Thanks.

Song search not working

Hello,

I get the following error when trying to execute example code for song.search found on this page: http://echonest.github.io/pyechonest/song.html

Traceback (most recent call last):
  File "test.py", line 4, in <module>
    results = pyechonest.song.search(artist='shakira', title='she wolf', buckets=['id:7digital', 'tracks'], limit=True, results=1)
  File "build/bdist.linux-x86_64/egg/pyechonest/song.py", line 447, in search
  File "build/bdist.linux-x86_64/egg/pyechonest/util.py", line 208, in callm
pyechonest.util.EchoNestIOError: Echo Nest Unknown Error

HTTP/SOCKS Proxy upload file

So I have an issue uploading a music file through the http proxy I am behind this query works

>>> song.search(artist="radiohead",title="Creep")

[<song - Creep>, <song - CREEP (LYRICS!)>, <song - Creep (Acoustic)>, <song - Creep (Radio Edit)>, <song - CREEP (Live)/(LYRICS!)>, <song - Creep (BBC Radio 1 Evening Session)>]

however doing this returns ...

>>> track.track_from_filename(filename)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "build/bdist.macosx-10.6-intel/egg/pyechonest/track.py", line 217, in track_from_filename
  File "build/bdist.macosx-10.6-intel/egg/pyechonest/track.py", line 196, in track_from_file
  File "build/bdist.macosx-10.6-intel/egg/pyechonest/track.py", line 174, in _track_from_string
  File "build/bdist.macosx-10.6-intel/egg/pyechonest/track.py", line 152, in _upload
  File "build/bdist.macosx-10.6-intel/egg/pyechonest/util.py", line 202, in callm
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 958, in request
    self._send_request(method, url, body, headers)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 992, in _send_request
    self.endheaders(body)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 954, in endheaders
    self._send_output(message_body)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 814, in _send_output
    self.send(msg)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 776, in send
    self.connect()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 757, in connect
    self.timeout, self.source_address)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 571, in create_connection
    raise err
socket.error: [Errno 60] Operation timed out

I have tried to "socksipy" (http://socksipy.sourceforge.net) to force the sockets to use the proxy like this:

>>> socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5,"socks.example.com")
>>> socket.socket = socks.socksocket

but to no avail.

I think that problems lies in the function util.callm or in httplib.HTTPConnection therefore I have also tried.

>>> track.util.opener = urllib2.build_opener(urllib2.ProxyHandler(),track.util.MyBaseHandler(), track.util.MyErrorProcessor())

Import Error about inconsistent indentation.

>>> from pyechonest import catalog
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "...\Python\Python37\lib\site-packages\pyechonest\catalog.py", line 327
    if since:
            ^
TabError: inconsistent use of tabs and spaces in indentation```

Permission error after installing "pyechonest"

I'm facing a permission problem while I'm using "echonest" plugin under Debian Squeeze (Python 2.6).

$ sudo pip install pyechonest
Downloading/unpacking pyechonest
Downloading pyechonest-8.0.0.tar.gz
Running setup.py egg_info for package pyechonest
Installing collected packages: pyechonest
Running setup.py install for pyechonest
Successfully installed pyechonest
Cleaning up...

$ beet imp autoKratz
Traceback (most recent call last):
File "/usr/local/bin/beet", line 5, in
from pkg_resources import load_entry_point
File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 2691, in
add_activation_listener(lambda dist: dist.activate())
File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 668, in subscribe
callback(dist)
File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 2691, in
add_activation_listener(lambda dist: dist.activate())
File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 2192, in activate
self.insert_on(path)
File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 2299, in insert_on
self.check_version_conflict()
File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 2338, in check_version_conflict
for modname in self._get_metadata('top_level.txt'):
File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 2186, in _get_metadata
for line in self.get_metadata_lines(name):
File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 1174, in get_metadata_lines
return yield_lines(self.get_metadata(name))
File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 1166, in get_metadata
return self._get(self._fn(self.egg_info,name))
File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 1281, in _get
stream = open(path, 'rb')
IOError: [Errno 13] Permission denied: '/usr/local/lib/python2.6/dist-packages/pyechonest-8.0.0.egg-info/top_level.txt'

$ ls /usr/local/lib/python2.6/dist-packages/pyechonest-8.0.0.egg-info/top_level.txt -alh
-rwx------ 1 root staff 11 Jun 12 13:51 /usr/local/lib/python2.6/dist-packages/pyechonest-8.0.0.egg-info/top_level.txt

Fixed by chmoding to 664:
$ sudo chmod 664 /usr/local/lib/python2.6/dist-packages/pyechonest-8.0.0.egg-info/top_level.txt

I hope it helps :)

eyeD3 version 0.7.x support

diff --git a/examples/show_tempos.py b/examples/show_tempos.py
--- a/examples/show_tempos.py
+++ b/examples/show_tempos.py
@@ -3,18 +3,18 @@

 import sys
 import os
-import eyeD3
+import eyed3.id3
 import tempo


 def show_tempo(mp3):
     "given an mp3, print out the artist, title and tempo of the song"
-    tag = eyeD3.Tag()
-    tag.link(mp3)
-    my_tempo = tempo.get_tempo(tag.getArtist(), tag.getTitle())
+    tag = eyed3.id3.Tag()
+    tag.parse(mp3)
+    my_tempo = tempo.get_tempo(tag.artist, tag.title)
     print 'File:  ', mp3
-    print 'Artist:', tag.getArtist()
-    print 'Title: ', tag.getTitle()
+    print 'Artist:', tag.artist
+    print 'Title: ', tag.title
     print 'Tempo: ', my_tempo
     print

Migrate to Spotify | API key not allowed

I expect that due to the migration of Echonest API to Spotify API, I'm now getting an error when I try to retrieve an audio_analysis object.

But I'm not sure how or where to change the API I'm calling from the Echonest API to the Spotify API.

The code is basically:

from echonest.remix.audio import AudioAnalysis
AudioAnalysis(str(track_md5))

Will pyechonest and remix still work? And if so, where do I need to make configuration changes?

I imagine I am missing something obvious.

IndexError: list index out of range in song.Song('<invalid id>')

example from documentation: s = song.Song('SOPEXHZ12873FD2AC7)'

calls this request: http://developer.echonest.com/api/v4/song/profile?api_key=&id=SOPEXHZ12873FD2AC7

which returns successfully despite not having any results in "songs"

as a result, this initialization results in the following stack trace:

Traceback (most recent call last):
  File "chordials.py", line 51, in <module>
    s = song.Song('SOPEXHZ12873FD2AC7')
  File "build/bdist.macosx-10.9-intel/egg/pyechonest/song.py", line 72, in __init__
  File "build/bdist.macosx-10.9-intel/egg/pyechonest/proxies.py", line 153, in __init__
IndexError: list index out of range

Echonest and Million Song Dataset - out of synch?

Hi!

Using your pyechonest library to access your API it frequently happens that song-ids provided by MSD result in empty responses.

s = song.Song('SOMNXCC12AB0187BE7', buckets=['tracks', 'id:7digital-US'])

Traceback (most recent call last):
File "...", line 153, in
s = song.Song('SOMNXCC12AB0187BE7', buckets=['tracks', 'id:7digital-US'])
File "...\pyechonest-7.1.0-py2.7.egg\pyechonest\song.py", line 72, in init
super(Song, self).init(id, buckets, **kwargs)
File "...\pyechonest-7.1.0-py2.7.egg\pyechonest\proxies.py", line 173, in init
kwargs.update(profile.get('songs')[0])
IndexError: list index out of range

  • Does this error indicate that there was no song entity retrieved or is it a bug?
  • This behaviour is similar using the track class. Does a 'list index out of range' always translate to 'no results found'?

readme.md link redirect

I think that the link "readme.md" should NOT redirect to this repo's readme.

  1. it's pointless
  2. causes confusion
  3. should be avoided, readme.md is a common filename and should now be a url.

KeyError: 'total'

I promised I would report the KeyError that I had been seeing. Here it is:

File "/usr/local/lib/python2.7/dist-packages/pyechonest-4.2.21-py2.7.egg/pyechonest/artist.py", line 338, in get_images
self.cache['images'] = ResultList(response['images'], 0, response['total'])
KeyError: 'total'

song.get_tracks always returns empty list

Hi!

I tried with various settings but always receive the same empty result.

ss_results = song.search(artist='radiohead', title='karma police', buckets=['id:7digital', 'tracks'])
slow_show = ss_results[0]
ss_tracks = slow_show.get_tracks('7digital')
print ss_tracks

[]

Also using direct access with song-id does not work. Either the data is not sent by the server or the data is not parsed by the pyechonet library.

Alex

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.