Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better handling of requests that fetch large amounts of tracks #13

Open
jamesshaw1987 opened this issue Jan 22, 2017 · 3 comments
Open

Comments

@jamesshaw1987
Copy link
Collaborator

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?

@Tyzer34
Copy link
Owner

Tyzer34 commented Jan 22, 2017

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.

@jamesshaw1987
Copy link
Collaborator Author

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.

@Tyzer34
Copy link
Owner

Tyzer34 commented Jan 28, 2017

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 :)

Tyzer34 added a commit that referenced this issue Feb 1, 2017
Perform searches using local URL if environment variable is set - #13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants