```sh #scheduled stream tracker for youtube #lists only the current live or the soonest premiering stream per channel #required arguments: channels_file invidious_instance #output is stored in out.txt, use grep and sort to filter accordingly #sample run: sh trackstreamyt.sh channels.txt https://invidious.privacydev.net; grep ^Live out.txt; grep minute out.txt | sort; grep hour out.txt | sort #channels_file contains a list of channel ids #sample content #UCqfVP-d0Flj_ygWJ9m8gHMQ #UCIoRFfQdwgErIokdU4Zb-Sg #UCejbicoRnQjCOdAPAv5JPwg #last line is empty (hit enter on the last channel id or else it will not be read) #tested with the following invidious instances # https://vid.puffyan.us # https://invidious.privacydev.net #for other instances go to invidio.us #check first if the url loads properly in the browser #recommended run schedule is every 45th minute of the hour #because the hour indicated is the floor value #"Premieres in 1 hour" means stream will start in around 1-2 hours infile="$1" invidious="$2" echo "Start: "`date` | tee out.txt echo "----------------------" | tee -a out.txt cat "$infile" | while read ch do curl "${invidious}/channel/${ch}/streams" | grep -B60 ">0 view" | tail -60 > info.tmp if test -s info.tmp then url=`grep "Watch on YouTube" info.tmp | cut -d'"' -f4 | cut -d'/' -f4` time_info="" if grep -q Shared info.tmp then time_info="Live : A LITERAL 0 VIEW VOD" else time_info=`grep Premieres info.tmp | cut -d'>' -f2 | cut -d'<' -f1` fi echo "${time_info} + "`grep channel-name info.tmp | cut -d'>' -f2`" + "`grep "a href=\"/${url}\"" info.tmp | cut -d'>' -f3 | cut -d'<' -f1`" + https://www.youtube.com/${url}" >> out.txt fi done sed -i "s/^ /Live /" out.txt echo "----------------------" | tee -a out.txt echo "End: "`date` | tee -a out.txt echo echo ```