Youtube added - further checking required

This commit is contained in:
Josako
2024-07-04 08:11:31 +02:00
parent 19e57f5adf
commit 8e1dac0233
17 changed files with 386 additions and 11 deletions

57
scripts/compress.sh Executable file
View File

@@ -0,0 +1,57 @@
#!/bin/bash
while getopts d:i:o: flag
do
case "${flag}" in
d) directory="${OPTARG}";;
i) input_file="${OPTARG}";;
o) output_file="${OPTARG}";;
*) # Catch-all for unexpected arguments
echo "Invalid option: -$OPTARG" >&2
echo "Usage: ./compress.sh -d <audio_folder> -i <input_file> -o <output_file>"
exit 1
;;
esac
done
# Check if the directory is provided
if [ -z "$directory" ]; then
echo "Directory is required."
echo "Usage: ./compress.sh -d <audio_folder> -i <input_file> -o <output_file>"
exit 1
fi
if [ -z "$input_file" ]; then
echo "Input file is required."
echo "Usage: ./compress.sh -d <audio_folder> -i <input_file> -o <output_file>"
exit 1
fi
if [ -z "$output_file" ]; then
echo "Output file is required."
echo "Usage: ./compress.sh -d <audio_folder> -i <input_file> -o <output_file>"
exit 1
fi
cd "$directory" || exit 1
# Compress the file
/usr/bin/ffmpeg -i "$input_file" -ar 16000 -ac 1 -map 0:a "$output_file"
WAIT_TIME=5
# Function to check for file existence
check_file() {
if [ -f "$output_file" ]; then
echo "File $output_file is available."
return 0
else
echo "File $output_file is not available yet. Waiting..."
return 1
fi
}
# Wait for the file to become available
while ! check_file; do
sleep $WAIT_TIME
done