-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathza-gd.sh
113 lines (95 loc) · 1.95 KB
/
za-gd.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/zsh
typeset -i COUNTER=0
digs=$(pwd)"/digests"
cwd=$(pwd)
cron_search()
{
odate="20220101"
dates=()
for file in $1/digest-*.m*
do
fname=${file##*/}
fdate=${fname:7:8}
if [ $fdate -ne $odate ]
then
dates+="$fdate"
odate=$fdate
fi
done
echo "$dates"
echo $#dates
}
rc_day()
{
day=$1
format=$2
cwd=$(pwd)
ffmap=""
for i in $digs/digest-$day*.m*
do
ffmap="$ffmap\n-i $i "
done
echo $ffmap
product="day-digest-$day.$format"
elevel="error" #elevel="debug"
ffmpeg -hide_banner -loglevel $elevel -y \
-safe 0 \
-f concat \
-i <(for i in $digs/digest-$day*.m*; do echo "file '$i'"; echo "outpoint 60"; done;) \
-an \
-c copy -r 15 "$product"
target="zgd:/ザッ君/digests"
echo "rcloning file from $product to $target"
rclone copy $product "$target"
}
for ARGUMENT in "$@"
do
KEY=$(echo $ARGUMENT | cut -f1 -d=)
VALUE=$(echo $ARGUMENT | cut -f2 -d=)
case "$KEY" in
d) day=${VALUE} ;;
f) format=${VALUE} ;;
debug) debug=${VALUE} ;;
cron) cron=${VALUE}} ;;
*) echo "unknown: " $KEY " " $VALUE ;;
esac
done
if [ -z "$format" ]
then
format="mkv"
fi
if [ -n "$cron" ]
then
echo "cron mode"
{
read -r days
read -r day_count
} <<< "$(cron_search $digs)"
my_count=0
for goday in $(echo "$days")
do
my_count=$(($my_count+1))
if [[ $my_count -eq $day_count ]]
then
echo "last day $goday - might be incomplete skipping "
else
echo "test for >$goday<"
test=$(echo "$cwd/day-digest-$goday.$format")
if [ -f "$test" ]
then
echo "found $goday"
else
echo "file not found for $goday"
rc_day $goday $format
fi
fi
done
exit
fi
if [ -z "$day" ]
then
echo "you must set a date"
exit
else
rc_day $day $format
fi