tags addtionnels

-par l’option -t
-par le tableau others()
This commit is contained in:
2022-08-21 09:30:58 +02:00
parent f13dacb45c
commit 2c633c5b8d
2 changed files with 52 additions and 41 deletions

View File

@@ -18,3 +18,4 @@ blaireau d'europe;european badger
martre;marten
martre des pins;pine marten
bouquetin;ibex
mammifère;mammal
1 FR EN
18 martre marten
19 martre des pins pine marten
20 bouquetin ibex
21 mammifère mammal

View File

@@ -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