From ad86f187f8d7201cfe211b0a67cbb412a7b785f3 Mon Sep 17 00:00:00 2001 From: fabh2o Date: Mon, 8 Feb 2021 21:29:26 +0100 Subject: [PATCH 1/8] keep n-th artist only --- AAXtoMP3 | 15 ++++++++++++--- README.md | 1 + 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/AAXtoMP3 b/AAXtoMP3 index ec2ce38..390cf7f 100755 --- a/AAXtoMP3 +++ b/AAXtoMP3 @@ -5,7 +5,7 @@ # Command Line Options # Usage Synopsis. -usage=$'\nUsage: AAXtoMP3 [--flac] [--aac] [--opus ] [--single] [--level ]\n[--chaptered] [-e:mp3] [-e:m4a] [-e:m4b] [--authcode ] [--no-clobber]\n[--target_dir ] [--complete_dir ] [--validate]\n[--continue ]{FILES}\n' +usage=$'\nUsage: AAXtoMP3 [--flac] [--aac] [--opus ] [--single] [--level ]\n[--chaptered] [-e:mp3] [-e:m4a] [-e:m4b] [--authcode ] [--no-clobber]\n[--target_dir ] [--complete_dir ] [--validate]\n[--continue ] [--keep-artist ] {FILES}\n' codec=libmp3lame # Default encoder. extension=mp3 # Default encoder extension. level=-1 # Compression level. Can be given for mp3, flac and opus. -1 = default/not specified. @@ -19,6 +19,7 @@ DEBUG=0 # Default off, If set extremely verbose output. noclobber=0 # Default off, clobber only if flag is enabled continue=0 # Default off, If set Transcoding is skipped and chapter splitting starts at chapter continueAt. continueAt=1 # Optional chapter to continue splitting the chapters. +keepArtist=-1 # Default off, if set change artist metadata to use the passed argument as field # ----- # Code tip Do not have any script above this point that calls a function or a binary. If you do @@ -59,6 +60,8 @@ while true; do --continue ) continueAt="$2"; continue=1; shift 2 ;; # Compression level --level ) level="$2"; shift 2 ;; + # Keep artist number n + --keep-artist ) keepArtist="$2"; shift 2 ;; # Command synopsis. -h | --help ) printf "$usage" $0 ; exit ;; # Standard flag signifying the end of command line processing. @@ -410,7 +413,14 @@ do # Make sure everything is a variable. Simplifying Command interpretation save_metadata "${aax_file}" genre=$(get_metadata_value genre) - artist=$(get_metadata_value artist) + if [ "${keepArtist}" != "-1" ]; then + # sed command: 'C. S. Lewis' -> 'C.S. Lewis' + artist=$(get_metadata_value artist | cut -d',' -f"$keepArtist" | $SED -E 's|\. +|\.|g; s|((\w+\.)+)|\1 |g') + album_artist="$(get_metadata_value album_artist | cut -d',' -f"$keepArtist" | $SED -E 's|\. +|\.|g; s|((\w+\.)')" + else + artist=$(get_metadata_value artist) + album_artist="$(get_metadata_value album_artist)" + fi title=$(get_metadata_value title | $SED 's/'\:'/'-'/g' | $SED 's/- /-/g' | xargs -0) title=${title:0:100} if [ "x${targetdir}" != "x" ] ; then @@ -420,7 +430,6 @@ do fi output_file="${output_directory}/${title}.${extension}" bitrate="$(get_bitrate)k" - album_artist="$(get_metadata_value album_artist)" album="$(get_metadata_value album)" album_date="$(get_metadata_value date)" copyright="$(get_metadata_value copyright)" diff --git a/README.md b/README.md index ab3dd87..c3af0a2 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,7 @@ bash AAXtoMP3 [-f|--flac] [-o|--opus] [-a|-aac] [-s|--single] [--level Date: Mon, 8 Feb 2021 21:39:10 +0100 Subject: [PATCH 2/8] rephrased flag description --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c3af0a2..cb421e6 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ bash AAXtoMP3 [-f|--flac] [-o|--opus] [-a|-aac] [-s|--single] [--level Date: Mon, 8 Feb 2021 21:46:57 +0100 Subject: [PATCH 3/8] typo in sed --- AAXtoMP3 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AAXtoMP3 b/AAXtoMP3 index 390cf7f..1bec38b 100755 --- a/AAXtoMP3 +++ b/AAXtoMP3 @@ -416,7 +416,7 @@ do if [ "${keepArtist}" != "-1" ]; then # sed command: 'C. S. Lewis' -> 'C.S. Lewis' artist=$(get_metadata_value artist | cut -d',' -f"$keepArtist" | $SED -E 's|\. +|\.|g; s|((\w+\.)+)|\1 |g') - album_artist="$(get_metadata_value album_artist | cut -d',' -f"$keepArtist" | $SED -E 's|\. +|\.|g; s|((\w+\.)')" + album_artist="$(get_metadata_value album_artist | cut -d',' -f"$keepArtist" | $SED -E 's|\. +|\.|g; s|((\w+\.)+)|\1 |g')" else artist=$(get_metadata_value artist) album_artist="$(get_metadata_value album_artist)" From 1e7802ac3fdb9b16349efe95a86187ef7158c13c Mon Sep 17 00:00:00 2001 From: fabh2o Date: Mon, 8 Feb 2021 22:04:32 +0100 Subject: [PATCH 4/8] force author name --- AAXtoMP3 | 25 +++++++++++++++++-------- README.md | 1 + 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/AAXtoMP3 b/AAXtoMP3 index 1bec38b..bedf2aa 100755 --- a/AAXtoMP3 +++ b/AAXtoMP3 @@ -5,7 +5,7 @@ # Command Line Options # Usage Synopsis. -usage=$'\nUsage: AAXtoMP3 [--flac] [--aac] [--opus ] [--single] [--level ]\n[--chaptered] [-e:mp3] [-e:m4a] [-e:m4b] [--authcode ] [--no-clobber]\n[--target_dir ] [--complete_dir ] [--validate]\n[--continue ] [--keep-artist ] {FILES}\n' +usage=$'\nUsage: AAXtoMP3 [--flac] [--aac] [--opus ] [--single] [--level ]\n[--chaptered] [-e:mp3] [-e:m4a] [-e:m4b] [--authcode ] [--no-clobber]\n[--target_dir ] [--complete_dir ] [--validate]\n[--continue ] [--keep-artist ] [--author ] {FILES}\n' codec=libmp3lame # Default encoder. extension=mp3 # Default encoder extension. level=-1 # Compression level. Can be given for mp3, flac and opus. -1 = default/not specified. @@ -20,6 +20,7 @@ noclobber=0 # Default off, clobber only if flag is enabled continue=0 # Default off, If set Transcoding is skipped and chapter splitting starts at chapter continueAt. continueAt=1 # Optional chapter to continue splitting the chapters. keepArtist=-1 # Default off, if set change artist metadata to use the passed argument as field +authorOverride= # Override the author, ignoring the metadata # ----- # Code tip Do not have any script above this point that calls a function or a binary. If you do @@ -62,6 +63,8 @@ while true; do --level ) level="$2"; shift 2 ;; # Keep artist number n --keep-artist ) keepArtist="$2"; shift 2 ;; + # Author override + --author ) authorOverride="$2"; shift 2 ;; # Command synopsis. -h | --help ) printf "$usage" $0 ; exit ;; # Standard flag signifying the end of command line processing. @@ -144,7 +147,7 @@ log() { # ----- # Print out what we have already after command line processing. -debug_vars "Command line options as set" codec extension mode container targetdir completedir auth_code +debug_vars "Command line options as set" codec extension mode container targetdir completedir auth_code keepArtist authorOverride # ======================================================================== # Variable validation @@ -413,13 +416,19 @@ do # Make sure everything is a variable. Simplifying Command interpretation save_metadata "${aax_file}" genre=$(get_metadata_value genre) - if [ "${keepArtist}" != "-1" ]; then - # sed command: 'C. S. Lewis' -> 'C.S. Lewis' - artist=$(get_metadata_value artist | cut -d',' -f"$keepArtist" | $SED -E 's|\. +|\.|g; s|((\w+\.)+)|\1 |g') - album_artist="$(get_metadata_value album_artist | cut -d',' -f"$keepArtist" | $SED -E 's|\. +|\.|g; s|((\w+\.)+)|\1 |g')" + if [ "x${authorOverride}" != "x" ]; then + #Override + artist="${authorOverride}" + album_artist="${authorOverride}" else - artist=$(get_metadata_value artist) - album_artist="$(get_metadata_value album_artist)" + if [ "${keepArtist}" != "-1" ]; then + # sed command: 'C. S. Lewis' -> 'C.S. Lewis' + artist=$(get_metadata_value artist | cut -d',' -f"$keepArtist" | $SED -E 's|\. +|\.|g; s|((\w+\.)+)|\1 |g') + album_artist="$(get_metadata_value album_artist | cut -d',' -f"$keepArtist" | $SED -E 's|\. +|\.|g; s|((\w+\.)+)|\1 |g')" + else + artist=$(get_metadata_value artist) + album_artist="$(get_metadata_value album_artist)" + fi fi title=$(get_metadata_value title | $SED 's/'\:'/'-'/g' | $SED 's/- /-/g' | xargs -0) title=${title:0:100} diff --git a/README.md b/README.md index cb421e6..93fc18c 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,7 @@ bash AAXtoMP3 [-f|--flac] [-o|--opus] [-a|-aac] [-s|--single] [--level Date: Tue, 9 Feb 2021 17:48:21 +0100 Subject: [PATCH 5/8] artist --> author --- AAXtoMP3 | 8 ++++---- README.md | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/AAXtoMP3 b/AAXtoMP3 index 3535ccc..14cd779 100755 --- a/AAXtoMP3 +++ b/AAXtoMP3 @@ -5,7 +5,7 @@ # Command Line Options # Usage Synopsis. -usage=$'\nUsage: AAXtoMP3 [--flac] [--aac] [--opus ] [--single] [--level ]\n[--chaptered] [-e:mp3] [-e:m4a] [-e:m4b] [--authcode ] [--no-clobber]\n[--target_dir ] [--complete_dir ] [--validate]\n[--continue ] [--keep-artist ] [--author ] {FILES}\n' +usage=$'\nUsage: AAXtoMP3 [--flac] [--aac] [--opus ] [--single] [--level ]\n[--chaptered] [-e:mp3] [-e:m4a] [-e:m4b] [--authcode ] [--no-clobber]\n[--target_dir ] [--complete_dir ] [--validate]\n[--continue ] [--keep-author ] [--author ] {FILES}\n' codec=libmp3lame # Default encoder. extension=mp3 # Default encoder extension. level=-1 # Compression level. Can be given for mp3, flac and opus. -1 = default/not specified. @@ -19,7 +19,7 @@ DEBUG=0 # Default off, If set extremely verbose output. noclobber=0 # Default off, clobber only if flag is enabled continue=0 # Default off, If set Transcoding is skipped and chapter splitting starts at chapter continueAt. continueAt=1 # Optional chapter to continue splitting the chapters. -keepArtist=-1 # Default off, if set change artist metadata to use the passed argument as field +keepArtist=-1 # Default off, if set change author metadata to use the passed argument as field authorOverride= # Override the author, ignoring the metadata # ----- @@ -61,8 +61,8 @@ while true; do --continue ) continueAt="$2"; continue=1; shift 2 ;; # Compression level --level ) level="$2"; shift 2 ;; - # Keep artist number n - --keep-artist ) keepArtist="$2"; shift 2 ;; + # Keep author number n + --keep-author ) keepArtist="$2"; shift 2 ;; # Author override --author ) authorOverride="$2"; shift 2 ;; # Command synopsis. diff --git a/README.md b/README.md index 93fc18c..5f78bfb 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ bash AAXtoMP3 [-f|--flac] [-o|--opus] [-a|-aac] [-s|--single] [--level Date: Tue, 9 Feb 2021 18:54:37 +0100 Subject: [PATCH 6/8] remove leading space after cut --- AAXtoMP3 | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/AAXtoMP3 b/AAXtoMP3 index 14cd779..623c52d 100755 --- a/AAXtoMP3 +++ b/AAXtoMP3 @@ -417,15 +417,17 @@ do save_metadata "${aax_file}" genre=$(get_metadata_value genre) if [ "x${authorOverride}" != "x" ]; then - #Override + #Manual Override artist="${authorOverride}" album_artist="${authorOverride}" else if [ "${keepArtist}" != "-1" ]; then - # sed command: 'C. S. Lewis' -> 'C.S. Lewis' - artist=$(get_metadata_value artist | cut -d',' -f"$keepArtist" | $SED -E 's|\. +|\.|g; s|((\w+\.)+)|\1 |g') - album_artist="$(get_metadata_value album_artist | cut -d',' -f"$keepArtist" | $SED -E 's|\. +|\.|g; s|((\w+\.)+)|\1 |g')" + # Choose artist from the one that are present in the metadata. Comma separated list of names + # remove leading space; 'C. S. Lewis' -> 'C.S. Lewis' + artist="$(get_metadata_value artist | cut -d',' -f"$keepArtist" | $SED -E 's|^ ||g; s|\. +|\.|g; s|((\w+\.)+)|\1 |g')" + album_artist="$(get_metadata_value album_artist | cut -d',' -f"$keepArtist" | $SED -E 's|^ ||g; s|\. +|\.|g; s|((\w+\.)+)|\1 |g')" else + # The default artist=$(get_metadata_value artist) album_artist="$(get_metadata_value album_artist)" fi From fb48899cb780b6cdae417c7de5b90cdacf7c8eb4 Mon Sep 17 00:00:00 2001 From: fabh2o Date: Tue, 9 Feb 2021 19:03:55 +0100 Subject: [PATCH 7/8] precedence --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5f78bfb..2cf91c6 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ bash AAXtoMP3 [-f|--flac] [-o|--opus] [-a|-aac] [-s|--single] [--level Date: Wed, 10 Feb 2021 09:26:25 +0100 Subject: [PATCH 8/8] deleted empty line --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index ba9cf7d..d736c0b 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,6 @@ bash AAXtoMP3 [-f|--flac] [-o|--opus] [-a|-aac] [-s|--single] [--level