Удаляем старое говномесиво

This commit is contained in:
Lulzette 2021-07-18 00:31:39 +00:00
parent 06aaed3d0f
commit c8c902163b
3 changed files with 0 additions and 77 deletions

View File

@ -1,27 +0,0 @@
#!/bin/bash
##########
# check if stream is live and start recording using youtube-dl
##########
full_path=$(dirname "$(realpath $0)")
source $full_path/config_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)
#if pid exists and stream is live, than exit and do not start recording
[ -f $storage_path/$1/pid ] && $full_path/lifeChk.py $1 $twitchid && exit 0
#exit if no stream and remove lock
$full_path/lifeChk.py $1 $twitchid || rm $storage_path/$1/pid ; exit 0
echo $$ > $storage_path/$1/pid
#set pid and start recording
/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
# remove pid
rm $storage_path/$1/pid

29
cron.sh
View File

@ -1,29 +0,0 @@
#!/bin/bash
##########
# (actually main) script which cron (systemd.timer) starts by time
##########
full_path=$(dirname "$(realpath $0)")
source $full_path/config_list.sh
for i in $list; do
echo "$i is live?..."
#check folder
[ ! -d $storage_path/$i ] && mkdir -p $storage_path/$i && echo "Created dir $storage_path/$i"
#detached check & start
nohup bash $full_path/check.sh $i &>> $storage_path/$1/youtube-dl.log &
sleep 2
done
#Show status
echo
for i in $list; do
[[ -f $storage_path/$i/pid ]] && echo $i "is recording!" || echo $i "is not recording"
done
echo
echo "Removing old files (older than $ctime_remove days):"
find $storage_path/ -ctime +$ctime_remove -name "*mp4*"
find $storage_path/ -ctime +$ctime_remove -name "*mp4*" -exec rm {} \;
echo "Done"

View File

@ -1,21 +0,0 @@
#!/usr/bin/python3
#################
# return 0 if streamer is live (continue execution while in bash), 1 if not
#################
import sys
if (not sys.argv[1]) or (not sys.argv[2]):
sys.exit(2)
from twitch import TwitchClient
client = TwitchClient(client_id=sys.argv[2]) #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):
print(user_id)
print(client.streams.get_stream_by_user(user_id).stream_type)
if client.streams.get_stream_by_user(user_id).stream_type == 'live':
sys.exit(0)
sys.exit(1)