Skip to content

Instantly share code, notes, and snippets.

@theGeekPirate
Last active May 6, 2018 18:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theGeekPirate/f2e4dd7d520dc0d82b6e15313d9372f5 to your computer and use it in GitHub Desktop.
Save theGeekPirate/f2e4dd7d520dc0d82b6e15313d9372f5 to your computer and use it in GitHub Desktop.
Twitch Streams
#!/bin/bash
#Uses https://github.com/GiedriusS/TwitchNotifier along with zenity
#to provide a nice list of followed streams which are currently online,
#then plays the selected stream using youtube-dl and mpv.
if [ -z "$2" ]; then
streamsOnline=$(twitchnotifier -c thegeekpirate -n | sort)
numCharsLongestChan=$(echo "$streamsOnline" | cut -d "^" -f 1 | wc -L)
numCharsLongestGame=$(echo "$streamsOnline" | cut -d "^" -f 2 | wc -L)
width=$((117+(numCharsLongestChan+numCharsLongestGame)*5))
numStreams=$(echo "$streamsOnline" | wc -l)
height=$((110+(numStreams*25)))
#In ~/.config/twitchnotifier.cfg, we need the following:
#list_entry=$1^$3
channelName=$(echo "$streamsOnline" | tr ^ '\n' | zenity --list --width=$width --height=$height --title="Twitch Streams" --column="Channel" --column="Game")
fi
if [ "$?" -eq 0 ] || [ -n "$2" ]; then
mpv https://twitch.tv/"${2:-$channelName}" -ytdl-format="${1:-480p}"
else
echo "No stream specified"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment