def test_get_tracks(self): e = Echonest() s = Spotify() tracks = e.search_songs("happy") self.assertTrue(len(tracks) > 0) for t in tracks: t.load_spotify(s) print("{0}/{1} {2}".format(t.title, t.artist_name, t.preview_url))
def convert(image_urls): ec = Echonest() sp = Spotify() log = [] # analyze moode log.append("begin vision recognition") target_mood = photo2mood(image_urls) # choose song from mood log.append("begin search song by mood") tracks = ec.search_songs(target_mood) # load spotify info @asyncio.coroutine def load_spotify(t): t.load_spotify(sp) log.append("begin load song information") tasks = [load_spotify(t) for t in tracks] done, _ = asyncio.get_event_loop().run_until_complete(asyncio.wait(tasks)) result = _make_result(target_mood, tracks, log=log) return result