Created
January 31, 2019 18:48
-
-
Save noopkat/ea98f5a6ef197e636394ff7b270a16a0 to your computer and use it in GitHub Desktop.
Live Stream 'Now Playing' live text label
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# run the following line in your terminal to load the launch agent: | |
sudo launchctl load ~/Library/LaunchAgents/twitch.song_updater.plist |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just for anyone who might want to know, the AppleScript works perfectly with Spotify if you replace instances of
iTunes
withSpotify
! (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.)