Skip to content

Notuom/ytmd-obs-output

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

ytmd-obs-output

Open Broadcaster Software (OBS) streaming helper for YouTube Music Desktop.

Listens to the Playback interface of YTMD and outputs formatted track information and album art files which can be consumed by OBS.

Handy for streaming currently played song from YTMD and doesn't require configuration unless you want to customize the output.

Features

  • Automatically polls the YTMD Remote API for changes to the current track
  • Output track information to a txt file which can then be used in OBS Studio
    • Customizable track information display
  • Output album art to a png file which can then be used in OBS Studio
    • Customizable resolution
  • Easy to use! (kinda... 😉)

Setting up YouTube Music Desktop App

Before using the script, you should make sure the YTMD remote control API is enabled. See the official docs for more details (Settings -> Integrations -> Remote Control). Also, make sure your firewall is configured properly by allowing access to Node.js and YTMD if they ask for it (this will vary based on the OS but most likely it will happen).

Setting up and running the script

If you have prior Node.js experience, this should be no problem. If you don't, I tried to make things as easy as possible :

  1. Install Node.js v12 (or whichever LTS is available when you are reading this). Ensure the tools are installed in your PATH (for Windows, this should be an option in the installer).
  2. Download this repo. (Click here to download the latest version as a zip file)
  3. Extract somewhere you don't mind keeping it (for Windows, somewhere that doesn't require administrator access).
  4. Execute the install.bat file (Windows) or install.sh file (Linux / macOS). You should be able to do that by double-clicking it.
  5. Execute the ytmd_output.bat file (Windows) or ytmd_output.sh file (Linux / macOS). You should be able to do that by double-clicking it.
  6. To close the script, use CTRL+C or close the command prompt window.

Steps 1 - 4 only have to be done once. After that, simply execute the relevant ytmd_output file and let it run while YTMD and your streaming application are open.

Adding the output to OBS Studio

To add the current track info, add a new Text (GDI+) source. Check the "Read from file" box and choose the "Current_Track.txt" file generated by this program.

To add the album art, add a new Image source and select the Current_Album_Art.png file generated by this program.

Configuration

Open the config.json file in a text editor in order to change settings. Here are all the available settings.

Note: You can also look at the config.schema.json which contains the JSON schema for config.json. The config.json file will be validated against the schema before the script starts and any errors will be listed.

albumArtFilePath

The file path where to write the text file containing the album art.

You can specify an absolute path in order to write it to a folder different from the script's location.

Note: An additional file corresponding to this filename followed by ".tmp" will also be written to the folder. This is required in order to resize the image.

Default: Current_Album_Art.png

albumArtHeight

The height of the album art to output in pixels.

Default: 500

Note: When the track played is a YouTube video, the cover art won't be square, but it will be resized to fit within the maximum given width and height.

albumArtWidth

The width of the album art to output in pixels.

Default: 500

Note: When the track played is a YouTube video, the cover art won't be square, but it will be resized to fit within the maximum given width and height.

outputPattern

The pattern to use when writing the current track information. You can both use symbols that will be replaced by the track information and plain text that will be left as-is.

Example: Track: %title% by %author% would output Track: Never Gonna Give You Up by Rick Astley.

You can also provide an array of strings, in which case each pattern will be written in a different file (you would then need to provide an array of filenames in the trackFilePath option).

Example: ["File 1: %author%", "File 2: %title% (%album%)"] would output to 2 different files specified in trackFilePath.

Valid symbols : %title%, %author%, %album%. Use \n to insert a line break.

Default: %author%\n%title%\n%album%

Note: When the track played is a YouTube video, the album will be empty.

pollIntervalMs

The interval between each request the script will make to the YTMD Remote API in milliseconds.

Default: 1000

trackFilePath

The file path where to write the text file containing the track information.

You can specify an absolute path in order to write it to a folder different from the script's location.

Example: "track.txt" would output the pattern specified in outputPattern.

You can also pass an array of strings in order to output to multiple files.

Example: ["track1.txt", "track2.txt"] would output 2 different files using the patterns specified in outputPattern.

Default: Current_Track.txt

ytmdRemoteUrl

Full URL to the YTMD Remote API.

Default: http://localhost:9863/query

removeTrackAfterPausedForMs

How long to wait before clearing out the track info after the player is paused or stopped, in milliseconds.

Example: If set to 3000 and the track gets paused for at least 3 seconds (exact timing depends on the polling interval), the track file and cover art will be deleted.

Default: undefined

Special thanks

Special thanks to YTMD for the awesome application and easy to use API!

Other tools

For Google Play Music Desktop Player: https://github.com/Notuom/gpmdp-output

About

Output YouTube Music Destkop App track information for consumption in OBS.

Topics

Resources

Stars

Watchers

Forks