-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquartero4-2
More file actions
executable file
·489 lines (401 loc) · 19.3 KB
/
quartero4-2
File metadata and controls
executable file
·489 lines (401 loc) · 19.3 KB
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
#!/bin/bash
#set -x
. /usr/local/bin/editscript
. ~/.config/indexopus.conf
tmp="$CACHE"
mp=tmp
scriptname=$(realpath "$0")
ulon=$(tput smul) # underline on
uloff=$(tput rmul) # underline off
bold="$(tput bold)" # bold on
tput0="$(tput sgr0)" # clear tput
red="$(tput setaf 9)" # red fg
white="$(tput setaf 15)" # white fg
relipsis="${red}..."
shopt -s nullglob extglob dotglob
[[ ! "$threads" ]] && threads=4
#rmmatch=false
#screened=false
source <(sourcefn -l "$HOME/bin/gits/indexopus/indexopus.lib" -f printline -f confirm)
cd-(){ cd - >/dev/null ; }
rmyn(){
while true; do
read -rp "$1"$'\n ' rmyn
case "$rmyn" in
[yY] ) "${@:3}"; break;;
[nN] ) printf '%s\n' "$2"; break;;
* ) printf "Invalid response...\n";;
esac
done
}
calctime(){
local findtitle
findtitle="$1"
[[ "$findtitle" = *\[* || "$findtitle" = *\]* ]] && findtitle="${findtitle//\[/\\[}" && findtitle="${findtitle//\]/\\]}"
(( verbose )) && pause "findtitle=$findtitle"
duration=$(find -type f -name "$findtitle" -print0 | xargs -0 mplayer -vo dummy -ao dummy -identify 2>/dev/null | perl -nle '/ID_LENGTH=([0-9\.]+)/ && ($t +=$1) && printf "%02d:%02d:%02d\n",$t/3600,$t/60%60,$t%60' | tail -n 1)
hours=$(find -type f -name "$findtitle" -print0 | xargs -0 mplayer -vo dummy -ao dummy -identify 2>/dev/null | perl -nle '/ID_LENGTH=([0-9\.]+)/ && ($t +=$1) && printf "%02d\n",$t/3600' | tail -n 1)
minutes=$(find -type f -name "$findtitle" -print0 | xargs -0 mplayer -vo dummy -ao dummy -identify 2>/dev/null | perl -nle '/ID_LENGTH=([0-9\.]+)/ && ($t +=$1) && printf "%02d\n",$t/60%60' | tail -n 1)
seconds=$(find -type f -name "$findtitle" -print0 | xargs -0 mplayer -vo dummy -ao dummy -identify 2>/dev/null | perl -nle '/ID_LENGTH=([0-9\.]+)/ && ($t +=$1) && printf "%02d\n",$t%60' | tail -n 1)
[[ "$hours" =~ "0*(.*)" ]] && hours=${BASH_REMATCH[1]}
[[ "$minutes" =~ "0*(.*)" ]] && minutes=${BASH_REMATCH[1]}
[[ "$seconds" =~ "0*(.*)" ]] && seconds=${BASH_REMATCH[1]}
printf "Duration: %s\n" "$duration"
hours="${hours#0}"
hourmin=$(( hours*60 ))
minutes="${minutes#0}"
secmin=$((hourmin+minutes))
secmin=$((secmin*60))
seconds="${seconds#0}"
totalsec=$(( "$seconds" + "$secmin" ))
# divsec=$(python3 -c "print($totalsec/$threads)")
divsec=$(echo "($totalsec/$threads)" | bc -l)
(( verbose )) && printf 'hours: %s\nminutes: %s\nseconds: %s\ntotalsec: %s\ndivsec: %s\n' \
"$hours" "$minutes" "$seconds" "$totalsec" "$divsec"
}
##--> calctime() <--###################################################################
calctime2(){
(( verbose )) && pause "Entering function: ${FUNCNAME[0]}"
local findtitle path
findtitle="$1"
findtitle="$(basename "$findtitle")"
path="$1"
# [[ "$findtitle" = *\[* || "$findtitle" = *\]* ]] && findtitle="${findtitle//\[/\\[}" && findtitle="${findtitle//\]/\\]}"
#(( verbose )) && pause "findtitle=$findtitle"
(( verbose )) && pause "path=$path"
#duration=$(find -type f -name "$findtitle" -print0 | xargs -0 mplayer -vo dummy -ao dummy -identify 2>/dev/null | perl -nle '/ID_LENGTH=([0-9\.]+)/ && ($t +=$1) && printf "%02d:%02d:%02d\n",$t/3600,$t/60%60,$t%60' | tail -n 1)
#hours=$(find -type f -name "$findtitle" -print0 | xargs -0 mplayer -vo dummy -ao dummy -identify 2>/dev/null | perl -nle '/ID_LENGTH=([0-9\.]+)/ && ($t +=$1) && printf "%02d\n",$t/3600' | tail -n 1)
#minutes=$(find -type f -name "$findtitle" -print0 | xargs -0 mplayer -vo dummy -ao dummy -identify 2>/dev/null | perl -nle '/ID_LENGTH=([0-9\.]+)/ && ($t +=$1) && printf "%02d\n",$t/60%60' | tail -n 1)
#seconds=$(find -type f -name "$findtitle" -print0 | xargs -0 mplayer -vo dummy -ao dummy -identify 2>/dev/null | perl -nle '/ID_LENGTH=([0-9\.]+)/ && ($t +=$1) && printf "%02d\n",$t%60' | tail -n 1)
#
#[[ "$hours" =~ "0*(.*)" ]] && hours=${BASH_REMATCH[1]}
#[[ "$minutes" =~ "0*(.*)" ]] && minutes=${BASH_REMATCH[1]}
#[[ "$seconds" =~ "0*(.*)" ]] && seconds=${BASH_REMATCH[1]}
#
#(( verbose )) && printf 'hours: %s\nminutes: %s\nseconds: %s\ntotalsec: %s\ndivsec: %s\n' "$hours" "$minutes" "$seconds" "$totalsec" "$divsec"
duration=$(mplayer -vo dummy -ao dummy -identify "$path" 2>/dev/null | \
perl -nle '/ID_LENGTH=([0-9\.]+)/ && ($t +=$1) && printf "%02d:%02d:%02d\n",$t/3600,$t/60%60,$t%60')
IFS=: read -r hours minutes seconds <<< "$duration"
(( verbose )) && printf 'hours: %s\nminutes: %s\nseconds: %s\ntotalsec: %s\ndivsec: %s\n' "$hours" "$minutes" "$seconds" "$totalsec" "$divsec" && pause
printf "Duration: %s\n" "$duration"
hours="${hours#0}"
hourmin=$(( hours*60 ))
minutes="${minutes#0}"
secmin=$((hourmin+minutes))
secmin=$((secmin*60))
seconds="${seconds#0}"
totalsec=$(( "$seconds" + "$secmin" ))
#divsec=$(python3 -c "print($totalsec/$threads)")
divsec=$(echo "($totalsec/$threads)" | bc -l)
(( verbose )) && printf 'hours: %s\nminutes: %s\nseconds: %s\ntotalsec: %s\ndivsec: %s\n' "$hours" "$minutes" "$seconds" "$totalsec" "$divsec" && pause
(( verbose )) && printf 'Leaving function: %s\n' "${FUNCNAME[0]}"
}
##--> calctime2() <--###################################################################
rmyn(){
while true
read -rp "$1"$'\n ' rmyn
do
case "$rmyn" in
[yY] ) "${@:3}"; break;;
[nN] ) printf '%s\n' "$2"; break;;
* ) printf "Invalid response...\n";;
esac
done
}
##--> rmyn() <--############################################################################
#confirm(){
# local ans IFS=
# while
# printf '%s' "$1"
# read -rp " " -n1 ans
# do
# printf '\n'
# case "$ans" in [Yy]) return 0;; [Nn]) return 1;;
# esac
# done
#}
##--> confirm() <--###################################################################################
#checkdur(){
# local m4a m4b opus mp3 wav
# m4a=(*m4a)
# m4b=(*m4b)
# opus=(*opus)
# mp3=(*mp3)
# wav=(*wav)
#
#if [[ "$1" ]]
# then
# find -type f -iname "*.$1" -print0 | xargs -0 mplayer -vo dummy -ao dummy -identify 2>/dev/null | perl -nle '/ID_LENGTH=([0-9\.]+)/ && ($t +=$1) && printf "%02d:%02d:%02d\n",$t/3600,$t/60%60,$t%60' | tail -n 1
# else
# printf '\n%sDuration(s):%s\n' "$bold" "$tput0"
# [[ "${#m4a[@]}" -gt 0 ]] &&
# printf '%s %s%s%s %s%s\n' "$bold" "$red" "$( find -type f -iname "*.m4a" -print0 | xargs -0 mplayer -vo dummy -ao dummy -identify 2>/dev/null | perl -nle '/ID_LENGTH=([0-9\.]+)/ && ($t +=$1) && printf "%02d:%02d:%02d\n",$t/3600,$t/60%60,$t%60' | tail -n 1)" "$white" "${m4a[@]}" "$tput0"
# [[ "${#m4b[@]}" -gt 0 ]] &&
# printf '%s %s%s%s %s%s\n' "$bold" "$red" "$( find -type f -iname "*.m4b" -print0 | xargs -0 mplayer -vo dummy -ao dummy -identify 2>/dev/null | perl -nle '/ID_LENGTH=([0-9\.]+)/ && ($t +=$1) && printf "%02d:%02d:%02d\n",$t/3600,$t/60%60,$t%60' | tail -n 1)" "$white" "${m4b[@]}" "$tput0"
# [[ "${#mp3[@]}" -gt 0 ]] &&
# printf '%s %s%s%s %s%s\n' "$bold" "$red" "$( find -type f -iname "*.mp3" -print0 | xargs -0 mplayer -vo dummy -ao dummy -identify 2>/dev/null | perl -nle '/ID_LENGTH=([0-9\.]+)/ && ($t +=$1) && printf "%02d:%02d:%02d\n",$t/3600,$t/60%60,$t%60' | tail -n 1)" "$white" "${mp3[@]}" "$tput0"
# [[ "${#opus[@]}" -gt 0 ]] &&
# printf '%s %s%s%s %s%s\n' "$bold" "$red" "$( find -type f -iname "*.opus" -print0 | xargs -0 mplayer -vo dummy -ao dummy -identify 2>/dev/null | perl -nle '/ID_LENGTH=([0-9\.]+)/ && ($t +=$1) && printf "%02d:%02d:%02d\n",$t/3600,$t/60%60,$t%60' | tail -n 1)" "$white" "${opus[@]}" "$tput0"
# [[ "${#wav[@]}" -gt 0 ]] &&
# printf '%s %s%s%s %s%s\n' "$bold" "$red" "$( find -type f -iname "*.opus" -print0 | xargs -0 mplayer -vo dummy -ao dummy -identify 2>/dev/null | perl -nle '/ID_LENGTH=([0-9\.]+)/ && ($t +=$1) && printf "%02d:%02d:%02d\n",$t/3600,$t/60%60,$t%60' | tail -n 1)" "$white" "${opus[@]}" "$tput0"
# fi
#}
##--> checkdur() <--##################################################################################
#####################################################
# Main #
#####################################################
(( screened == 2 )) && pause "running in screen"
while (( $# > 0 )); do
[[ "$1" = @(--edit|edit|e|nano) ]] && editscript && exit
[[ "$1" = @(-v|--verbose) ]] && args+=("$1") && shift && verbose=1 && continue
[[ "$1" = --force@(|-quarter) ]] && args+=("$1") && shift && force=1 && continue
[[ "$1" = @(-s) ]] && shift && screened=1 && continue
[[ "$1" = @(|-)@(-ys|-yes) ]] && shift && rmmatch=1 && screened=1 && continue
[[ "$1" = -y ]] && shift && rmmatch=1 && continue
[[ "$1" = --save ]] && args+=("$1") && shift && save=1 && continue
[[ "$1" = @(-D|--discord) ]] && { args+=("$1"); unset discord; . ~/.config/discord-local.conf; shift; continue; }
[[ "$1" = --calling-tmp && -f "$2" ]] && { calltmpf="$2"; shift 2; continue; } ## requires calling script to touch file first
[[ -f "$1" ]] && { args+=("$1"); shift; clifile="${args[-1]}"; continue; }
{ printf '"%s" is unrecognized.\n' "$1"; shift; confirm -y 'Proceed with script' || exit 1; }
done
if (( screened == 1 )); then
allfiles=( *.mp3 )
[[ ! "$allfiles" ]] && allfiles=( *.m4[ab] )
. indexopus.lib
printline "$bold Calling quartero4 in GNU screen $tput0"
printf \\n\\n
# allm4s=(*.m4[ab])
screenname="q.o.4-${allfiles[0]}"
args+=("-y")
# screen -dmS "${screenname:0:16}" screened=2 quartero4 "${args[@]}"
screen -dmS "${screenname:0:16}" quartero4 "${args[@]}"
screen -ls
printf \\n\\n
exit
fi
(( verbose )) && [[ "$calltmpf" ]] && printf '[verbose] $calltmpf=%s\n' "$calltmpf"
(( verbose )) && pause "[verbose] rmmatch=$rmmatch"
SWD="$(pwd)"
if [[ "$clifile" ]]; then
if [[ "$clifile" = *@(.mp3|.m4@(a|b)|wav|.mp4) ]]; then
path="$clifile"
fi
(( verbose )) && pause "[verbose] \$path=$path"
else
ckbook=( *@(mp3|m4@(a|b)|wav) )
if (( ${#ckbook[@]} == 1 )); then
path="${ckbook[0]}"
else # i.e., elif (( ${#ckbook[@]} != 1 )); then
printf '\n%s%sE: No single .mp3 or .m4b/.m4a file found!%s\nListing of %s:\n' "$red" "$bold" "$tput0" "$SWD"
ls
printf '\n\nexit 1\n'
exit 1
fi
fi
## i don't think i need to be doing this at all. there's really no reason to rename the souce file
#if [[ "$path" != *\ --\ Audiobook.@(mp3|m4@(a|b)|wav) ]]
# then
## path="$ckbook"
# printf '\n%s%sFile is not in the format of <title> -- Audiobook.@(mp3|m4a|m4b)!\n%s\n' "$red" "$bold" "$tput0"
# ckbookfile="${ckbook%.*}"; ckbookext="${ckbook##*.}"
## [[ "$ckbookfile" =~ \. ]] && n_ckbookfile="${ckbookfile//./_}"
## if (( rmmatch )) || confirm "Rename $path to ${ckbook%.*} -- Audiobook.${ckbook##*.}? (y/n) "
## n_ckbook="${n_ckbookfile:-$ckbookfile} -- Audiobook.$ckbookext"
# n_ckbook="$ckbookfile -- Audiobook.$ckbookext"
# if (( rmmatch )) || { printf 'Rename\n %s \nto\n %s\n' \
# "$path" \
# "$n_ckbook";
# confirm -y; }
# then
# mv "$ckbook" "$n_ckbook"
# else
# printf "No file name given or filename invalid...\n"
# printf "File must be in the format of \"* -- Audiobook.@(mp3|m4?|wav)\n"
# exit
# fi
#fi
! (( force )) && [[ "$(mediainfo "$path"|grep Menu)" =~ ^Menu ]] && printf '%s has an index!\nexit 1\n' "$path" && exit 1
startfile="$(basename "$path")"
startdir="$(dirname "$path")"
## realpath is probably not what I want here in the event I'm in a symlink dir:
[[ "$startdir" = . ]] && startdir="$(pwd)"
(( verbose )) && pause "startfile=$startfile"
(( verbose )) && pause " startdir=$startdir"
inext="${startfile##*.}"
title="${startfile%.*}"
title="${title%% -- *}"
ititle="${ulon}$title${uloff}"
(( verbose )) && pause " title=$title"
if [[ "$inext" = m4b ]]; then
ext="$inext"
outext="m4a"
(( verbose )) && pause "$outext"
elif [[ "$inext" = @(mp3|opus|m4a|flac|wav) ]]; then
ext="$inext"; outext="$inext"
else
printf "%s is not equal to a compatible file format of .mp3, .opus, .m4a, m4b. Please correct the error and try again. (exit 1)"
exit 1
fi
tmp="$tmp/quartero4-$title"
count=1 #cannot change.
(( verbose )) && printf ' inext=%s\n outext=%s\n ext=%s\n tmp=%s\n count=%s\n save=%s\n' "$inext" "$outext" "$ext" "$tmp" "$count" "$save"
[[ ! -d "$tmp" ]] && mkdir "$tmp"
## this is fucking stupid since there's no wholefile defined at this point
#if [[ ! -w . || ! -w "$wholefile" ]]; then
# sudo chown -R "$USER:media" .
#fi
## why is this even a for loop? there should only be one file accepted by this point...
## and why not use for wholefile in *"$ext"?
#for i in *"$ext"; do
# path="$i"
(( verbose )) && pause " path=$path"
printf '\nFile to split: %s\n' "$path"
(( verbose )) && printf 'Not calling calctime2 %s\n' "$path"
# calctime2 "$path"
totalsec=$(ffprobe -v quiet -show_entries format=duration -of csv=p=0 "$path")
divsec=$(echo "$totalsec/$threads" | bc -l)
(( verbose )) && printf '[verbose] $totalsec: %s\n' "$totalsec"
(( verbose )) && pause "[verbose] \$divsec: $divsec"
printf '\n\n%sSplitting file into %s pieces:\n%s' "$relipsis" "$threads" "$tput0"
while (( count <= threads )); do
(( threads < 100 )) && printf -v part '%02d' "$count"
(( threads > 100 )) && printf -v part '%03d' "$count"
#(( verbose )) && pause "$(python -c "print(($count-1)*$divsec)")"
ffmpeg -n \
-nostdin \
-hide_banner \
-stats \
-v error \
-ss $(echo "(($count-1)*$divsec)" | bc -l) \
-to $(echo "($count*$divsec)" | bc -l) \
-i file:"$path" \
-vn \
-acodec copy \
file:"$tmp/${title%% -- *} -- Part $part.$outext"
(( verbose )) && printf 'count %s -> part %s\n' "$count" "$part"
(( count++ ))
done
#done
cd "$tmp"
#for i in First Second Third Fourth; do
# ((n++))
# for f in *\ --\ Part\ 0"$n".*; do
# mv "$f" "${f/./: $i Quarter.}"
# done
#done
printline " Entering opus.book.4 "
threads="$threads" opus.book.4
printline " Leaving opus.book.4 "
mediaduration
printline " Entering indexopus "
indexopus -y -t "$title" || { echo "indexopus failed, exit 1" ; exit 1; }
#indexopus -y -t "$title"
#ioexit="$?"
#(( ioexit==1 )) && echo "indexopus failed, exit 1" && exit 1
printline " Leaving indexopus "
printf '\n%smoving %s/%s -- Audiobook.opus to %s%s\n\n' "$relipsis" "$tmp" "$ititle" "$SWD" "$tput0"
titleopus="$title -- Audiobook.opus"
mv "$titleopus" "$SWD" || unset rmmatch
lsopus=( *opus )
(( "${#lsopus[@]}" )) &&
{ printf '%sopus files still remain in %s!\nls *opus:\n%s' "$relipsis" "$tmp" "$tput0";
printf '%s\n' "${lsopus[@]}";
printf \\n;
unset rmmatch; }
ckparts=( "$title -- Part "*.opus )
if (( "${#ckparts[@]}" )); then
printf -- '--> %sThe duration of the %s -- Part *opus is %s\n\n%s' "$relipsis" "$ititle" "$duration" "$tput0"
confirm -Y "Remove $ititle -- Part *.opus files?" && rm "$title -- Part "*.opus || printf '...Leaving %s -- Part *.opus files...\n' "$ititle"
fi
cd "$SWD"
# for now i need to just remove the temp files.... at the end of the day, if indexopus sent them back without error, they can just be removed.
#rm -r "$tmp"
if (( rmmatch )); then
rm -r "$tmp"
else
eza "$tmp"
confirm "Remove $tmp?" && rm -r "$tmp" || printf '...Leaving %s\n' "$tmp"
fi
# (( verbose )) && pause "...Continue ?"
#printf '%s\n%s\n' "$(ls *\ Audiobook.m4?)" "$(mediainfo *\ Audiobook.m4?|grep ^Duration\ |uniq)"
opusdursec=$(( $(mediainfo --Inform="General;%Duration%" "$titleopus")/1000 ))
! (( opusdursec )) && { printf 'The duration for %s is zero and will result in a divide-by-zero error. Investigate. (exit 1)\n' "$titleopus"; exit 1; }
## not sure what all of this is doing, but shouls be using $n_ckbook (for new $ckbook) and renaming
## back to $ckbook if --save
#[[ ! "$allfiles" ]] && allfiles=( *.mp3 )
#
#[[ ! "$allfiles" ]] && allfiles=( *.m4[ab] )
#
#for i in "${allfiles[@]}"; do allfilesdur=$(( allfilesdur + $(mediainfo --Inform="General;%Duration%" "$i") )); done
startdur=$(( $(mediainfo --Inform="General;%Duration%" "$path")/1000 ))
verifydur=$(( (1000 * (startdur - opusdursec)) / opusdursec ))
verifydur=$(( verifydur < 0 ? -verifydur:verifydur ))
#verifydur=$(bc <<< "scale=4; ($allfilesdur - $opusdursec) / $opusdursec " )
#verifydur=$(( verifydur < 0 ? -verifydur:verifydur ))
#verifydur="${verifydur/#-}"
#if (( rmmatch )); then # && (( opusdursec > 0 )); then
# if [[ $(bc <<< "scale=4; $verifydur < 0.001") ]]; then
# ! (( save )) && rm -r "${allfiles[@]}"
# [[ "$m4bindursec" != "$opusdursec" ]] &&
# printf '\n%sDurations don'\''t %sexactly%s match but fuckin'\'' close '\''nuff!%s\n' \
# "$relipsis" \
# "$(tput sitm)" \
# "$(tput ritm)" \
# "$tput0" ||
# printf '%sDurations match!%s\n' "$relipsis" "$tput0"
# printf '\n%sDone.\n\nPlease see %s/%s%s\n\n' "$relipsis" "$PWD" "$ioutput" "$tput0"
## elif (( allfilesdur != opusdursec )) #[[ "$(checkdur m4b)" != "$(checkdur opus)" ]]; then
# else
# printf '%s%sThe m4b and opus audiobook durations do not match!\n' "$bold" "$red"
# printf '%s%sm4b2opus will not automatically delete starting and temporary files!\n' "$white" "$tput0"
# printf '\n\n'
# printf '%s-y/-f specified, but the durations do not match!\n%s' "$bold" "$tput0"
# fi
#else
##(( verbose )) && pause "rm -i *.@(mp3|m4@(a|b)):"
## rm -i *.@(mp3|m4@(a|b))
#(( verbose )) && pause "rm -i $path"
# rm -i "$path"
#fi
if (( verifydur <= 1 )) && ! (( save )) && { (( rmmatch )) || confirm -y "Durations are within 0.1%.\n $(ls "$path") \n\nRemove starting audio file?"; }; then #this is a 0.1% difference
# rm -r "${allfiles[@]}"
! (( save )) && rm "$path"
[[ "$m4bindursec" != "$opusdursec" ]] &&
printf '\n%sDurations don'\''t %sexactly%s match but fuckin'\'' close '\''nuff!%s\n' \
"$relipsis" \
"$(tput sitm)" \
"$(tput ritm)" \
"$tput0" ||
printf '%sDurations match!%s\n' "$relipsis" "$tput0"
printf '\n%sDone.\n\nPlease see %s/%s%s\n\n' "$relipsis" "$PWD" "$ioutput" "$tput0"
elif (( save )); then
printf '%s was launched with --save flag.\nThe starting file, %s, will not be deleted.\n' "$0" "$path"
elif (( rmmatch )) && (( verifydur > 1 )); then
printf '%s%sThe m4b and opus audiobook durations do not match!\n' "$bold" "$red"
printf '%s%sm4b2opus will not automatically delete starting and temporary files!\n' "$white" "$tput0"
printf '\n\n'
printf '%s-y/-f specified, but the durations do not match!\n%s' "$bold" "$tput0"
elif ! (( rmmatch )); then
whole=$(( verifydur / 10 ))
frac=$(( verifydur % 10 ))
printf 'Durations:\n%s - %s\n%s - %s\nPercent difference: %d.%d%%\n' "$path" "$startdur" "$titleopus" "$opusdursec" "$whole" "$frac"
confirm "Would you still like to delete the starting file?" && rm -i "$path"
fi
#else
##(( verbose )) && pause "rm -i *.@(mp3|m4@(a|b)):"
## rm -i *.@(mp3|m4@(a|b))
#(( verbose )) && pause "rm -i $path"
# rm -i "$path"
#fi
#(( discord )) && apprise "$apprisediscord" -t "$0 completed:" -b "${titleopus:-title unavailable}"
(( discord )) && discorddm "mp32opus completed: ${title:-title unavailable}"
## communicate sourcable "$title" "$titleopus" variables back to script calling with --calling-temp "$calltmpf" file
if [[ "$calltmpf" ]]; then
printf 'title="%s"\n' "$title" >> "$calltmpf"
printf 'titleopus="%s"\n' "$titleopus" >> "$calltmpf"
fi
: "${ec:=0}"
printline "${bold} Exiting $0 (exit $ec) $tput0"
exit "$ec"
#https://www.reddit.com/r/ffmpeg/comments/107p3mh/remove_all_apart_from_audio/
#Mon Dec 11 10:52:50 AM EST 2023