Skip to content

Instantly share code, notes, and snippets.

@bnlucas
Last active December 18, 2015 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bnlucas/5813590 to your computer and use it in GitHub Desktop.
Save bnlucas/5813590 to your computer and use it in GitHub Desktop.
Using foreign IDs with pyechonest Song instantiations due to their issue with Song.id and Song.track_id.
from pyechonest import config
from pyechonest.song import Song
# Loading Bangarang by Skrillex...
song = Song('id:rdio-US:track:t14313937')
song = Song('id:spotify-WW:track:6VRhkROS2SZHGlp0pxndbJ')
song = Song('TRVOJIZ13A9CFBB670')
class SongProxy(GenericProxy):
#...
# found at line 157
def get_attribute(self, *args, **kwargs):
## ADDED CODE ##
if self.id.startswith('id:'):
kwargs['track_id'] = self.id
else:
kwargs['id'] = self.id
## ADDED CODE ##
return super(SongProxy, self).get_attribute(*args, **kwargs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment