Skip to content

refactor(streaming): Use aiohttp instead of curl and use Flaresolverr to bypass bot checks - #124

Open
Dolly132 wants to merge 25 commits into
srcdslab:masterfrom
Dolly132:dolly-fix2
Open

refactor(streaming): Use aiohttp instead of curl and use Flaresolverr to bypass bot checks#124
Dolly132 wants to merge 25 commits into
srcdslab:masterfrom
Dolly132:dolly-fix2

Conversation

@Dolly132

@Dolly132 Dolly132 commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

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 aiohttp for 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 Host and Port in config for *FlareSolverr`.

Changelog:

  • Removed the --no-deps flag on PIP dependencies on production and dev environments. pip will not install any dependency required from the desired one to install.
  • Added aiohttp-socks and curl-cffi dependencies.
  • Added FlareSolverr.py module to handle everything related to FlareSolverr.
  • Local files are played internally from ffmpeg process alone now.
  • Got rid of curl process and used aiohttp client sessions instead.
  • Added better handling for youtube videos, (static duration instead of counting it while streaming it)
  • Some other minor changes related to the goal of this PR.

Note:
This is a huge PR, i tried my best to test. however there could be errors!

This PR also combines #120

**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.
@Dolly132
Dolly132 marked this pull request as draft September 3, 2026 13:41
@Dolly132
Dolly132 marked this pull request as ready for review September 3, 2026 14:21
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

Successfully merging this pull request may close these issues.

1 participant