Last active
May 6, 2018 18:33
-
-
Save theGeekPirate/f2e4dd7d520dc0d82b6e15313d9372f5 to your computer and use it in GitHub Desktop.
Twitch Streams
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 | |
#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