Proof of Concept: Simple Cog which downloads YT Music and then plays it through Audio Cog as a Local File in VoiceChat #6800
Labels
No labels
Automated PR
Blocked
Blocked By: Damage Control
Blocked By: Dependency
Blocked By: Other PR
Breaking Change
Category: CI
Category: Cogs - Admin
Category: Cogs - Alias
Category: Cogs - Audio
Category: Cogs - Bank
Category: Cogs - Cleanup
Category: Cogs - CustomCommands
Category: Cogs - Dev
Category: Cogs - Downloader
Category: Cogs - Economy
Category: Cogs - Filter
Category: Cogs - General
Category: Cogs - Image
Category: Cogs - Mod
Category: Cogs - Modlog
Category: Cogs - Mutes
Category: Cogs - Permissions
Category: Cogs - Reports
Category: Cogs - Streams
Category: Cogs - Trivia
Category: Cogs - Trivia - Lists
Category: Cogs - Warnings
Category: Core - API - App Commands Package
Category: Core - API - Audio
Category: Core - API - Bank
Category: Core - API - Commands Package
Category: Core - API - Config
Category: Core - API - Other
Category: Core - API - Utils Package
Category: Core - Bot Class
Category: Core - Bot Commands
Category: Core - Command-line Interfaces
Category: Core - Downloader
Category: Core - Help
Category: Core - i18n
Category: Core - Modlog
Category: Core - Other Internals
Category: Core - RPC/ZMQ
Category: Docker
Category: Docs - Changelogs
Category: Docs - For Developers
Category: Docs - Install Guides
Category: Docs - Other
Category: Docs - User Guides
Category: Meta
Category: RPC/ZMQ methods
Category: Vendored Packages
Changelog Entry: Added
Changelog Entry: Pending
Changelog Entry: Skipped
Closed: Duplicate
Closed: External
Closed: Invalid
Closed: User Error
Closed: Won't Fix
Complex Issue
Docs-only
Feature Branch
Good First Issue
Help Wanted
High Priority
Needs Backport To stable-docs
No Activity
No Repro
QA: Bypassed
QA: Changes Requested
QA: Passed
Release Blocker
Status: Accepted
Status: Frozen
Status: In Progress
Status: Needs Discussion
Status: Needs Info
Status: Needs Triage
Status: PRs Welcome
Type: Bug
Type: Dependency Update
Type: Deprecation
Type: Enhancement
Type: Feature
Type: Informational
Type: Merge
Type: Optimisation
Type: Question
Type: Removal
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Mrcoolgamer11/Red-DiscordBot#6800
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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 /youtubelocal/
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
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.
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 if you believe it is something that you or others would be interested in despite the limitations.