mirror of
https://github.com/KrumpetPirate/AAXtoMP3.git
synced 2024-11-18 03:08:57 +01:00
Some little improvements
This commit is contained in:
parent
4698f7728a
commit
7f2309248f
@ -9,16 +9,13 @@
|
|||||||
|
|
||||||
# ===Variables====================================================================================================================================
|
# ===Variables====================================================================================================================================
|
||||||
|
|
||||||
# Usage synopsis
|
|
||||||
usage=$'\nUsage: interactiveAAXtoMP3 [--advanced] [--help]\n'
|
|
||||||
# Help mesaage
|
# Help mesaage
|
||||||
help=$'\nUsage: interactiveAAXtoMP3 [--advanced] [--help]\n
|
help=$'\nUsage: interactiveAAXtoMP3 [--advanced] [--help]\n
|
||||||
--advanced More options
|
--advanced More options
|
||||||
--help Print this message\n'
|
--help Print this message\n'
|
||||||
summery="" # This will contain a summery of the options allready set.
|
summary="" # This will contain a summary of the options allready set.
|
||||||
call="./AAXtoMP3" # This will contain the call for AAXtoMP3.
|
call="./AAXtoMP3" # This will contain the call for AAXtoMP3.
|
||||||
isnum='^[0-9]+$' # This is needed to check whether a variable is a number.
|
advanced=0 # Toggles advanced options on or off.
|
||||||
advanced=0 # Toggles Advanced options on or off.
|
|
||||||
|
|
||||||
# ===Options======================================================================================================================================
|
# ===Options======================================================================================================================================
|
||||||
|
|
||||||
@ -29,36 +26,58 @@ while true; do
|
|||||||
# Command synopsis.
|
# Command synopsis.
|
||||||
-h | --help ) echo -e "$help"; exit ;;
|
-h | --help ) echo -e "$help"; exit ;;
|
||||||
# Anything else stops command line processing.
|
# Anything else stops command line processing.
|
||||||
* ) echo -e "$usage"; exit ;;
|
* ) break ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# ===Cross platform compatible use grep and sed===================================================================================================
|
||||||
|
|
||||||
|
# ===Detect which annoying version of grep we have===
|
||||||
|
GREP=$(grep --version | grep -q GNU && echo "grep" || echo "ggrep")
|
||||||
|
if ! [[ $(type -P "$GREP") ]]; then
|
||||||
|
echo "$GREP (GNU grep) is not in your PATH"
|
||||||
|
echo "Without it, this script will break."
|
||||||
|
echo "On macOS, you may want to try: brew install grep"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ===Detect which annoying version of sed we have===
|
||||||
|
SED=$(sed --version 2>&1 | $GREP -q GNU && echo "sed" || echo "gsed")
|
||||||
|
if ! [[ $(type -P "$SED") ]]; then
|
||||||
|
echo "$SED (GNU sed) is not in your PATH"
|
||||||
|
echo "Without it, this script will break."
|
||||||
|
echo "On macOS, you may want to try: brew install gnu-sed"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# ===Get options for AAXtoMP3=====================================================================================================================
|
# ===Get options for AAXtoMP3=====================================================================================================================
|
||||||
|
|
||||||
# ===Codec===
|
# ===Codec===
|
||||||
while true; do
|
while true; do
|
||||||
clear;
|
clear;
|
||||||
read -p "codec (mp3/m4a/m4b/flac/aac/opus): " codec
|
read -p "codec (mp3/m4a/m4b/flac/aac/opus): " codec
|
||||||
if [[ "$codec" = "mp3" ]]; then summery="$summery""codec: $codec"; call="$call -e:mp3"; break
|
case "$codec" in
|
||||||
elif [[ "$codec" = "m4a" ]]; then summery="$summery""codec: $codec"; call="$call -e:m4a"; break
|
mp3 ) summary="$summary""codec: $codec"; call="$call -e:mp3"; break;;
|
||||||
elif [[ "$codec" = "m4b" ]]; then summery="$summery""codec: $codec"; call="$call -e:m4b"; break
|
m4a ) summary="$summary""codec: $codec"; call="$call -e:m4a"; break;;
|
||||||
elif [[ "$codec" = "flac" ]]; then summery="$summery""codec: $codec"; call="$call --flac"; break
|
m4b ) summary="$summary""codec: $codec"; call="$call -e:m4b"; break;;
|
||||||
elif [[ "$codec" = "aac" ]]; then summery="$summery""codec: $codec"; call="$call --aac"; break
|
flac ) summary="$summary""codec: $codec"; call="$call --flac"; break;;
|
||||||
elif [[ "$codec" = "opus" ]]; then summery="$summery""codec: $codec"; call="$call --opus"; break
|
aac ) summary="$summary""codec: $codec"; call="$call --aac"; break;;
|
||||||
fi
|
opus ) summary="$summary""codec: $codec"; call="$call --opus"; break;;
|
||||||
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
# ===Compression===
|
# ===Compression===
|
||||||
while true; do
|
while true; do
|
||||||
clear; echo -e "$summery"
|
clear; echo -e "$summary"
|
||||||
if [[ "$codec" = "mp3" ]]; then maxlevel=9
|
case "$codec" in
|
||||||
elif [[ "$codec" = "flac" ]]; then maxlevel=12
|
mp3 ) maxlevel=9;;
|
||||||
elif [[ "$codec" = "opus" ]]; then maxlevel=10
|
flac ) maxlevel=12;;
|
||||||
else break
|
opus ) maxlevel=10;;
|
||||||
fi
|
* ) break;;
|
||||||
|
esac
|
||||||
read -p "compression level (0-$maxlevel): " compression
|
read -p "compression level (0-$maxlevel): " compression
|
||||||
if [[ ${compression} =~ $isnum ]] && [[ "$((${compression} > -1))" == "1" ]] && [[ "$((${compression} < ${maxlevel}+1))" == "1" ]]; then
|
if [[ $compression =~ ^[0-9]+$ ]] && [[ "$compression" -ge "0" ]] && [[ "$compression" -le "$maxlevel" ]]; then
|
||||||
summery="$summery""\ncompression level: $compression"
|
summary="$summary""\ncompression level: $compression"
|
||||||
call="$call --level $compression"
|
call="$call --level $compression"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
@ -66,45 +85,45 @@ done
|
|||||||
|
|
||||||
# ===Chapters===
|
# ===Chapters===
|
||||||
while true; do
|
while true; do
|
||||||
clear; echo -e "$summery"
|
clear; echo -e "$summary"
|
||||||
read -p "chapters (yes/no/chapternumber to continue with): " chapters
|
read -p "chapters (yes/no/chapternumber to continue with): " chapters
|
||||||
if [[ ${chapters} =~ $isnum ]]; then summery="$summery""\nchapters: $chapters"; call="$call -c --continue ${chapters}"; break
|
case "$chapters" in
|
||||||
elif [[ "$chapters" = "yes" ]] ; then summery="$summery""\nchapters: $chapters"; call="$call -c"; break
|
^[0-9]+$ ) summary="$summary""\nchapters: $chapters"; call="$call -c --continue ${chapters}"; break;;
|
||||||
elif [[ "$chapters" = "no" ]] ; then summery="$summery""\nchapters: $chapters"; call="$call -s"; break
|
yes ) summary="$summary""\nchapters: $chapters"; call="$call -c"; break;;
|
||||||
fi
|
no ) summary="$summary""\nchapters: $chapters"; call="$call -s"; break;;
|
||||||
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
# ===Authcode===
|
# ===Authcode===
|
||||||
if ! [ -r .authcode ] || [ -r ~/.authcode ]; then
|
if ! [ -r .authcode ] || [ -r ~/.authcode ]; then
|
||||||
clear; echo -e "$summery"
|
clear; echo -e "$summary"
|
||||||
read -p "Authcode: " authcode
|
read -p "Authcode: " authcode
|
||||||
summery="$summery""\nauthcode: $authcode"
|
summary="$summary""\nauthcode: $authcode"
|
||||||
call="$call -A $authcode"
|
call="$call -A $authcode"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ===Loglevel===
|
# ===Loglevel===
|
||||||
while true; do
|
while true; do
|
||||||
clear; echo -e "$summery"
|
clear; echo -e "$summary"
|
||||||
read -p "loglevel (0/1/2/3): " loglevel
|
read -p "loglevel (0/1/2/3): " loglevel
|
||||||
if [[ ${loglevel} =~ $isnum ]] && [[ "$((${loglevel} > -1))" == "1" ]] && [[ "$((${loglevel} < 4))" == "1" ]]; then
|
if [[ $loglevel =~ ^[0-9]+$ ]] && [[ "$loglevel" -ge "0" ]] && [[ "$loglevel" -le "3" ]]; then
|
||||||
summery="$summery""\nloglevel: $loglevel"
|
summary="$summary""\nloglevel: $loglevel"
|
||||||
call="$call -l $loglevel"
|
call="$call -l $loglevel"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# ===File===
|
# ===File===
|
||||||
clear; echo -e "$summery"
|
clear; echo -e "$summary"
|
||||||
read -p "aax-file: " file
|
read -p "aax-file: " file
|
||||||
summery="$summery""\naax-file: $file"
|
summary="$summary""\naax-file: $file"
|
||||||
call="$call $(echo $file | sed "s;~;$HOME;")"
|
call="$call $(echo $file | $SED "s;~;$HOME;")"
|
||||||
|
|
||||||
# ===Summerize chosen options and call AAXtoMP3===================================================================================================
|
# ===Summerize chosen options and call AAXtoMP3===================================================================================================
|
||||||
|
|
||||||
# ===Summery===
|
# ===Summary===
|
||||||
clear; echo -e "$summery\n"
|
clear; echo -e "$summary\n"
|
||||||
echo -e "$call\n"
|
echo -e "$call\n"
|
||||||
# -----
|
|
||||||
|
|
||||||
# ===Call AAXtoMP3===
|
# ===Call AAXtoMP3===
|
||||||
$call
|
$call
|
||||||
|
Loading…
Reference in New Issue
Block a user