aquelemiguel / parrot

🦜 A hassle-free, highly performant, self-hosted Discord music bot with YouTube and Spotify support. Powered by yt-dlp.
MIT License
136 stars 44 forks source link

Allow streaming from other yt-dlp supported sources #209

Closed aquelemiguel closed 1 year ago

aquelemiguel commented 1 year ago

📝 Description

yt-dlp allows for streaming from multiple other sources other than YouTube. A lot more actually.

In the play command, we check the query/url in this fashion:

let query_type = if url.contains("spotify.com") {
  // extract metadata from the spotify link and search it on youtube
}
else if url.contains("youtube.com") {
  // pass the link directly to yt-dlp
}
else {
  // pass the provided query to yt-dlp
}

There are a few issues with this approach:

🪜 Reproduction Steps

N/A

ℹ Environment / Computer Info

📸 Screenshots

No response

aquelemiguel commented 1 year ago

Asking for your input @joao-conde and @afonsojramos as to what would be the best approach for distinguishing a YouTube query from a valid YouTube link.

joao-conde commented 1 year ago

Not just valid youtube link, but all other links from https://github.com/yt-dlp/yt-dlp/blob/master/supportedsites.md right? Can check for the http:// begining and if not present assume its a query.

Additionally, we could have blacklisted sites, like p**rnhub, or allow that to be set on a per guild basis, using our guild settings

aquelemiguel commented 1 year ago

@joao-conde I've got an implementation in the works, it's just missing the blacklist. How would you add this? Would mods have to add every single 18+ website manually? There are a lot of supported websites, would be a chore.

joao-conde commented 1 year ago

Better to have some control than none. Mods would do something of an includes logic, like "/block porn" would block sites with porn in the name. "/block actuallydomain.com" would block URLs with that.

StaticRocket commented 1 year ago

Easiest solution to implement would be have a switch to toggle default behavior (allow/block all) and then mods provide overrides for each domain. It goes without saying that any command specific solution would depend on #124 , unless we just want to say whoever sets up the bot gets to decide and slap it into an env var.

joao-conde commented 1 year ago

Nah we need the settings. I am un-assigning myself, can't finish it. Feel free to @StaticRocket or @aquelemiguel

aquelemiguel commented 1 year ago

@StaticRocket @joao-conde I'm experimenting with the new modals feature for this allow/block domains config. It's fetching the allowed list from the GuildSettings and (should soon) update it on submit.

Opinions? I think it looks neat and cuts down on the # of commands we'd need otherwise.

image

StaticRocket commented 1 year ago

@aquelemiguel , the only concern I have is if the default behavior should be an allow list or a block list. I see one being useful for keeping things under lock and key but for those running the bot on a trusted server it may be tedious to allow almost all domains one by one.

joao-conde commented 1 year ago

I think it should be a black list approach, by default allow all. The modal looks good to me.

aquelemiguel commented 1 year ago

@StaticRocket @joao-conde Taking both your inputs into account, please feedback on this approach where we'd add two required fields to the modal - an allow list and a block list:

Is this implementation confusing? Am I overlooking any nasty edge cases?

afonsojramos commented 1 year ago

I'd say that's the fairest implementation of this feature. I do believe that in the case that if neither have a wildcard, you assume the default behaviour.

Question about the modals:

  1. Does it maintain state? If someone opens that modal after someone made changes, do you see those changes?
  2. Is there not a possibility of having two separate fields? One for the AllowList and another for the BlockList?
joao-conde commented 1 year ago

@aquelemiguel I was suggesting the exact opposite, and so was @StaticRocket I think.

afonsojramos commented 1 year ago

@joao-conde Initially, I was also supporting that approach, however, I do see the value for large servers to work on an AllowList.

aquelemiguel commented 1 year ago

@afonsojramos

Does it maintain state? If someone opens that modal after someone made changes, do you see those changes?

Yes, it reads from and writes to the GuildSettings, so if you were to block a domain, I would see it upon opening the modal.

Is there not a possibility of having two separate fields? One for the AllowList and another for the BlockList?

Definitely, that's what I suggested!

aquelemiguel commented 1 year ago

@joao-conde yt-dlp supports too many supported 18+ domains, it'd be hell for some servers to manually block all (and having to periodically check for new undesired domains). However simultaneously, some other servers may want to allow most. I think that was the point @StaticRocket was making and what prompted my approach.

joao-conde commented 1 year ago

Agreed, go with 2 lists for allowed and unallowed

StaticRocket commented 1 year ago

@joao-conde yt-dlp supports too many supported 18+ domains, it'd be hell for some servers to manually block all (and having to periodically check for new undesired domains). However simultaneously, some other servers may want to allow most. I think that was the point @StaticRocket was making and what prompted my approach.

Right, that and the general extractor they have can apply to domains that aren't necessarily listed on yt-dlp's compatibility page. An allow list approach becomes tedious with that. I run a server with a bunch of impatient goofs that'll pitch a fit if they can't blast a random meme across voice chat from god-knows-where.