Skip to content

Instantly share code, notes, and snippets.

@noopkat
Created January 31, 2019 18:48
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save noopkat/ea98f5a6ef197e636394ff7b270a16a0 to your computer and use it in GitHub Desktop.
Save noopkat/ea98f5a6ef197e636394ff7b270a16a0 to your computer and use it in GitHub Desktop.
Live Stream 'Now Playing' live text label
on is_running(appName)
tell application "System Events" to (name of processes) contains appName
end is_running
set iTunesRunning to is_running("iTunes")
set noMusic to "no music is playing"
set song to noMusic
if iTunesRunning then
set song to run script "tell application \"iTunes\" to if player state is playing then \"now playing: \" & name of current track & \" by \" & artist of current track"
try
song
return song
on error
return noMusic
end try
else
return noMusic
end if
#!/bin/bash
# Adds the currently playing iTunes track to a text file for an OBS text label.
#
SONG=`osascript ~/bin/twitch-scripts/iTunesSong.scpt`
echo -e $SONG > ~/Documents/twitch/custom-labels/now-playing.txt
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>twitch.song_updater.write_file</string>
<key>Program</key>
<string>/Users/noopkat/bin/twitch-scripts/nowPlaying.sh</string>
<key>RunAtLoad</key>
<true/>
<key>StartInterval</key>
<integer>10</integer>
</dict>
</plist>
# run the following line in your terminal to load the launch agent:
sudo launchctl load ~/Library/LaunchAgents/twitch.song_updater.plist
@otherjoel
Copy link

Just for anyone who might want to know, the AppleScript works perfectly with Spotify if you replace instances of iTunes with Spotify! (Of course, Spotify lacks a mini player…and if streaming, you want to be careful to use downloaded tracks so as not to waste bandwidth during your session.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment