Вот мое решение, которое я придумал
!/bin/bash
#
# YouTube live broadcast monitor
#
cd /var/azuracast/videostream/
youtubeURL=https://www.youtube.com/watch?v=BiHequcIiNw
# Get YouTube Manifest 1
youtube-dl -4 -f 91 -g $youtubeURL > manifest1.txt
# Probe Manifest 1
ffprobe -v quiet -print_format json -show_streams "$(<manifest1.txt)" > json1.txt
sleep 2
youtube-dl -4 -f 91 -g $youtubeURL > manifest2.txt
ffprobe -v quiet -print_format json -show_streams "$(<manifest2.txt)" > json2.txt
# do we have a valid json
starttime=$(cat json1.txt | jq '.streams[].start_time')
if [ -z "$starttime" ]; then
echo "$(date)" "Error: No start_time" "$starttime"
exit 1
fi
# compare the ffprobe json, if they are the same, the live stream stopped
if cmp -s json1.txt json2.txt; then
echo "$(date)" "Stream Down"
# restart stream
docker-compose restart videostream
echo "$(date)" "Stream Up"
sleep 20
else
echo "$(date)" "Stream Up"
fi