diff --git a/AAXtoMP3 b/AAXtoMP3 index 61de1ce..a3c388a 100755 --- a/AAXtoMP3 +++ b/AAXtoMP3 @@ -683,7 +683,7 @@ do #ffmpeg version 4+ and on the output for all older versions. split_input="" split_output="" - if [ "$(($(ffmpeg -version | sed -E 's/[^0-9]*([0-9]).*/\1/g;1q') > 3))" = "1" ]; then + if [ "$(($(ffmpeg -version | $SED -E 's/[^0-9]*([0-9]).*/\1/g;1q') > 3))" = "1" ]; then split_input="-ss ${chapter_start%?} -to ${chapter_end}" else split_output="-ss ${chapter_start%?} -to ${chapter_end}" diff --git a/README.md b/README.md index 3c319a4..00a45b0 100644 --- a/README.md +++ b/README.md @@ -32,10 +32,14 @@ Thanks to kbabioch, this script has also been packaged in the [AUR](https://aur. ``` bash AAXtoMP3 [-f|--flac] [-o|--opus] [-a|-aac] [-s|--single] [--level ] [-c|--chaptered] [-e:mp3] [-e:m4a] [-e:m4b] [-A|--authcode ] [-n|--no-clobber] [-t|--target_dir ] [-C|--complete_dir ] [-V|--validate] [-d|--debug] [-h|--help] [--continue ] ... ``` +or if you want to get guided through the options +``` +bash interactiveAAXtoMP3 [-a|--advanced] [-h|--help] +``` * **<AAX INPUT_FILES>**... are considered input file(s), useful for batching! -## Options +## Options for AAXtoMP3 * **-f** or **--flac** Flac Encoding and as default produces a single file. * **-o** or **--opus** Ogg/Opus Encoding defaults to multiple file output by chapter. The extension is .ogg * **-a** or **--aac** AAC Encoding and produce a m4a single files output. @@ -58,6 +62,11 @@ bash AAXtoMP3 [-f|--flac] [-o|--opus] [-a|-aac] [-s|--single] [--level &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 from last time=================================================================================================================== + +# ===Set default values=== +lastcodec="mp3" +lastcompression="4" +lastchapters="yes" +lastauthcode="" +lastloglevel="1" + +# ===Get Values from last time=== +if [ -f ".interactivesave" ]; then + for ((i=1;i<=$(wc -l .interactivesave | cut -d " " -f 1);i++)) do + line=$(head -$i .interactivesave | 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 .interactivesave; exit 1;; + esac + done +fi + +# ===Get options for AAXtoMP3===================================================================================================================== + +# ===Codec=== +while true; do + clear; + read -e -p "codec (mp3/m4a/m4b/flac/aac/opus): " -i "$lastcodec" codec + case "$codec" in + mp3 ) summary="$summary""codec: $codec"; call="$call -e:mp3"; break;; + m4a ) summary="$summary""codec: $codec"; call="$call -e:m4a"; break;; + m4b ) summary="$summary""codec: $codec"; call="$call -e:m4b"; break;; + flac ) summary="$summary""codec: $codec"; call="$call --flac"; break;; + aac ) summary="$summary""codec: $codec"; call="$call --aac"; break;; + opus ) summary="$summary""codec: $codec"; call="$call --opus"; break;; + esac +done + +# ===Compression=== +while true; do + clear; echo -e "$summary" + case "$codec" in + mp3 ) maxlevel=9;; + flac ) maxlevel=12;; + opus ) maxlevel=10;; + * ) break;; + esac + read -e -p "compression level (0-$maxlevel): " -i "$lastcompression" compression + if [[ $compression =~ ^[0-9]+$ ]] && [[ "$compression" -ge "0" ]] && [[ "$compression" -le "$maxlevel" ]]; then + summary="$summary""\ncompression level: $compression" + call="$call --level $compression" + break + fi +done + +# ===Chapters=== +while true; do + clear; echo -e "$summary" + read -e -p "chapters (yes/no/chapternumber to continue with): " -i "$lastchapters" chapters + case "$chapters" in + ^[0-9]+$ ) summary="$summary""\nchapters: $chapters"; call="$call -c --continue ${chapters}"; break;; + yes ) summary="$summary""\nchapters: $chapters"; call="$call -c"; break;; + no ) summary="$summary""\nchapters: $chapters"; call="$call -s"; break;; + esac +done + +# ===Authcode=== +if ! [ -r .authcode ] || [ -r ~/.authcode ]; then + clear; echo -e "$summary" + read -e -p "Authcode: " -i "$lastauthcode" authcode + summary="$summary""\nauthcode: $authcode" + call="$call -A $authcode" +fi + +# ===Loglevel=== +while true; do + clear; echo -e "$summary" + read -e -p "loglevel (0/1/2/3): " -i "$lastloglevel" loglevel + if [[ $loglevel =~ ^[0-9]+$ ]] && [[ "$loglevel" -ge "0" ]] && [[ "$loglevel" -le "3" ]]; then + summary="$summary""\nloglevel: $loglevel" + call="$call -l $loglevel" + break + fi +done + +# ===File=== +clear; echo -e "$summary" +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" +call="$call $(echo $file | $SED "s;~;$HOME;")" + +# ===Summerize chosen options and call AAXtoMP3=================================================================================================== + +# ===Summary=== +clear; echo -e "$summary\n" +echo -e "$call\n" + +# ===Save chosen options=== +echo -e $savefile | $SED "s;\ level:;:;" > .interactivesave + +# ===Call AAXtoMP3=== +$call