Open jamesshaw1987 opened 7 years ago
I can understand, as the response time is indeed only 10 seconds. Sometimes, when the local internet is slow, it doesn't even take a 100+ track request to timeout the response. The best way to go about this, may be indeed to globally do the queue adding using an external thread and returning the first available song. This way, a timeout should be avoided while still allowing the queue to be filled up. Problems with multithreading may occur, but normally, the queue should be thread safe.
Haven't looked at putting a proper solution for this, though I have improved things on my setup. I've moved away from using Heroku and am instead just hosting locally (using ngrok to expose the server for now). And what that means is that I can then use the local Plex URL for searching and performing artist/album lookups. Obviously the external Plex URL is still needed to play tracks as the request for that is coming from the Alexa servers. And if the local URL is set on the environment it'll fall back to using the external URL for searching//lookups, which means the code will still work when hosted on Heroku/anywhere external.
So as a result a request that returns 200+ tracks is now completing in ~5s, which covers my needs for now. I can make a pull request for the changes if you like, nothing much to it and it just requires an extra environment variable to be set.
I have also thought of that solution, but, many people will not be able to do this at home. If you would make it so that, if the extra environmental variable isn't set, that it will still work, you should push it. This is just to introduce a little backwards compatibility :)
This is something that only really applies when trying to play everything by an artist for whom you have a lot of albums/tracks.
If, for example, you have 20 albums by an artist, each containing 10 tracks, you'd have to make 221 requests (1 for the artist, 20 for the albums and 200 for the tracks) to Plex when using the "play artist" intent. This can obviously take a while to conplete, often longer than Alexa allows for the response.
Not sure of the best approach for handling this and I don't now Python well enough to know the options available. Add the first album to the queue and fetch the rest asynchronously maybe? Or pull back, say, 100 tracks and have some placeholder at the end of the queue telling it to fetch the next batch when it gets to that point? Or maybe just limit each request to ~100 tracks and let the user know that they'll have to be more specific to play others?