Package pyechonest :: Module song
[hide private]
[frames] | no frames]

Module song

source code

Copyright (c) 2010 The Echo Nest. All rights reserved. Created by Tyler Williams on 2010-04-25.

The Song module loosely covers http://developer.echonest.com/docs/v4/song.html Refer to the official api documentation if you are unsure about something.

Classes [hide private]
  Song
A Song object
Functions [hide private]
 
identify(filename=None, query_obj=None, code=None, artist=None, title=None, release=None, duration=None, genre=None, buckets=None, version=None, codegen_start=0, codegen_duration=30)
Identify a song.
source code
 
search(title=None, artist=None, artist_id=None, combined=None, description=None, style=None, mood=None, results=None, start=None, max_tempo=None, min_tempo=None, max_duration=None, min_duration=None, max_loudness=None, min_loudness=None, artist_max_familiarity=None, artist_min_familiarity=None, artist_max_hotttnesss=None, artist_min_hotttnesss=None, song_max_hotttnesss=None, song_min_hotttnesss=None, mode=None, min_energy=None, max_energy=None, min_danceability=None, max_danceability=None, key=None, max_latitude=None, min_latitude=None, max_longitude=None, min_longitude=None, sort=None, buckets=None, limit=False, test_new_things=None, rank_type=None, artist_start_year_after=None, artist_start_year_before=None, artist_end_year_after=None, artist_end_year_before=None, song_type=None)
Search for songs by name, description, or constraint.
source code
 
profile(ids=None, track_ids=None, buckets=None, limit=False)
get the profiles for multiple songs at once
source code
Variables [hide private]
  __package__ = 'pyechonest'
Function Details [hide private]

identify(filename=None, query_obj=None, code=None, artist=None, title=None, release=None, duration=None, genre=None, buckets=None, version=None, codegen_start=0, codegen_duration=30)

source code 

Identify a song.

Args:

Kwargs:

filename (str): The path of the file you want to analyze (requires codegen binary!)

query_obj (dict or list): A dict or list of dicts containing a 'code' element with an fp code

code (str): A fingerprinter code

artist (str): An artist name

title (str): A song title

release (str): A release name

duration (int): A song duration

genre (str): A string representing the genre

buckets (list): A list of strings specifying which buckets to retrieve

version (str): The version of the code generator used to generate the code

codegen_start (int): The point (in seconds) where the codegen should start

codegen_duration (int): The duration (in seconds) the codegen should analyze

Example:
>>> qo
{'code': 'eJxlldehHSEMRFsChAjlAIL-S_CZvfaXXxAglEaBTen300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uvLm7CY_Vfa_k7SCzdwHNg5mICTSHDxyBWmaOSyLQpPmCSXyF-eL7MHo7zNd668JMb_N-AJJRuMwrX0jNx7a8-Rj5oN6nyWoL-jRv4pu7Ue821TzU3MhvpD9Fo-XI',
 'code_count': 151,
 'low_rank': 0,
 'metadata': {'artist': 'Harmonic 313',
              'bitrate': 198,
              'codegen_time': 0.57198400000000005,
              'decode_time': 0.37954599999999999,
              'duration': 226,
              'filename': 'koln.mp3',
              'genre': 'Electronic',
              'given_duration': 30,
              'release': 'When Machines Exceed Human Intelligence',
              'sample_rate': 44100,
              'samples_decoded': 661816,
              'start_offset': 0,
              'title': 'kln',
              'version': 3.1499999999999999},
 'tag': 0}
>>> song.identify(query_obj=qo)
[<song - Köln>]
>>>

search(title=None, artist=None, artist_id=None, combined=None, description=None, style=None, mood=None, results=None, start=None, max_tempo=None, min_tempo=None, max_duration=None, min_duration=None, max_loudness=None, min_loudness=None, artist_max_familiarity=None, artist_min_familiarity=None, artist_max_hotttnesss=None, artist_min_hotttnesss=None, song_max_hotttnesss=None, song_min_hotttnesss=None, mode=None, min_energy=None, max_energy=None, min_danceability=None, max_danceability=None, key=None, max_latitude=None, min_latitude=None, max_longitude=None, min_longitude=None, sort=None, buckets=None, limit=False, test_new_things=None, rank_type=None, artist_start_year_after=None, artist_start_year_before=None, artist_end_year_after=None, artist_end_year_before=None, song_type=None)

source code 

Search for songs by name, description, or constraint.

Args:

Kwargs:

title (str): the name of a song

artist (str): the name of an artist

artist_id (str): the artist_id

combined (str): the artist name and song title

description (str): A string describing the artist and song

style (str): A string describing the style/genre of the artist and song

mood (str): A string describing the mood of the artist and song

results (int): An integer number of results to return

max_tempo (float): The max tempo of song results

min_tempo (float): The min tempo of song results

max_duration (float): The max duration of song results

min_duration (float): The min duration of song results

max_loudness (float): The max loudness of song results

min_loudness (float): The min loudness of song results

artist_max_familiarity (float): A float specifying the max familiarity of artists to search for

artist_min_familiarity (float): A float specifying the min familiarity of artists to search for

artist_max_hotttnesss (float): A float specifying the max hotttnesss of artists to search for

artist_min_hotttnesss (float): A float specifying the max hotttnesss of artists to search for

song_max_hotttnesss (float): A float specifying the max hotttnesss of songs to search for

song_min_hotttnesss (float): A float specifying the max hotttnesss of songs to search for

max_energy (float): The max energy of song results

min_energy (float): The min energy of song results

max_dancibility (float): The max dancibility of song results

min_dancibility (float): The min dancibility of song results

mode (int): 0 or 1 (minor or major)

key (int): 0-11 (c, c-sharp, d, e-flat, e, f, f-sharp, g, a-flat, a, b-flat, b)

max_latitude (float): A float specifying the max latitude of artists to search for

min_latitude (float): A float specifying the min latitude of artists to search for

max_longitude (float): A float specifying the max longitude of artists to search for

min_longitude (float): A float specifying the min longitude of artists to search for

sort (str): A string indicating an attribute and order for sorting the results

buckets (list): A list of strings specifying which buckets to retrieve

limit (bool): A boolean indicating whether or not to limit the results to one of the id spaces specified in buckets

rank_type (str): A string denoting the desired ranking for description searches, either 'relevance' or 'familiarity

artist_start_year_before (int): Returned songs's artists will have started recording music before this year.

artist_start_year_after (int): Returned songs's artists will have started recording music after this year.

artist_end_year_before (int): Returned songs's artists will have stopped recording music before this year.

artist_end_year_after (int): Returned songs's artists will have stopped recording music after this year.

song_type (string): A string or list of strings specifiying the type of song to search for.

Returns:
A list of Song objects

Example:

>>> results = song.search(artist='shakira', title='she wolf', buckets=['id:7digital', 'tracks'], limit=True, results=1)
>>> results
[<song - She Wolf>]
>>> results[0].get_tracks('7digital')[0]
{u'catalog': u'7digital',
 u'foreign_id': u'7digital:track:7854109',
 u'id': u'TRTOBSE12903CACEC4',
 u'preview_url': u'http://previews.7digital.com/clips/34/7854109.clip.mp3',
 u'release_image': u'http://cdn.7static.com/static/img/sleeveart/00/007/081/0000708184_200.jpg'}
>>>

profile(ids=None, track_ids=None, buckets=None, limit=False)

source code 

get the profiles for multiple songs at once

Args:
ids (str or list): a song ID or list of song IDs
Kwargs:

buckets (list): A list of strings specifying which buckets to retrieve

limit (bool): A boolean indicating whether or not to limit the results to one of the id spaces specified in buckets

Returns:
A list of term document dicts

Example:

>>> song_ids = [u'SOGNMKX12B0B806320', u'SOLUHKP129F0698D49', u'SOOLGAZ127F3E1B87C', u'SOQKVPH12A58A7AF4D', u'SOHKEEM1288D3ED9F5']
>>> songs = song.profile(song_ids, buckets=['audio_summary'])
[<song - chickfactor>,
 <song - One Step Closer>,
 <song - And I Am Telling You I'm Not Going (Glee Cast Version)>,
 <song - In This Temple As In The Hearts Of Man For Whom He Saved The Earth>,
 <song - Octet>]
>>> songs[0].audio_summary
{u'analysis_url': u'https://echonest-analysis.s3.amazonaws.com:443/TR/TRKHTDL123E858AC4B/3/full.json?Signature=sE6OwAzg6UvrtiX6nJJW1t7E6YI%3D&Expires=1287585351&AWSAccessKeyId=AKIAIAFEHLM3KJ2XMHRA',
 u'danceability': None,
 u'duration': 211.90485000000001,
 u'energy': None,
 u'key': 7,
 u'loudness': -16.736999999999998,
 u'mode': 1,
 u'tempo': 94.957999999999998,
 u'time_signature': 4}
>>>