-
Notifications
You must be signed in to change notification settings - Fork 0
/
parse.sh
39 lines (39 loc) · 1.21 KB
/
parse.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
if [ "$1" = "video" ]; then
while sleep 1; do
logfile=${2%.*}.txt;
progress=$(cat $logfile | egrep -o "\[[0-9.%]*\]" | tail -n 1 | cut -d"[" -f2 | cut -d"]" -f1 | cut -d"%" -f1);
eta=$(cat $logfile | egrep -o "eta [0-9:]*" | tail -n 1 | cut -d" " -f2);
end=$(cat $logfile | egrep -o "encoded [0-9/]*" | cut -d" " -f1);
./connection.php $1 $2 $progress $eta;
if [ "$end" = "encoded" ]; then
echo "ended";
break;
fi
done
fi
if [ "$1" = "audio" ]; then
sleep 1;
logfile=${2%.*}_audio.txt;
hours=$(cat $logfile | egrep -o "Duration: [0-9:]*" | cut -d":" -f2);
minutes=$(cat $logfile | egrep -o "Duration: [0-9:]*" | cut -d":" -f3);
seconds=$(cat $logfile | egrep -o "Duration: [0-9:]*" | cut -d":" -f4);
length=$(($hours*3600+$minutes*60+$seconds));
while sleep 1; do
progress=$(cat $logfile | egrep -o "time=[0-9.]*" | tail -n 1 | cut -d"=" -f2 | cut -d"." -f1);
progresspercent=$(($progress*100 / $length));
echo $progresspercent;
./connection.php $1 $2 $progresspercent;
if [ "$progresspercent" = "100" ]; then
sleep 5;
break;
fi
done
fi
if [ "$1" = "mux" ]; then
logfile=${2%.*}_mux.txt;
while sleep 1; do
string=$(cat $logfile | sed 's/|=*\ *|\ //');
echo $string;
done
fi