From 2c633c5b8daec1ddf9068d422c4b36c75cb23d65 Mon Sep 17 00:00:00 2001 From: Bruno21 Date: Sun, 21 Aug 2022 09:30:58 +0200 Subject: [PATCH] tags addtionnels MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -par l’option -t -par le tableau others() --- keywords.csv | 1 + keywords2insta.sh | 92 ++++++++++++++++++++++++++--------------------- 2 files changed, 52 insertions(+), 41 deletions(-) diff --git a/keywords.csv b/keywords.csv index 74949b0..e6d7012 100644 --- a/keywords.csv +++ b/keywords.csv @@ -18,3 +18,4 @@ blaireau d'europe;european badger martre;marten martre des pins;pine marten bouquetin;ibex +mammifère;mammal diff --git a/keywords2insta.sh b/keywords2insta.sh index d0142e3..f271bd8 100755 --- a/keywords2insta.sh +++ b/keywords2insta.sh @@ -4,12 +4,18 @@ red="\033[1;31m" bold="\033[1m" reset="\033[0m" -file=$1 -#t) tags+=("$OPTARG");; +# Tags automatically added +# You can add tags to this 4 arrays + +wild=("wildlife" "wildlifephoto" "wildlifephotographer") +nat=("naturelovers" "natureshot" "naturephotography") +reg=("Bourgogne" "Burgundy" "Bourgogne Franche-Comté" "Côte d'or") +others=("tag" "keu") # tags -t mammifere foret animal +opt_others=false opt_lens=false opt_model=false opt_region=false @@ -33,26 +39,23 @@ do ;; m) opt_model=true;; l) opt_lens=true;; - a) opt_all=false;; *) echo "Unknow option '-$opt'" >&2 exit -1;; esac done + if [ $opt_lens = true ] || [ $opt_model = true ] || [ $opt_region = true ] || [ $opt_nature = true ] || [ $opt_wildlife = true ]; then opt_all=false fi -l=$(echo "${tags[@]}" | sed -r 's/[^ ]+/,&/g') +if [ ${#others[@]} -gt 0 ] || [ ${#tags[@]} -gt 0 ]; then + opt_others=true +fi -# Tags automatically added -# You can add tags to this 4 arrays +t=$(echo "${tags[@]}" | sed -r 's/[^ ]+/,&/g') -wild=("wildlife" "wildlifephoto" "wildlifephotographer") -nat=("naturelovers" "natureshot" "naturephotography") -reg=("Bourgogne" "Burgundy" "Bourgogne Franche-Comté" "Côte d'or") -others=("tag" "keu") #trans fr:en -b "renard" @@ -102,7 +105,6 @@ exif=$(exiftool -Canon -s -Keywords "$file") # keywords k=$(echo "$exif" | sed -n '/^Keywords/p' | awk -F":" '{print $2}' | sed 's/^ *//g') -[ "$l" != "" ] && k="$k $l" if [ -z "$k" ]; then echo -e "${bold}${red}No Keywords found !${reset}" @@ -225,6 +227,7 @@ END_COMMENT echo "tags: ${tags[@]}" +echo "others: ${others[@]}" echo "file: $file" echo "wildlife: $opt_wildlife" echo "nature: $opt_nature" @@ -236,51 +239,57 @@ echo if [ $opt_all = false ]; then -if [ $opt_wildlife = false ]; then - wildlife_flickr="" - wildlife_insta="" - echo "pas de wildlife !" -fi + if [ $opt_wildlife = false ]; then + wildlife_flickr="" + wildlife_insta="" + fi -if [ $opt_nature = false ]; then - nature_flickr="" - nature_insta="" - echo "pas de nature !" -fi + if [ $opt_nature = false ]; then + nature_flickr="" + nature_insta="" + fi -if [ $opt_region = false ]; then - region_flickr="" - region_insta="" - echo "pas de region !" -fi + if [ $opt_region = false ]; then + region_flickr="" + region_insta="" + fi -if [ $opt_lens = false ]; then - lens_flickr="" - lens_insta="" - echo "pas de lens !" -fi + if [ $opt_lens = false ]; then + lens_flickr="" + lens_insta="" + fi -if [ $opt_model = false ]; then - model_flickr="" - model_insta="" - echo "pas de model !" -fi + if [ $opt_model = false ]; then + model_flickr="" + model_insta="" + fi fi keywords_flickr="$keyword_flickr$model_flickr$lens_flickr$wildlife_flickr$nature_flickr$region_flickr" keywords_insta=$(echo "$keyword_insta$model_insta$lens_insta$wildlife_insta$nature_insta$region_insta" | awk '{print tolower($0)}') -if [ ${#others[@]} -gt 0 ]; then +if [ $opt_others = true ]; then + # insert tags added with option -t to others's tag array + others+=(`echo $t | tr ',' ' '`) + for i in "${others[@]}" do - if [[ "$i" = *" "* ]]; then - others_flickr+="\"${i}\" " + if [[ ${dico["$i"]} ]] ; then + o_en=${dico["$i"]} else - others_flickr+="${i} " + o_en="" fi - others_insta+="#$(echo "${i}" | iconv -f UTF-8-MAC -t ascii//translit | sed 's/[^a-zA-Z 0-9]//g' | sed 's/ //g') " + + if [ -n "$o_en" ]; then + [[ "$i" = *" "* ]] && others_flickr+="\"${i}\" " || others_flickr+="${i} " + [[ "$o_en" = *" "* ]] && others_flickr+="\"${o_en}\" " || others_flickr+="${o_en} " + others_insta+="#${i// /} #${o_en// /} " + else + [[ "$i" = *" "* ]] && others_flickr+="\"${i}\" " || others_flickr+="${i} " + others_insta+="#${i// /} " + fi done keywords_flickr+="$others_flickr" keywords_insta+="$others_insta" @@ -293,6 +302,7 @@ echo "$keywords_insta" echo END_COMMENT + # suppress accent (bug in macos) => add sed => suppress punctuation too # https://stackoverflow.com/questions/806199/how-to-fix-weird-issue-with-iconv-on-mac-os-x