twitch-autosave/check.sh
lulzette d15e9a7132 added check for dead recorders
got rid of absolute hardcoded paths
renamed some stuff cause of readability
decreased delay between checks
2020-03-21 09:33:16 +03:00

26 lines
671 B
Bash
Executable File

#!/bin/bash
##########
# check if stream is live and start recording using youtube-dl
##########
full_path=$(dirname "$(realpath $0)")
source $full_path/list.sh
#check if not running, kill if running and stream is finished (broken record)
[ -f $storage_path/$1/pid ] && $full_path/lifeChk.py $1 && exit 0 || kill -9 $(cat $storage_path/$1/pid)
#exit if no stream
$full_path/lifeChk.py $1 || exit 0
#set pid and start downloading
nohup $ytdl_path/youtube-dl -v -o $storage_path/$1/"%(upload_date)s_%(title)s__%(timestamp)s_%(id)s.%(ext)s" twitch.tv/$1 >> $storage_path/$1/youtube-dl.log 2>&1 & echo $! > $storage_path/$1/pid
#remove pid
rm $storage_path/$1/pid