bhj / KaraokeEternal

Open karaoke party system
https://www.karaoke-eternal.com
ISC License
452 stars 67 forks source link

YouTube search and automatic karaoke mix creation #34

Closed gazugafan closed 3 years ago

gazugafan commented 3 years ago

I went a little nuts the past few months and added the ability to search for songs on YouTube. You can search for pre-made karaoke mixes 🥱💤, but the really crazy part... you can search for normal songs or music videos and have them automatically turned into karaoke mixes in the background while other songs are being sang 🤯

Here's a video demonstrating the new features... https://youtu.be/zWa8k6degVs

I understand if you don't want to merge this in. It's a lot of new code to maintain, and it maybe might possibly potentially draw some... unwanted attention. It also might run slightly contrary to some of your stated project goals (like easy setup and not requiring an Internet connection). But, it's also really easy to disable (it is by default), and probably easy enough to completely strip out if necessary.

Hope you give it a look and consideration!

bhj commented 3 years ago

This is truly awesome, and the effort to integrate it so seamlessly has not gone unnoticed! 🤯

For historical reference, there used to be YouTube support where you could add known-good karaoke channels, it would pull their songs' meta into the library and the player streamed the videos. During development one of the channels suddenly disallowed playback in 3rd party players (presumably because they don't show ads) so I ended up ripping out that code in e7308c9293ba7f3a7a562395bdbb6f2f14d49688, keeping everything file-based for stability.

That doesn't mean we can't use this though! Would you be willing to hop on the Discord? I have some ideas and there are a few others that might have input too.

gazugafan commented 3 years ago

I did not know that! Omw to the discord.

rizzlesauce commented 3 years ago

@gazugafan it looks like we've been on a similar wavelength! I just did some related YouTube work recently: https://github.com/bhj/karaoke-forever/pull/35

I haven't checked out your implementation yet but I'm very interested to see what you've done and possibly incorporate it into my project.

gazugafan commented 3 years ago

Hey, nice! I just took a look at your screenshots. Looks like one of the big differences is that you have people perform the search externally on YouTube and then copy/paste the link back in KF. I used https://github.com/TimeForANinja/node-ytsr to do the YouTube search from the KF server and return the results back to the KF client directly.

rizzlesauce commented 3 years ago

Yes, I saw your video and it's very impressive! I wanted to do the YT search within the app but I didn't get around to it yet. You have gone above and beyond with your solution in many ways, particularly with the auto creation of karaoke videos! I'm curious if you ran into some of the same name collision issues I did with having variations of the same song in the library (kind of an edge case). I think I'll probably just drop most of my YT changes and merge in yours instead. Very nicely integrated into the UI for a good user experience! Thank you for your work. I wish I'd known about it a few weeks ago haha.

rizzlesauce commented 3 years ago

Also, something I noticed about my solution is that the app was unable to determine the duration of some YT video files. I think this may be due to the download library I'm using getting the wrong file format in some cases (like maybe getting a format that didn't have audio in it, for example). I wonder if you ran into this issue.

gazugafan commented 3 years ago

Glad you're liking how I did things!!!

I'm curious if you ran into some of the same name collision issues I did with having variations of the same song in the library (kind of an edge case)

I don't think I ran into this. YouTube videos are handled a little differently in the queue with the way I did it, and they don't reference the local song library. So I don't think a name conflict would cause a problem.

Also, something I noticed about my solution is that the app was unable to determine the duration of some YT video files

The library I'm using for the download is https://github.com/fent/node-ytdl-core, but if I remember right I'm getting the duration straight from the search results--not the download. You do need to be a little careful with how this library downloads things. I had to set it to download specifically audio/video separately. Otherwise it'll occasionally download both in one container, which could lead to problems if you're not expecting that. Here's the relevant bit...

ytdl(video.url, { quality: 'highestaudio', filter:'audioonly' })
ytdl(video.url, { quality: 'highestvideo', filter:'videoonly' })

... and then I use FFMPEG to combine the two.

gazugafan commented 3 years ago

I'm moving development of this feature on my fork from the main branch to feature/youtube, so recreated this PR as #37 and closing this one!