dmhacker / alexa-youtube-skill

Allows Alexa to play audio from YouTube videos
MIT License
243 stars 109 forks source link

Anyone having issues with long videos? #56

Open tal9000v2 opened 5 years ago

tal9000v2 commented 5 years ago

Anyone having issues with videos that are long? Seems like maybe some caching issue. For example, try searching for "Prince". The first result that is returned is a 7minute video. It won't play unless you hit the horokuapp directly and search for Prince, let the video play through to get it cached in horoku. Then you can search for it and it will play. But try something like "Guardians of the Galaxy Soundtrack". The first result is 1hours and 30minutes. That wont play at all.

dmhacker commented 5 years ago

Unfortunately, this is a major issue and one that I am actively trying to resolve. The problem is that the Heroku server must download the audio from the YouTube video entirely before Alexa can play it. This means that Alexa has to potentially wait a long time before actually playing the video. Possible resolutions:

  1. Fetch the audio as a link directly from YouTube or some third-party provided. Highly unlikely since YouTube doesn't (to my knowledge) provide a way to separate audio & visual components of their videos.
  2. Stream the video to Alexa as it is being downloaded. The most promising solution, but I have been unable to get it to work with my Alexa thus far.

Anyway, in short, just hang tight & try not to download large audio files unless you don't mind the wait. It also sucks up a lot of bandwidth and disk storage on Heroku too, so I might have to enforce caps in the future if it gets to be a problem and my solutions don't pan out. My only suggestion would be to set up your own Heroku server (see here) and connect to that rather than using the default.

chokkyvista commented 5 years ago

Hi @dmhacker , kudos for putting all these together and for sharing your great work 👍 You've also got me started with my first ever Alexa programming experience :-)

I've also run into this issue recently and have been trying to resolve it. In my experience, it seems not simply the issue of a long wait though - my Echo would time out (w/ the rolling ring dimming out) after about 45 seconds of waiting. And after that even though the download (on heroku) and the polling (on AWS) could still be going and the response would eventually still be sent out, it wouldn't hit Alexa anyway and thus the playback won't happen.

So to fix this particular issue, I've modified the script to now keep reprompting the user during the download (every 45 seconds or so) to keep the session alive. Please take a look and I'd appreciate your thoughts on this.

chokkyvista commented 5 years ago

And btw, even after I've already started my own (free Dynos) Heroku server and modified it to download "short" videos only (here), it's still quite common (almost always actually) for my Heroku server to spend as long as 70 seconds on downloading a video of less than 4 minutes.

Does this sound normal to you, or maybe am I missing something for my Heroku setup?

chokkyvista commented 5 years ago

Fetch the audio as a link directly from YouTube or some third-party provided.

Just fyi, it seems like this is doing exactly that using pytube?