#!/bin/bash
# Uber generic script to watch twitch live streams easily.
# This pipes the output of ffmpeg to STDIN to be read by ffplay.
# Uses a modified ffplay binary borrowed from PPCMC by alex_free.
# Copyright 2021 wicknix
#
echo ""
echo ""
echo "If this stops working, please remember to update youtube-dl"
echo "Open Terminal.app and issue the following command to update"
echo "/Applications/TwitchPlay.app/dist/bin/youtube-dl -U"
echo " "
echo "               ________ "
echo "              |        |"
echo "Twitch        |   | |  |"
echo "Play          |_  ____/ "
echo "                |/      "
echo " "
echo "Navigate to https://m.twitch.tv and find somebody to watch."
echo "Enter the name of the 'live' Twitch channel you want to stream."
echo "Note: The channel name must be typed in lowercase letters."
read CHANNEL
echo "----"
echo "Choose your desired stream quality: (360p recommended on G4)"
echo "160p"
echo "360p"
echo "480p"
echo "720p"
echo "----"
read QUALITY
echo "----"
echo "Loading $CHANNEL @ $QUALITY ...."
export PATH="/Applications/TwitchPlay.app/dist/bin:$PATH"
/Applications/TwitchPlay.app/dist/bin/youtube-dl --proxy "" -f $QUALITY -o - https://www.twitch.tv/$CHANNEL | /Applications/TwitchPlay.app/dist/bin/ffplay -window_title TwitchPlay -
# If you want to use VLC instead comment out the line above and uncomment the next line
#/Applications/TwitchPlay.app/dist/bin/youtube-dl --proxy "" -f $QUALITY -o - https://www.twitch.tv$CHANNEL | /Applications/VLC.app/Contents/MacOS/VLC -