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

Module util

source code

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

Utility functions to support the Echo Nest web API interface.

Classes [hide private]
  MyBaseHandler
  MyErrorProcessor
  EchoNestException
Parent exception class. Catches API and URL/HTTP errors.
  EchoNestAPIError
API Specific Errors.
  EchoNestIOError
URL and HTTP errors.
Functions [hide private]
 
get_successful_response(raw_json) source code
 
reallyunicode(s, encoding='utf-8') source code
 
reallyUTF8(s) source code
 
codegen(filename, start=0, duration=30) source code
 
callm(method, param_dict, POST=False, socket_timeout=None, data=None)
Call the api! Param_dict is a regular python dictionary so if you want to have multi-valued params put them in a list.
source code
 
oauthgetm(method, param_dict, socket_timeout=None) source code
 
postChunked(host, selector, fields, files)
Attempt to replace postMultipart() with nearly-identical interface. (The files tuple no longer requires the filename, and we only return the response body.) Uses the urllib2_file.py originally from http://fabien.seisen.org which was also drawn heavily from http://code.activestate.com/recipes/146306/ .
source code
 
fix(x) source code
Variables [hide private]
  logger = logging.getLogger(__name__)
  TYPENAMES = (('AR', 'artist'), ('SO', 'song'), ('RE', 'release...
  foreign_regex = re.compile(r'^.+?:(artist|song|release|track|p...
  short_regex = re.compile(r'^((AR|SO|RE|TR|PE|DE|LI|ED|TW|CA)[0...
  long_regex = re.compile(r'music://id.echonest.com/.+?/(AR|SO|R...
  headers = [('User-Agent', 'Pyechonest 0.0.0')]
  opener = urllib2.build_opener(MyBaseHandler(), MyErrorProcesso...
  __package__ = 'pyechonest'
Function Details [hide private]

callm(method, param_dict, POST=False, socket_timeout=None, data=None)

source code 

Call the api! Param_dict is a regular python dictionary so if you want to have multi-valued params put them in a list.

** note, if we require 2.6, we can get rid of this timeout munging.

postChunked(host, selector, fields, files)

source code 

Attempt to replace postMultipart() with nearly-identical interface. (The files tuple no longer requires the filename, and we only return the response body.) Uses the urllib2_file.py originally from http://fabien.seisen.org which was also drawn heavily from http://code.activestate.com/recipes/146306/ .

This urllib2_file.py is more desirable because of the chunked uploading from a file pointer (no need to read entire file into memory) and the ability to work from behind a proxy (due to its basis on urllib2).


Variables Details [hide private]

TYPENAMES

Value:
(('AR', 'artist'),
 ('SO', 'song'),
 ('RE', 'release'),
 ('TR', 'track'),
 ('PE', 'person'),
 ('DE', 'device'),
 ('LI', 'listener'),
 ('ED', 'editor'),
...

foreign_regex

Value:
re.compile(r'^.+?:(artist|song|release|track|person|device|listener|ed\
itor|tweditor|catalog):([^\^]+)\^?([0-9\.]+)?')

short_regex

Value:
re.compile(r'^((AR|SO|RE|TR|PE|DE|LI|ED|TW|CA)[0-9A-Z]{16})\^?([0-9\.]\
+)?')

long_regex

Value:
re.compile(r'music://id.echonest.com/.+?/(AR|SO|RE|TR|PE|DE|LI|ED|TW|C\
A)/(AR|SO|RE|TR|PE|DE|LI|ED|TW|CA)[0-9A-Z]{16}\^?([0-9\.]+)?')

opener

Value:
urllib2.build_opener(MyBaseHandler(), MyErrorProcessor())