cva was buggy, nrt add -f -r -t flags

This commit is contained in:
inigoortega 2020-03-31 16:09:19 +02:00
parent 3993cdb183
commit 664209251e
2 changed files with 39 additions and 19 deletions

View File

@ -5,21 +5,12 @@ last_watched_video="$2"
[ -n "$3" ] && dateafter="--dateafter $3"
fifo="/tmp/cva-fifo-$(date +%s%N)"
mkfifo "$fifo"
dash $TSCRIPTS/no-response-timeout.sh -f 63 -r 10 \
youtube-dl --get-id "$channel" $dateafter 2>/dev/null |
while read -r line && [ "$line" != "$last_watched_video" ]; do
echo "$line"
done
dash $TSCRIPTS/no-response-timeout.sh 19 \
youtube-dl --get-id "$channel" $dateafter 2>/dev/null > "$fifo" &
while read -r line; do
if [ "$line" != "$last_watched_video" ]; then
echo "$line"
else
exit
fi
done < "$fifo"
rm "$fifo"
# youtube-dl --get-id "$channel" | grep -B 4 "$last_watched_video" | tee /home/initega/test/test -a &
# child_pid=$!

View File

@ -1,18 +1,47 @@
#!/usr/bin/env sh
time="$1"
shift
usage() {
printf "HELP ME"
}
(sleep "$time" && kill -INT "$$" 2>/dev/null) &
while getopts ":t:r:f:" option; do
case "${option}" in
t)
time="${OPTARG}"
;;
r)
time4rest="${OPTARG}"
;;
f)
time4first="${OPTARG}"
;;
*)
usage
;;
esac
done
shift $((OPTIND-1))
[ -z "$time" ] && time="30"
[ -z "$time4rest" ] && time4rest="$time"
[ -z "$time4first" ] && time4first="$time"
{
sleep "$time4first"
kill -INT "$$" 2>/dev/null
} &
checkpoint_pid="$!"
fifo="/tmp/no-response-timout-fifo$(date +%s%N)"
mkfifo "$fifo"
sh -c "$*" > "$fifo" &
while read line; do
while read -r line; do
kill "$checkpoint_pid"
(sleep "$time" && kill -INT "$$" 2>/dev/null) &
{
sleep "$time4rest"
kill -INT "$$" 2>/dev/null
} &
checkpoint_pid="$!"
echo "$line"