Programmatically detect if Spotify is playing

Plan

Premium

Country

USA

Device

Any

Operating System

Any

 

My Question or Issue

So, I'm a noob.  I would like to run a script on my Windows PC if Spotify (the service, not the Windows app, as the Windows app may not be running) is playing a song.  To put it into psuedo-code,
if SpotifyPlaying = True then ExecuteThisScript.bat
My script changes the output device of my PC to a ghetto whole-house speaker system I made. 

Bonus points (but absolutely not required) if the script can tell WHICH device is playing Spotify.

I found this guide, https://developer.spotify.com/console/get-users-currently-playing-track/ , and I can use it to generate a token to use CURL to output to  a .txt file with my WSL installation.  The text file tells me if something is playing, but I don't know how to connect this to an automation.

Thank you in advance to anyone who can help me! 

Child Item
Child Item
Child Item

Accepted answers

All comments

Child Item
Child Item