Proof of Concept: Simple Cog which downloads YT Music and then plays it through Audio Cog as a Local File in VoiceChat

#6800 · closed · 1 comments

View on GitHub ↗

Szymkim2134

### What component of Red (cog, command, API) would you like to see improvements on? Audio ### Describe the enhancement you're suggesting. Being annoyed by always Broken managed Lavalink [which requires to really tweak around with stuff to just make it work], i've thought up of a Fallback Solution - Why not just use the Functionality of Playing Local Files through the Bot, by automating the Downloading process from Youtube Music? So, i've managed to vibe-code [using Deepseek, but i do know Python but not so much as to program it myself] it, You can see the result in the attached Python file. It works like this: User sends the command [p]localplay <youtube_link> -> Bot gets it, Downloads info about it -> Bot checks if it already exists in that one local folder ["youtubelocal" folder in the localpath set in Audioset] -> If not, downloads it through yt-dlp [probably also using ffmpeg to convert it to mp3]-> And then executes the command [p]play <localpath tracks folder>/youtubelocal/<video name on youtube>.mp3 -> Which plays the youtube link, as a locally hosted file. The End users sadly do not care about "Piracy-Risk" or "Avoiding Ads" and stuff, they just find it convenient when stuff works and doesn't break. Sadly - This required for me to install into the RedEnv: yt-dlp, PyNaCl, davey, and probably also ffmpeg. Implementing something similar without these is probably way above my league [and way harder/impossible because of legal reasons?], but with these it was somewhat easy [for local usage]. If you want to use anything from this - Be my guest. But PLEASE Review this code, and DO NOT include it as-is, because it's an AI-Slop which just works. It would need refinement before anything else. [Info.json file is in polish because i'm lazy to change it lol] [info.json](https://github.com/user-attachments/files/31333971/info.json) [localplay.py](https://github.com/user-attachments/files/31333970/localplay.py) ### Anything else? Again - This is just a Proof of Concept Idea, which would be REALLY convenient when things break with Lavalink. I don't think if this same thing could be applied to other platforms like Spotify and stuff, buut at least this would really make things easier when using the Audio Cog in this Discord Bot.

Comments

Flame442

Red previously used yt-dl for its audio cog, however it is generally able to provide more responsive and higher quality audio by directly streaming the track rather than waiting for a download and reupload. yt-dl is also not immune to the same kinds of protections employed by Youtube to prevent the kind of scraping of songs that both it and Lavaplayer perform. I do personally think pre-downloading any commonly played tracks and using them as local files is a good solution for users who tend to play the same songs often, however this does not help in any way when a new track needs to be played and Youtube is deciding to be uncooperative. The bot currently supports localtrack playback and users are able to manually download tracks using yt-dl or any other program in order to set up local backups of tracks they want to keep, however I do not think adding the extra burden of bundling all of the dependencies needed to run yt-dl into Red is a good idea for that marginal use case just to make it a little more seamless. I believe our stance is that we would likely drop Youtube support (and all of the sources that depend on it, i.e. Spotify) in the audio cog before we would move to a different player, as all players will suffer from the same limitations as Lavaplayer. In that situation, local tracks and HTTP streams would still function, as well as other sources that are not as difficult to maintain, however the `[p]play <keyword>` functionality would be lost. Even in that situation, power users could probably still reconfigure Lavaplayer to use a Youtube plugin and whatever additional effort is required for it to work if they are willing to play the cat and mouse game with Youtube. I am going to close this issue as it is not something we would integrate into Core, however please feel free to polish up your code and [publish it as a 3rd party cog](https://docs.discord.red/en/stable/guide_publish_cogs.html) if you believe it is something that you or others would be interested in despite the limitations.