I am building a SoundCloud music streaming skill for Alexa with Flask-ask in python. I have a generator function that looks like this:
def stream_likes():
url = "http://api.soundcloud.com/me/favorites?oauth_token={}".format(oauth_token)
r = requests.get(url)
response = json.loads(r.text)
for track in response:
yield track.url
fav_generator = stream_likes()
When I call next(fav_generator)
immediately after the iterator is created, it works fine. However, when I call the function from inside of another function like this:
@ask.intent('FavoritesIntent')
def play_favs():
stream_url = next(fav_generator)
return audio().play(stream_url)
I get the following error code.
TypeError: next() takes no arguments (1 given)
I would understand this error if I called a method of a class without passing the self parameter but I don't know why I am getting it in this instance.