Youtube Music Integration with controls

Description

This extension will allow you to use Youtube Music app with streamerbot.

  • Ability to control Youtube music with streamer bot.
  • Ability to fetch current playing song and last added song.

Import Code

Import the following code in streamer bot.
ytmusic v2.sb (5.4 KB)

Resources

These are the requirements for getting this to work.

Please only use the non-WebSetup version as WebSetup version does not come
with webserver plugin

  • OBS Plugin : Tuna-OBS
  • Obviously StreamerBot.

Installation

Import the ytmusic v2.sb (5.4 KB) in Streamer.bot

In Streamer.bot click the Import button in the top menu. Drag the .sb file into the Import String field.

First Step

Assuming you have the “YTMusic fork by MrF1yn” app installed. (Please use non-WebSetup version as WebSetup version doesn't have webserver plugin in it.)

  1. Open YTMusic app and on navigation bar click on options > uncheck Auto Update (Disable auto update)
    image

  2. On the navigation bar go to plugins > webserver & enable the plugin if its disabled.
    websrv

  3. Enable Tuna plugin in YTMusic app on the navigation bar go to plugins > Tuna OBS.
    tuna1

Second Step

Assuming you have the “Tuna-OBS” plugin installed.

  1. In OBS go to Tools > Tuna Settings & set Song source to Web browser also enable Host/receive information on local webserver with port 1608. (Don’t forget to start tuna and apply)

Do not change the default webserver port or the data won’t be passes to streamer bot. Also clear your song queue and start the song with command so everything functions properly.

If you followed all the steps correctly then you are good to go. :+1:

Changelogs

V2

  • Changed the code in Music Now Playing to not create new browser instance. (Thanks to @rondhi for giving me a new code.)
  • Updated the header name from value to name in play command.

Configuration

These are the things you can configure with this setup.

  • Play Music
    you can add music to queue and/or force play the music immediately.
    http://localhost:8888/play & http://localhost:8888/video use following headers.

    Header Value Description
    name song name This header takes the name of the song as input an adds it to the queue
    force true/false This header tells the YTMusic app to either add the song to the queue or forcefully play it immediately
  • Fetch last added song
    http://localhost:8888/lastAdded gives the name of the last added song.

  • Play / Pause Music
    http://localhost:8888/playpause allows you to toggle the state of music.

  • Play next song or previous song

    1. http://localhost:8888/playnext allows you to skip to the next song.
    2. http://localhost:8888/playprevious allows you to jump to the previous song.
  • Queue
    http://localhost:8888/queue gives you song queue list. (I haven’t use this)

Commands

These are the available commands feel free to change them.

Command Description
!p <song name> plays the song. (play)
!vp <song name> plays the video song. (video play)
!np Tells the current song name. (now playing)
!pause, !resume, !stop Toggle the song state from play to stop or vice versa.
!s Skips the current playing song. (skip)

Contributors

This is not a production based solution but it gets the job done. If you have something to suggest feel free to do so.

If you liked this then do check my socials : https://krak8.xyz
I also have a way to control audio output volume in OBS via StreamerBot if you want that then do let me know.

1 Like

Sadly this does not follow the Submission Template so it can not be approved. I will leave this submission here for 30 more days to give you time to update it to follow the template. If within 30 days you don’t update it then it will auto close and will be moved to declined.

I have made the changes do check if this format works. @GoWMan

I’m currently checking it a bit, the first thing I noticed in your instructions it says to enable the webserver in the App, however at least in the latest version I just downloaded there is no Webserver included in the plugins, so I can’t really test further atm.

Second in the action called Music Now Playing, you are using “using WebClient”, best case you would be creating static instance of the WebClient and in the Execute Code subaction settings “Keep Instance Active”. This way it will not create a new Webclient everytime the command is called, and uses only once WebClient instance. This might not be a big issue tho!

I’m a bit confused as to how it’s decided to which playlist the songs are getting added to? For example at the very start I tested the play/pause option, worked as intended is just played a random song, in this case it was an Imagine Dragons album. Adding songs to the queue then added the songs to that album queue. Now I thought, I’ll just create a new playlist and start playing it, then it should probably recognize that it’s playing the specific playlist and add the songs to that queue. But honestly I had no clue where the songs were getting added in the end. So maybe it’s just user error but unsure…

Quoted reply by @pwnyy (Jump)
Second in the action called Music Now Playing, you are using “using WebClient”, best case you would be creating static instance of the WebClient and in the Execute Code subaction settings “Keep Instance Active”. This way it will not create a new Webclient everytime the command is called, and uses only once WebClient instance. This might not be a big issue tho!

I am unfamiliar with C# and the code is made using Chat GPT. If someone can help me fix it I will make the necessary changes.

Quoted reply by @pwnyy (Jump)
I’m a bit confused as to how it’s decided to which playlist the songs are getting added to? For example at the very start I tested the play/pause option, worked as intended is just played a random song, in this case it was an Imagine Dragons album. Adding songs to the queue then added the songs to that album queue. Now I thought, I’ll just create a new playlist and start playing it, then it should probably recognize that it’s playing the specific playlist and add the songs to that queue. But honestly I had no clue where the songs were getting added in the end. So maybe it’s just user error but unsure…

So the songs are getting added to queue not the playlist. If you start with songs already in your queue then the songs you add will be in the last or end of the queue. I will recommend starting with empty queue so that the songs requested by the chat will be the ones playing.

I have updated few things in V2 please refer to #changelogs.
Once again thanks to @rondhi for helping me with new code.

You should point to https://github.com/MrF1yn/youtube-music/releases/latest

As well as point out to download the non-WebSetup version because the WebSetup version does not come with the Webserver plugin.

Oh yes I should do that thanks for the suggestions :smiley: