first
This commit is contained in:
commit
53cbd997d0
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
list.sh
|
17
check.sh
Executable file
17
check.sh
Executable file
@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
##########
|
||||
# check if stream is live and start recording using youtube-dl
|
||||
##########
|
||||
|
||||
source /opt/downloader/list.sh
|
||||
#check if not running
|
||||
[ -f $path/$1/pid ] && exit 0
|
||||
|
||||
#check if live
|
||||
/opt/downloader/lifeChk.py $1 || exit 0
|
||||
|
||||
|
||||
#set pid and start downloading
|
||||
touch $path/$1/pid
|
||||
/home/ubuntu/.local/bin/youtube-dl -v -o $path/$1/"%(uploader)s__%(upload_date)s_%(timestamp)s__%(title)s_%(id)s.%(ext)s" twitch.tv/$1 > $path/$1/youtube-dl.log
|
||||
rm $path/$1/pid
|
25
cron.sh
Executable file
25
cron.sh
Executable file
@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
##########
|
||||
# (actually main) script which cron (systemd.timer) starts by time
|
||||
##########
|
||||
source /opt/downloader/list.sh
|
||||
|
||||
for i in $list; do
|
||||
echo "$i is live?..."
|
||||
|
||||
#check folder
|
||||
[ ! -d $path/$i ] && mkdir -p $path/$i && echo "Created dir $path/$i"
|
||||
|
||||
#detached check & start
|
||||
screen -dmS $i bash /opt/downloader/check.sh $i
|
||||
sleep 5
|
||||
|
||||
done
|
||||
|
||||
#Show status
|
||||
echo "===="
|
||||
|
||||
for i in $list; do
|
||||
cat $path/$i/pid 2>/dev/null && echo $i "is recording!" || echo $i "is not recording"
|
||||
done
|
||||
echo "===="
|
19
lifeChk.py
Executable file
19
lifeChk.py
Executable file
@ -0,0 +1,19 @@
|
||||
#!/usr/bin/python3
|
||||
#################
|
||||
# return 0 if streamer is live (continue exec while in bash), 1 if not
|
||||
#################
|
||||
import sys
|
||||
#if not sys.argv[1]:
|
||||
# sys.exit(2)
|
||||
|
||||
twitchid = "59hrsplx7dmvc17pqkqcm9l3n1uzc4"
|
||||
from twitch import TwitchClient
|
||||
client = TwitchClient(client_id=twitchid) #client init
|
||||
user_id=client.users.translate_usernames_to_ids(sys.argv[1])[0].id #get id
|
||||
#get live by id (if var not empty)
|
||||
|
||||
if client.streams.get_stream_by_user(user_id):
|
||||
sys.exit(0)
|
||||
else:
|
||||
sys.exit(1)
|
||||
|
9
list.sh.template
Normal file
9
list.sh.template
Normal file
@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
###########
|
||||
# just config file
|
||||
###########
|
||||
|
||||
list="jesusavgn"
|
||||
|
||||
path="/media/twitch/automatedRecording"
|
||||
ytdliConf="-o %(uploader)s__%(upload_date)s_%(timestamp)s__%(title)s_%(id)s.%(ext)s"
|
Loading…
Reference in New Issue
Block a user