Last active
December 18, 2015 16:48
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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