refactor(streaming): Use aiohttp instead of curl and use Flaresolverr to bypass bot checks - #124
refactor(streaming): Use aiohttp instead of curl and use Flaresolverr to bypass bot checks#124Dolly132 wants to merge 25 commits into
Conversation
**Summary** Well, YouTube is so strict sometimes, so it blocks buffer from actually being sent to the ffmpeg process in time, and we can't control that, however, a 15 seconds timeout was set, youtube usually takes more than 5 seconds to send buffers in time. **Why aiohttp?** I had to get rid of curl because handling it is harder, aiohttp is way easier and more reliable for requests like YouTube and MyInstants. - Solves srcdslab#119 - Now local files don't need a curl process to be made, it can be done inside ffmpeg itself - Set the duration of the youtube video before playing it instead of calculating it during the stream.
Code reviewBugs1. 2. curl_cffi worker thread deadlocks on early stop — 3. 4. Race on Dependencies / packaging5. Lockfiles contradict pyproject — 6. Docs7. Invalid FlareSolverr example — |
this PR focuses on changing the logic used in FFmpegAudioPlayer.
Previously, it was using a curl process to retrieves the bytes of a desired url, no matter whether it was local or from the internet.
however, this PR will not require any process other than ffmpeg itself to play local sounds, and a
aiohttpfor extern sounds.Another change:
Recently, myinstants website added a cloudflare bot protection, so genuinely, before this PR, the torchlight bot could not resolve the bot protection, so it ended up not playing any sound from myinstants.
A fix was introduced to use FlareSolverr from https://github.com/Flaresolverr/Flaresolverr .
Added the required
HostandPortin config for *FlareSolverr`.Changelog:
--no-depsflag on PIP dependencies on production and dev environments. pip will not install any dependency required from the desired one to install.aiohttp-socksandcurl-cffidependencies.FlareSolverr.pymodule to handle everything related to FlareSolverr.Note:
This is a huge PR, i tried my best to test. however there could be errors!
This PR also combines #120