Merge pull request #5 from KrumpetPirate/master

Merge Krumpet Changes.
This commit is contained in:
upuv 2018-07-25 13:58:23 +10:00 committed by GitHub
commit 09e82c0ed6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,7 +5,7 @@
# Command Line Options # Command Line Options
# Usage Synopsis. # Usage Synopsis.
usage=$'\nUsage: AAXtoMP3 [--flac] [--aac] [--opus ] [--single] [--chaptered]\n[-e:mp3] [-e:m4a] [-e:m4b] [--authcode <AUTHCODE>]\n[--output_dir <PATH>] [--complete_dir <PATH>] [--validate]\n{FILES}\n' usage=$'\nUsage: AAXtoMP3 [--flac] [--aac] [--opus ] [--single] [--chaptered]\n[-e:mp3] [-e:m4a] [-e:m4b] [--authcode <AUTHCODE>]\n[--target_dir <PATH>] [--complete_dir <PATH>] [--validate]\n{FILES}\n'
codec=libmp3lame # Default encoder. codec=libmp3lame # Default encoder.
extension=mp3 # Default encoder extention. extension=mp3 # Default encoder extention.
mode=chaptered # Multi file output mode=chaptered # Multi file output
@ -146,6 +146,16 @@ if ! [[ $(type -P "$GREP") ]]; then
exit 1 exit 1
fi 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
# ----- # -----
# Detect ffmpeg and ffprobe # Detect ffmpeg and ffprobe
if [[ "x$(type -P ffmpeg)" == "x" ]]; then if [[ "x$(type -P ffmpeg)" == "x" ]]; then
@ -296,7 +306,7 @@ get_metadata_value() {
local key local key
key="$1" key="$1"
# Find the key in the meta data file # Extract field value # Remove the following /'s "(Unabridged) <blanks> at start end and multiples. # Find the key in the meta data file # Extract field value # Remove the following /'s "(Unabridged) <blanks> at start end and multiples.
echo "$($GREP --max-count=1 --only-matching "${key} *: .*" "$metadata_file" | cut -d : -f 2- | sed -e 's#/##g;s/ (Unabridged)//;s/^[[:blank:]]\+//g;s/[[:blank:]]\+$//g' | sed 's/[[:blank:]]\+/ /g')" echo "$($GREP --max-count=1 --only-matching "${key} *: .*" "$metadata_file" | cut -d : -f 2- | $SED -e 's#/##g;s/ (Unabridged)//;s/^[[:blank:]]\+//g;s/[[:blank:]]\+$//g' | $SED 's/[[:blank:]]\+/ /g')"
} }
# ----- # -----
@ -325,7 +335,7 @@ do
save_metadata "${aax_file}" save_metadata "${aax_file}"
genre=$(get_metadata_value genre) genre=$(get_metadata_value genre)
artist=$(get_metadata_value artist) artist=$(get_metadata_value artist)
title=$(get_metadata_value title | sed 's/'\:'/'-'/g' | sed 's/- /-/g' | xargs -0) title=$(get_metadata_value title | $SED 's/'\:'/'-'/g' | $SED 's/- /-/g' | xargs -0)
if [ "x${targetdir}" != "x" ] ; then if [ "x${targetdir}" != "x" ] ; then
output_directory="${targetdir}/${genre}/${artist}/${title}" output_directory="${targetdir}/${genre}/${artist}/${title}"
else else