From a0cb1bae1b91131122774fb50ea8e838a4a08dd9 Mon Sep 17 00:00:00 2001 From: Vincent Riquer Date: Tue, 29 Apr 2025 23:48:12 +0200 Subject: [PATCH] Switch to an array --- doc/config | 6 +++--- doc/example.cfg | 12 ++++++++++-- lib/config/getSource | 4 ++-- lib/config/print | 9 ++++++++- lib/config/write | 11 +++++++++-- 5 files changed, 32 insertions(+), 10 deletions(-) diff --git a/doc/config b/doc/config index f182dc0..7c1f826 100644 --- a/doc/config +++ b/doc/config @@ -58,9 +58,9 @@ Sections: %{title}, %{track}, %{year}. - * tag-guessing-triggers : String. List of tags, separated by commas. - If any of the tgs in this list cannot be fetched by tag readers, guessing - will be attempted. + * tag-guessing-trigger : String. Specify multiple times for multiple + tags. + If cannot be fetched by tag readers, guessing will be attempted. [] Each section not named 'general' or 'source' will define a new destination. diff --git a/doc/example.cfg b/doc/example.cfg index 7eb7488..9390d41 100644 --- a/doc/example.cfg +++ b/doc/example.cfg @@ -62,10 +62,18 @@ skip /zzz-atrier # %{title}, # %{track} (2 digits), # %{year}. -#tag-guessing %{genre}/%{albumartist}/%{year}-%{album}-%{releasecountry}/%{disk}%{track}--%{artist}-%{title} +#tag-guessing %{genre}/%{albumartist}/%{year}-%{album}-%{releasecountry}/%{disc}%{track}--%{artist}-%{title} # Guess tags on missing infos: -#tag-missing-triggers artist,albumartist,title,track,year,genre +#tag-guessing-trigger artist +#tag-guessing-trigger albumartist +#tag-guessing-trigger album +#tag-guessing-trigger releasecountry +#tag-guessing-trigger disc +#tag-guessing-trigger title +#tag-guessing-trigger track +#tag-guessing-trigger year +#tag-guessing-trigger genre [Vorbis] diff --git a/lib/config/getSource b/lib/config/getSource index a7c3b02..a5e9354 100644 --- a/lib/config/getSource +++ b/lib/config/getSource @@ -10,8 +10,8 @@ getConfigSource() { 'tag-guessing') tagguessing="$value" ;; - 'tag-guessing-triggers') - tagguessingtriggers="$value" + 'tag-guessing-trigger') + tagguessingtriggers+=( "$value" ) ;; esac } diff --git a/lib/config/print b/lib/config/print index 666b64d..d26821b 100644 --- a/lib/config/print +++ b/lib/config/print @@ -22,7 +22,14 @@ printConfig() { done unset printed echo " |Tag guessing expression|$tagguessing" - echo " |Tag guessing triggers|$tagguessingtriggers" + for trigger in "${tagguessingtriggers[@]}" + do + (( printed )) \ + && echo -n ' | |' \ + || echo -n ' |Tag guessing triggers|' + echo "$trigger" + printed=1 + done for destination in ${destinations[@]} do diff --git a/lib/config/write b/lib/config/write index 1d32fc3..7aafd44 100644 --- a/lib/config/write +++ b/lib/config/write @@ -64,10 +64,17 @@ path $sourcepath # %{title}, # %{track} (2 digits), # %{year}. -#tag-guessing %{genre}/%{albumartist}/%{year}-%{album}-%{releasecountry}/%{disk}%{track}--%{artist}-%{title} +#tag-guessing %{genre}/%{albumartist}/%{year}-%{album}-%{releasecountry}/%{disc}%{track}--%{artist}-%{title} +tag-guessing $tagguessing # Guess tags on missing infos: -#tag-missing-triggers artist,albumartist,title,track,year,genre +#tag-guessing-trigger artist +#tag-guessing-trigger albumartist + EOCfg + for trigger in "${tagguessingtriggers[@]}" + do + echo $'tag-guessing-trigger\t'"$trigger" + done EOCfg