mirror of
https://github.com/KrumpetPirate/AAXtoMP3.git
synced 2024-11-18 03:08:57 +01:00
Save chosen options for next time
Now this script creates a save-file from which it loads the option the next time the script is used Additionally aax-File drag'n'drop works now, at least on Ubuntu.
This commit is contained in:
parent
4537c7d01d
commit
88c9b1701f
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
# ===Variables====================================================================================================================================
|
# ===Variables====================================================================================================================================
|
||||||
|
|
||||||
# Help mesaage
|
# Help message
|
||||||
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'
|
||||||
@ -22,11 +22,11 @@ advanced=0 # Toggles advanced options on or off.
|
|||||||
while true; do
|
while true; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
# Advanced options.
|
# Advanced options.
|
||||||
-a | --advanced ) advanced=1; shift ;;
|
-a | --advanced ) advanced=1; shift ;;
|
||||||
# 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.
|
||||||
* ) break ;;
|
* ) break ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -50,12 +50,36 @@ if ! [[ $(type -P "$SED") ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# ===Get options from last time===================================================================================================================
|
||||||
|
|
||||||
|
# ===Set default values===
|
||||||
|
lastcodec="mp3"
|
||||||
|
lastcompression="4"
|
||||||
|
lastchapters="yes"
|
||||||
|
lastauthcode=""
|
||||||
|
lastloglevel="1"
|
||||||
|
|
||||||
|
# ===Get Values from last time===
|
||||||
|
if [ -f "interactive.txt" ]; then
|
||||||
|
for ((i=1;i<=$(wc -l interactive.txt | cut -d " " -f 1);i++)) do
|
||||||
|
line=$(head -$i interactive.txt | tail -1)
|
||||||
|
case $(echo $line | cut -d " " -f 1 | $SED 's/.$//') in
|
||||||
|
codec ) lastcodec="$(echo $line | cut -d " " -f 2)";;
|
||||||
|
compression ) lastcompression="$(echo $line | cut -d " " -f 2)";;
|
||||||
|
chapters ) lastchapters="$(echo $line | cut -d " " -f 2)";;
|
||||||
|
authcode ) lastauthcode="$(echo $line | cut -d " " -f 2)";;
|
||||||
|
loglevel ) lastloglevel="$(echo $line | cut -d " " -f 2)";;
|
||||||
|
* ) rm interactive.txt; exit 1;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
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 -e -p "codec (mp3/m4a/m4b/flac/aac/opus): " -i "$lastcodec" codec
|
||||||
case "$codec" in
|
case "$codec" in
|
||||||
mp3 ) summary="$summary""codec: $codec"; call="$call -e:mp3"; break;;
|
mp3 ) summary="$summary""codec: $codec"; call="$call -e:mp3"; break;;
|
||||||
m4a ) summary="$summary""codec: $codec"; call="$call -e:m4a"; break;;
|
m4a ) summary="$summary""codec: $codec"; call="$call -e:m4a"; break;;
|
||||||
@ -75,7 +99,7 @@ while true; do
|
|||||||
opus ) maxlevel=10;;
|
opus ) maxlevel=10;;
|
||||||
* ) break;;
|
* ) break;;
|
||||||
esac
|
esac
|
||||||
read -p "compression level (0-$maxlevel): " compression
|
read -e -p "compression level (0-$maxlevel): " -i "$lastcompression" compression
|
||||||
if [[ $compression =~ ^[0-9]+$ ]] && [[ "$compression" -ge "0" ]] && [[ "$compression" -le "$maxlevel" ]]; then
|
if [[ $compression =~ ^[0-9]+$ ]] && [[ "$compression" -ge "0" ]] && [[ "$compression" -le "$maxlevel" ]]; then
|
||||||
summary="$summary""\ncompression level: $compression"
|
summary="$summary""\ncompression level: $compression"
|
||||||
call="$call --level $compression"
|
call="$call --level $compression"
|
||||||
@ -86,7 +110,7 @@ done
|
|||||||
# ===Chapters===
|
# ===Chapters===
|
||||||
while true; do
|
while true; do
|
||||||
clear; echo -e "$summary"
|
clear; echo -e "$summary"
|
||||||
read -p "chapters (yes/no/chapternumber to continue with): " chapters
|
read -e -p "chapters (yes/no/chapternumber to continue with): " -i "$lastchapters" chapters
|
||||||
case "$chapters" in
|
case "$chapters" in
|
||||||
^[0-9]+$ ) summary="$summary""\nchapters: $chapters"; call="$call -c --continue ${chapters}"; break;;
|
^[0-9]+$ ) summary="$summary""\nchapters: $chapters"; call="$call -c --continue ${chapters}"; break;;
|
||||||
yes ) summary="$summary""\nchapters: $chapters"; call="$call -c"; break;;
|
yes ) summary="$summary""\nchapters: $chapters"; call="$call -c"; break;;
|
||||||
@ -97,7 +121,7 @@ done
|
|||||||
# ===Authcode===
|
# ===Authcode===
|
||||||
if ! [ -r .authcode ] || [ -r ~/.authcode ]; then
|
if ! [ -r .authcode ] || [ -r ~/.authcode ]; then
|
||||||
clear; echo -e "$summary"
|
clear; echo -e "$summary"
|
||||||
read -p "Authcode: " authcode
|
read -e -p "Authcode: " -i "$lastauthcode" authcode
|
||||||
summary="$summary""\nauthcode: $authcode"
|
summary="$summary""\nauthcode: $authcode"
|
||||||
call="$call -A $authcode"
|
call="$call -A $authcode"
|
||||||
fi
|
fi
|
||||||
@ -105,7 +129,7 @@ fi
|
|||||||
# ===Loglevel===
|
# ===Loglevel===
|
||||||
while true; do
|
while true; do
|
||||||
clear; echo -e "$summary"
|
clear; echo -e "$summary"
|
||||||
read -p "loglevel (0/1/2/3): " loglevel
|
read -e -p "loglevel (0/1/2/3): " -i "$lastloglevel" loglevel
|
||||||
if [[ $loglevel =~ ^[0-9]+$ ]] && [[ "$loglevel" -ge "0" ]] && [[ "$loglevel" -le "3" ]]; then
|
if [[ $loglevel =~ ^[0-9]+$ ]] && [[ "$loglevel" -ge "0" ]] && [[ "$loglevel" -le "3" ]]; then
|
||||||
summary="$summary""\nloglevel: $loglevel"
|
summary="$summary""\nloglevel: $loglevel"
|
||||||
call="$call -l $loglevel"
|
call="$call -l $loglevel"
|
||||||
@ -116,6 +140,9 @@ done
|
|||||||
# ===File===
|
# ===File===
|
||||||
clear; echo -e "$summary"
|
clear; echo -e "$summary"
|
||||||
read -p "aax-file: " file
|
read -p "aax-file: " file
|
||||||
|
file="${file%\'}" #remove suffix ' if file is given via drag'n'drop
|
||||||
|
file="${file#\'}" #remove prefix ' if file is given via drag'n'drop
|
||||||
|
savefile="$summary"
|
||||||
summary="$summary""\naax-file: $file"
|
summary="$summary""\naax-file: $file"
|
||||||
call="$call $(echo $file | $SED "s;~;$HOME;")"
|
call="$call $(echo $file | $SED "s;~;$HOME;")"
|
||||||
|
|
||||||
@ -125,5 +152,8 @@ call="$call $(echo $file | $SED "s;~;$HOME;")"
|
|||||||
clear; echo -e "$summary\n"
|
clear; echo -e "$summary\n"
|
||||||
echo -e "$call\n"
|
echo -e "$call\n"
|
||||||
|
|
||||||
|
# ===Save chosen options===
|
||||||
|
echo -e $savefile | $SED "s;\ level:;:;" > interactive.txt
|
||||||
|
|
||||||
# ===Call AAXtoMP3===
|
# ===Call AAXtoMP3===
|
||||||
$call
|
$call
|
||||||
|
Loading…
Reference in New Issue
Block a user