small bugfix and code cleanup

This commit is contained in:
esche 2023-07-08 00:06:12 +02:00
parent 2b5a385e51
commit c3cb18999e

View file

@ -18,6 +18,7 @@ print_help() {
printf "Help: not implemented yet" printf "Help: not implemented yet"
} }
delete="false"
while getopts 'e:dh' flag; do while getopts 'e:dh' flag; do
case "${flag}" in case "${flag}" in
e) extension+=("$OPTARG");; e) extension+=("$OPTARG");;
@ -28,10 +29,10 @@ while getopts 'e:dh' flag; do
esac esac
done done
echo "$delete"
# write array into string # write array into string
extension="${extension[*]}" extension="${extension[*]}"
# remove leading space
extension="${extension##+([[:space:]])}"
# change separator # change separator
extension=${extension// /|} extension=${extension// /|}
@ -60,10 +61,10 @@ for file in **/*.@($extension); do
is_video=$(ffprobe -v error -select_streams V -show_entries stream=codec_type "$file") is_video=$(ffprobe -v error -select_streams V -show_entries stream=codec_type "$file")
if [[ ${#channels[@]} -gt 1 || -n "$is_video" ]]; then if [[ ${#channels[@]} -gt 1 || -n "$is_video" ]]; then
ffmpeg -i "$file" -map 0 -map -0:d -map -0:t -c copy -c:a libopus $bitrate_settings-v info -hide_banner "${file%.*}.mkv" && ffmpeg -i "$file" -map 0 -map -0:d -map -0:t -c copy -c:a libopus $bitrate_settings-v info -hide_banner "${file%.*}.mkv" &&
if [[ delete="true" ]]; then rm "$file"; fi if [[ "$delete"=true ]]; then rm "$file"; fi
else else
ffmpeg -i "$file" $bitrate_settings-v info -hide_banner "${file%.*}.opus" && ffmpeg -i "$file" $bitrate_settings-v info -hide_banner "${file%.*}.opus" &&
if [[ delete="true" ]]; then rm "$file"; fi if [[ "$delete"=true ]]; then rm "$file"; fi
fi fi
done done