mattkirwan
6/1/2015 - 10:33 AM

A quick bash script to get the latest RDAD twitchers and show there current streaming status.

A quick bash script to get the latest RDAD twitchers and show there current streaming status.

#!/bin/bash
twitch_accounts=()

while read line
do
  twitch_accounts+=("$line")
done < <(curl http://www.reddit.com/r/RedditDads/wiki/twitch_and_youtube | grep "* http://www.twitch.tv/" | sed 's/* http\:\/\/www\.twitch\.tv\//\ /;s//\n/')

for twitch_account in "${twitch_accounts[@]}"
do
	twitch_account="${twitch_account//[[:space:]]/}"
  	status_response=$(curl -sS --silent -H 'Accept: application/vnd.twitchtv.v3+json' -X GET "https://api.twitch.tv/kraken/streams/$twitch_account" | sed -e "s,.*\"stream\"\:null.*,"$(printf "\033[31mOFFLINE\033[0m")"," -e t -e "s,.*,"$(printf "\033[32mLIVE\033[0m")",")
  	echo "$twitch_account: $status_response"
done