MusicBot icon indicating copy to clipboard operation
MusicBot copied to clipboard

[Feature Request] yt-dlp for Youtube

Open vico93 opened this issue 4 months ago • 4 comments

Is your feature request related to a problem? Please describe.

Since this repository seems to be dead, i will direct this question/suggestion for the numerous forks that are active but doesn't have the Issues tab enabled, mainly @Eddie0343, @antronic, @PoH98 and others

I wonder if switching to yt-dlp (with help of ffmpeg too, if necessary) to fetch Youtube links instead of the current methods (lavaplayer, YT API) would solve the multitude of issues that appeared when users try to play youtube songs with the bot.

What is your ideal solution to the problem?

n/a

How would this feature be used?

n/a

Additional Info

No response

Checklist

vico93 avatar Sep 09 '25 01:09 vico93

Unlikely, because the changes YouTube has implemented affects every InnerTube client, whether its yt-dlp, lavaplayer's youtube-source, youtubei.js, individious, even the official YouTube clients are affected:

Image

  • The IPs/ASNs of most hosting services have been banned. If you are trying to stream/download from them, you will get a "Sign in to confirm youre not a bot" error
  • If you try to sign in using cookies, your account will very likely get flagged/banned pretty quickly by YouTube
  • PO tokens can help IPs that are not banned yet, but you will inevetably get flagged if you are playing too many things often enough
  • TV client/OAuth2 can be used as a somewhat reliable way to sign in with a banned IP & it is likely the route we want to go with for JMusicBot, but if you play too many things then you might also encounter trouble (e.g. there was an issue where specific Google accounts were only served DRM content)

lavaplayer youtube-source is not the problem. its a great InnerTube client, so is yt-dlp, youtubei.js, individious & the other major InnerTube clients out there. They're all doing their best to allow for video playback/downloads despite all the curveballs YouTube has thrown.

The issue is that JMusicBot's maintenance has fallen off because both jagrosh & myself are too occupied with our own lives. In addition, JMusicBot is kind of stuck in a limbo now, because of a new & separate issue that has arisen recently:

Discord has deprecated all the voice encryption modes that JDA 4 supports. That means JMusicBot cannot (reliably) connect to any voice channels anymore. We need to update JMusicBot to JDA 5 to resolve that. It's difficult though, because JMusicBot is heavily dependent on JDA-Utilities, which needs to be updated to JDA 5 as well. If I recall correctly, jagrosh said he was working on JDA-Utilities but I have no idea what the state of that is. I don't really have the authority to migrate JMusicBot away from JDA-Utilities to another command library/framework either, so this repository is stuck in a limbo.

We can update youtube source to fix playback on non-banned IP addresses & I do have a branches/patches that add IPv6 rotation and OAuth2 to circumvent these blocks that YouTube has implemented. But what is it worth when JMusicBot struggles to connect to voice channels & cannot play anything? There's no path forward because of the aforemtioned JDA-Utilities dependency & how it is seemingly not getting any progress.

MichailiK avatar Sep 09 '25 02:09 MichailiK

fwiw implementing yt-dlp support in JMusicBot would be a good idea in general, since they support hundreds/thousands of sources & perhaps could even act as a fallback if lavaplayer's youtube-source fails. some issues i could think of on the top of my head:

  • figure out how streaming would work (play the track during the download, instead of waiting for the download to finish)
  • figure out how seeking would work (both forwards & backwards)
  • how problematic network congestion would be, especially when JMusicBot plays in multiple servers (lavaplayer gradually downloads small chunks as its playing, whereas yt-dlp is gonna download the entire track all at once)

MichailiK avatar Sep 09 '25 02:09 MichailiK

May i suggest to drop youtube support anyways?

Unlikely, because the changes YouTube has implemented affects every InnerTube client, whether its yt-dlp, lavaplayer's youtube-source, youtubei.js, individious, even the official YouTube clients are affected: Why? Well they resist hard, they can always change authentication of theirs streams, i don't think if such work would be paid , that it would be stable and efficient.

What we can offer to people a workaround: the users of MusicBot , should download theirs music on discord servers or other public places (Hint not US or EU) and from there add tracks to playlist of MusicBot. Those playlist if allowed can be shared between MusicBots p2p style. I hope MusicBot still support this: SoundCloud Bandcamp Vimeo Twitch streams Local files HTTP URLs

You need to add Spotify to the list as supported playlist, and then actually problem solved. People who wish to play music from youtube, they would download music and place on public available places and from there playback would work.

I know, not everyone would like this idea, but really you need to understand google would be always one step ahead of us and make no sense to overcomplicate the stuff, bot should not care about youtube.

orlovskyjavaprofi avatar Oct 05 '25 11:10 orlovskyjavaprofi

Please re-read the last 2 paragraphs on my original response. I have fixes ready to make YouTube playback work again. The issue is JMusicBot cant play anything because it can't connect to voice channels anymore.

To entertain your ideas regardless:

download theirs music on discord servers or other public places [...] shared between MusicBots p2p style

flies way too close to the sun with DMCA and general legal issues. the reason we're imitating a YouTube client is two fold

  1. youtube is a (somewhat) reliable and technically feasible way to retrieve music from. they are authorized to distribute music, so we dont have to anticipate for them to ever go away.
  2. at worst, we're only violating YouTube ToS with this approach. your approach relies on either unauthorized redistibrutions/mirrors (which are generally unreliable in availability/uptime & could get DMCA'd) or using p2p (which can lead to much worse legal consequences.)

You need to add Spotify

Most music bots "implement" Spotify by searching for the same track on YouTube. The reason we cannot play from Spotify directly is because they make use of Widevine DRM. we (nor the rest of the open source space) dont have the technical expertise or time to get around the DRM.

MichailiK avatar Oct 05 '25 11:10 MichailiK