Created
December 19, 2017 21:14
-
-
Save non-carbondated/0437a657769264ff09ef3828080905b7 to your computer and use it in GitHub Desktop.
Simple script to update Slack status with the currently playing Streaming Soundtracks track via iTunes
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 | |
APIKEY="_APIKEY_"; #From Here https://api.slack.com/custom-integrations/legacy-tokens | |
CURRENTSTREAMINFO="" | |
while true | |
STREAM=$(osascript -e 'tell application "iTunes" to current stream title as string') | |
STREAMINFO=${STREAM/\([\d|:]+?\)$/""} | |
MESSAGE=$(echo "$STREAMINFO" | perl -MURI::Escape -ne 'chomp;print uri_escape($_),"\n"') | |
do | |
if [ "$CURRENTSTREAMINFO" != "$STREAMINFO" ] | |
then | |
CURRENTSTREAMINFO=$STREAMINFO | |
curl -s -d "payload=$json" "https://slack.com/api/users.profile.set?token="$APIKEY"&profile=%7B%22status_text%22%3A%22"$MESSAGE"%22%2C%22status_emoji%22%3A%22%3Astreamingsoundtracks%3A%22%7D" > /dev/null | |
fi | |
sleep 10 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment