2019-11-09 01:29:29 +03:00
|
|
|
#!/bin/bash
|
|
|
|
##########
|
|
|
|
# check if stream is live and start recording using youtube-dl
|
|
|
|
##########
|
|
|
|
|
2020-03-21 09:33:16 +03:00
|
|
|
full_path=$(dirname "$(realpath $0)")
|
2019-11-09 01:29:29 +03:00
|
|
|
|
2021-04-21 21:43:30 +03:00
|
|
|
source $full_path/config_list.sh
|
2020-03-21 09:33:16 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#check if not running, kill if running and stream is finished (broken record)
|
2021-04-21 21:43:30 +03:00
|
|
|
# [ -f $storage_path/$1/pid ] && $full_path/lifeChk.py $1 && exit 0 || kill -9 $(cat $storage_path/$1/pid)
|
|
|
|
[ -f $storage_path/$1/pid ] && $full_path/lifeChk.py $1 && exit 0
|
2020-03-21 09:33:16 +03:00
|
|
|
|
|
|
|
#exit if no stream
|
|
|
|
$full_path/lifeChk.py $1 || exit 0
|
2021-04-21 22:03:55 +03:00
|
|
|
# echo `$full_path/lifeChk.py $1`
|
2019-11-09 01:29:29 +03:00
|
|
|
|
|
|
|
#set pid and start downloading
|
2021-04-21 22:03:55 +03:00
|
|
|
echo $! > $storage_path/$1/pid
|
|
|
|
/home/losted/.local/bin/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
|
2020-03-21 09:33:16 +03:00
|
|
|
|
|
|
|
|
|
|
|
#remove pid
|
|
|
|
|
|
|
|
rm $storage_path/$1/pid
|