suppress gmap api key from history
This commit is contained in:
880
keywords2insta 2.sh
Executable file
880
keywords2insta 2.sh
Executable file
@@ -0,0 +1,880 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
red="\033[1;31m"
|
||||||
|
greenbold="\033[1;32m"
|
||||||
|
green="\033[0;32m"
|
||||||
|
yellow="\033[0;33m"
|
||||||
|
bold="\033[1m"
|
||||||
|
#bold_under="\033[1;4m"
|
||||||
|
underline="\033[4m"
|
||||||
|
reset="\033[0m"
|
||||||
|
|
||||||
|
|
||||||
|
# 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=("lanscape" "animal" "beautiful nature")
|
||||||
|
#others=()
|
||||||
|
|
||||||
|
# Display Instagram AND/OR Flickr tags
|
||||||
|
insta=false # #Becasseauvariable #LeTeich #Bird
|
||||||
|
flickr=true # "Bécasseau variable" "Le Teich" Bird
|
||||||
|
ccpx=true # Bécasseau variable, Le Teich, Bird
|
||||||
|
|
||||||
|
gps=0
|
||||||
|
opt_gps=true # insert gps data (false: gps data will be deleted in file)
|
||||||
|
opt_copyright=true # insert copyright, artist, creator (false: data will be deleted in file)
|
||||||
|
|
||||||
|
# Default: all tags
|
||||||
|
opt_others=false
|
||||||
|
opt_lens=false
|
||||||
|
opt_model=false
|
||||||
|
opt_region=false
|
||||||
|
opt_nature=false
|
||||||
|
opt_wildlife=false
|
||||||
|
opt_all=true # default
|
||||||
|
|
||||||
|
# Google maps static
|
||||||
|
zoom=10
|
||||||
|
color=blue
|
||||||
|
label="S"
|
||||||
|
type=hybrid
|
||||||
|
map_size="450x450"
|
||||||
|
prefix=${map_size%%x*} # find x position in map_size string
|
||||||
|
x=${#prefix}
|
||||||
|
gm_width=${map_size:0:$x}
|
||||||
|
|
||||||
|
#long_path=$(pwd)"/"$(basename "$0") # /Users/bruno/Documents/Scripts/kymsu2/keywords2insta.sh
|
||||||
|
# long: /Users/bruno/Documents/GitHub/GooFuzz/keywords2insta.sh
|
||||||
|
|
||||||
|
dir=$(dirname "$0") # /Users/bruno/Documents/Scripts/keywords2insta
|
||||||
|
|
||||||
|
dotenv () {
|
||||||
|
set -a
|
||||||
|
# shellcheck disable=SC1091
|
||||||
|
[ -f "$HOME/.env" ] && . "$HOME/.env" || echo -e "${red}\nNo .env file found ! Googlemaps reverse geocode not working.${reset}"
|
||||||
|
set +a
|
||||||
|
}
|
||||||
|
|
||||||
|
dotenv
|
||||||
|
|
||||||
|
trim () {
|
||||||
|
read -rd '' "$1" <<<"${!1}"
|
||||||
|
}
|
||||||
|
|
||||||
|
alpha_name=
|
||||||
|
alpha () {
|
||||||
|
|
||||||
|
array=()
|
||||||
|
#declare -A ilce=( ['ILCE-7M3']="Alpha 7 III" ['ILCE-7M4']="α7 IV" ['ILCE-7MRM5']="α7R V" ['ILCE-7SM3']="Alpha 7S III" ['ILCE-7RM4']="α7R IV" ['ILCE-7RM3']="α7R III" ['ILCE-7C']="Alpha 7C" )
|
||||||
|
declare -A ilce
|
||||||
|
|
||||||
|
if [ -f "$dir"/sony.csv ]; then
|
||||||
|
|
||||||
|
#echo "Loading Sony APNs..."
|
||||||
|
|
||||||
|
while IFS=';' read -ra array;
|
||||||
|
do
|
||||||
|
key="${array[0]}"
|
||||||
|
value="${array[1]}"
|
||||||
|
ilce["$key"]="$value"
|
||||||
|
done < "$dir"/sony.csv
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
for val in "${!ilce[@]}"
|
||||||
|
do
|
||||||
|
[[ ${val} == "$model" ]] && alpha_name="${ilce[$val]}"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
showHelp() {
|
||||||
|
echo -e "${greenbold}keywords2insta${reset} v3.1"
|
||||||
|
echo -e "Bruno <bruno<clicclac.info>"
|
||||||
|
echo -e "Read exif and keywords from an image file, and copy them to the clipboard, "
|
||||||
|
echo -e " ready for Instagram, Flickr and 500px."
|
||||||
|
echo
|
||||||
|
echo -e "${yellow}USAGE:${reset}"
|
||||||
|
echo -e "${green}keyword2insta [-Options...] -f <file>${reset}"
|
||||||
|
echo -e "If no option (except gps and copyright) is chosen, all tags are added (default)."
|
||||||
|
echo -e "Keywords taken from exifs are automatically added."
|
||||||
|
echo -e "You can add keywords permanently by adding them to the ${underline}others array${reset} at the start of the script. (See others=())"
|
||||||
|
echo -e "The images files are not modified."
|
||||||
|
echo
|
||||||
|
echo -e "If the gps and coypright options are selected, the images files will be modified."
|
||||||
|
echo
|
||||||
|
echo -e "${yellow}OPTIONS:${reset}"
|
||||||
|
echo -e " ${green}-f${reset}, ${green}--file <file>${reset} Image file"
|
||||||
|
echo -e " ${green}-l${reset}, ${green}--lens${reset} Add lens exif"
|
||||||
|
echo -e " ${green}-m${reset}, ${green}--model${reset} Add APN model exif"
|
||||||
|
echo -e " ${green}-n${reset}, ${green}--nature${reset} Add nature related keywords"
|
||||||
|
echo -e " ${green}-r${reset}, ${green}--region${reset} Add region related keywords"
|
||||||
|
echo -e " ${green}-c${reset}, ${green}--copyright${reset} Delete artist and copyright in file"
|
||||||
|
echo -e " ${green}-t${reset} <keywords> Add some additionnals keywords"
|
||||||
|
echo -e " ${green}-w${reset}, ${green}--wildlife${reset} Add wildlife related keywords"
|
||||||
|
echo -e " ${green}-h${reset}, ${green}--help${reset} Display this help"
|
||||||
|
echo
|
||||||
|
echo -e "${yellow}REQUIEREMENTS:${reset}"
|
||||||
|
echo -e " -${underline}exiftool${reset} for extract exifs ${bold}(requis)${reset}"
|
||||||
|
echo -e " brew install exiftool"
|
||||||
|
echo -e " -${underline}iconv${reset} for suppress accent (optional"
|
||||||
|
echo -e " brew install iconv"
|
||||||
|
echo -e " -${underline}gawk${reset} for suppress doubles (optional)"
|
||||||
|
echo -e " brew install gawk"
|
||||||
|
echo
|
||||||
|
echo -e "${yellow}EXAMPLES:${reset}"
|
||||||
|
echo -e " keyword2insta -f image.jpg"
|
||||||
|
echo -e " keyword2insta -lm -f image.jpg"
|
||||||
|
echo -e " keyword2insta --lens --model --file image.jpg"
|
||||||
|
echo -e " keyword2insta -lm -t deer mammal animal -f deer.jpg"
|
||||||
|
echo
|
||||||
|
echo -e "${yellow}EXIT CODES:${reset}"
|
||||||
|
echo -e " 0: Success !"
|
||||||
|
echo -e " 1: Exiftool could not be found."
|
||||||
|
echo -e " 2: No image file."
|
||||||
|
echo -e " 3: Unknown long option."
|
||||||
|
echo -e " 4: Unknown short option."
|
||||||
|
echo -e " 5: No Keywords found in image file."
|
||||||
|
echo
|
||||||
|
echo -e "${yellow}Changelog:${reset}"
|
||||||
|
echo -e " v3.0: support 500px"
|
||||||
|
echo -e " v3.1: display thumb"
|
||||||
|
echo -e " v3.2: suppress copyright and artist infos"
|
||||||
|
echo -e " v3.3: add a static Google maps for geoloc"
|
||||||
|
}
|
||||||
|
|
||||||
|
# https://stackoverflow.com/questions/402377/using-getopts-to-process-long-and-short-command-line-options
|
||||||
|
# le 1er : de $optspec supprime le message d'erreur
|
||||||
|
unset -v tags
|
||||||
|
#OPTIND=1
|
||||||
|
optspec=":wnrcf:t:mlh-:"
|
||||||
|
while getopts "$optspec" opt
|
||||||
|
do
|
||||||
|
case $opt in
|
||||||
|
-) case "${OPTARG}" in
|
||||||
|
help) showHelp; exit;;
|
||||||
|
wildlife) opt_wildlife=true;;
|
||||||
|
nature) opt_nature=true;;
|
||||||
|
region) opt_region=true;;
|
||||||
|
file)
|
||||||
|
file="${!OPTIND}"; OPTIND=$(( OPTIND + 1 ))
|
||||||
|
;;
|
||||||
|
file=*)
|
||||||
|
file=${OPTARG#*=}
|
||||||
|
#opt=${OPTARG%=$file}
|
||||||
|
opt="$(printf "%s\n" "${OPTARG}" | cut -d'=' -f1 )" ; file="$(printf "%s\n" "${OPTARG}" | cut -d'=' -f2-)"
|
||||||
|
;;
|
||||||
|
model) opt_model=true;;
|
||||||
|
lens) opt_lens=true;;
|
||||||
|
copyright) opt_copyright=false;;
|
||||||
|
*)
|
||||||
|
if [ "$OPTERR" = 1 ] && [ "${optspec:0:1}" = ":" ]; then
|
||||||
|
echo "Unknown option --${OPTARG}" >&2
|
||||||
|
fi
|
||||||
|
exit 3
|
||||||
|
;;
|
||||||
|
esac;;
|
||||||
|
w) opt_wildlife=true;;
|
||||||
|
n) opt_nature=true;;
|
||||||
|
r) opt_region=true;;
|
||||||
|
c) opt_copyright=false;;
|
||||||
|
f) file="${OPTARG}";;
|
||||||
|
t) tags=("$OPTARG")
|
||||||
|
until [[ $(eval "echo \${$OPTIND}") =~ ^-.* ]] || [ -z $(eval "echo \${$OPTIND}") ]; do
|
||||||
|
tags+=($(eval "echo \${$OPTIND}"))
|
||||||
|
OPTIND=$((OPTIND + 1))
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
m) opt_model=true;;
|
||||||
|
l) opt_lens=true;;
|
||||||
|
h)
|
||||||
|
showHelp
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
if [ "$OPTERR" != 1 ] || [ "${optspec:0:1}" = ":" ]; then
|
||||||
|
echo "Non-option argument: '-${OPTARG}'" >&2
|
||||||
|
fi
|
||||||
|
exit 4
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
#shift $((OPTIND-1))
|
||||||
|
|
||||||
|
if [ $opt_lens = true ] || [ $opt_model = true ] || [ $opt_region = true ] || [ $opt_nature = true ] || [ $opt_wildlife = true ]; then
|
||||||
|
opt_all=false
|
||||||
|
fi
|
||||||
|
|
||||||
|
# others: array from script
|
||||||
|
# tags: array from arguments
|
||||||
|
if [ ${#others[@]} -gt 0 ] || [ ${#tags[@]} -gt 0 ]; then
|
||||||
|
opt_others=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
t=$(echo "${tags[@]}" | sed -r 's/[^ ]+/,&/g')
|
||||||
|
|
||||||
|
#: <<'END_COMMENT'
|
||||||
|
echo "----"
|
||||||
|
echo "others: " ${others[@]}
|
||||||
|
echo "tags: " ${tags[@]} # t
|
||||||
|
echo "opt_lens: " $opt_lens # l
|
||||||
|
echo "opt_model: " $opt_model # m
|
||||||
|
echo "opt_region: " $opt_region # r
|
||||||
|
echo "opt_nature: " $opt_nature # n
|
||||||
|
echo "opt_wildlife: " $opt_wildlife # w
|
||||||
|
echo "opt_others: " $opt_others
|
||||||
|
echo "opt_copyright: " $opt_copyright # c
|
||||||
|
echo "----"
|
||||||
|
#END_COMMENT
|
||||||
|
|
||||||
|
|
||||||
|
if ! command -v exiftool &> /dev/null; then
|
||||||
|
echo -e "${bold}exiftool${reset} could not be found !\n"
|
||||||
|
echo -e "You should install ${bold}exiftool${reset}:\n"
|
||||||
|
echo -e " - brew install exiftool"
|
||||||
|
echo -e ""
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
[ ! -f "$file" ] && echo -e "${bold}${red}No input file !${reset}" && exit 2
|
||||||
|
|
||||||
|
echo -e "\n${greenbold}keywords2insta${reset} v3.3"
|
||||||
|
|
||||||
|
# dico français / anglais
|
||||||
|
|
||||||
|
fr=()
|
||||||
|
en=()
|
||||||
|
array2=()
|
||||||
|
declare -A dico
|
||||||
|
|
||||||
|
if [ -f "$dir"/keywords.csv ]; then
|
||||||
|
|
||||||
|
echo "Loading keyword dictionary..."
|
||||||
|
|
||||||
|
while IFS=';' read -ra array2;
|
||||||
|
do
|
||||||
|
fr+=("${array2[0]}")
|
||||||
|
en+=("${array2[1]}")
|
||||||
|
done < "$dir"/keywords.csv
|
||||||
|
|
||||||
|
j=0
|
||||||
|
for i in "${fr[@]}"
|
||||||
|
do
|
||||||
|
x="${en[$j]}"
|
||||||
|
dico+=( ["$i"]="$x" )
|
||||||
|
((j=j+1))
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
echo -e "\n${bold}Reading $file exif...${reset}"
|
||||||
|
|
||||||
|
# The exiftool application exits with a status of 0 on success, or 1 if an
|
||||||
|
# error occurred, or 2 if all files failed the -if condition (for any of
|
||||||
|
# the commands if -execute was used).
|
||||||
|
|
||||||
|
|
||||||
|
#exif=$(exiftool -Canon -s -Keywords -j "$file")
|
||||||
|
exif=$(exiftool -j "$file")
|
||||||
|
# The exiftool application exits with a status of 0 on success, or 1 if an
|
||||||
|
# error occurred, or 2 if all files failed the -if condition (for any of
|
||||||
|
# the commands if -execute was used).
|
||||||
|
|
||||||
|
# exif
|
||||||
|
|
||||||
|
make=$(echo "$exif" | jq -j '.[] | .Make | select( . != null )')
|
||||||
|
model=$(echo "$exif" | jq -j '.[] | .Model | select( . != null )')
|
||||||
|
date_original=$(echo "$exif" | jq -j '.[] | .DateTimeOriginal | select( . != null )')
|
||||||
|
speed=$(echo "$exif" | jq -j '.[] | .ShutterSpeed | select( . != null )')
|
||||||
|
aperture=$(echo "$exif" | jq -j '.[] | .Aperture | select( . != null )')
|
||||||
|
iso=$(echo "$exif" | jq -j '.[] | .ISO | select( . != null )')
|
||||||
|
lens=$(echo "$exif" | jq -j '.[] | .Lens | select( . != null )')
|
||||||
|
lensID=$(echo "$exif" | jq -j '.[] | .LensID | select( . != null )')
|
||||||
|
lensModel=$(echo "$exif" | jq -j '.[] | .LensModel | select( . != null )')
|
||||||
|
focal=$(echo "$exif" | jq -j '.[] | .FocalLength | select( . != null )')
|
||||||
|
latitude=$(echo "$exif" | jq -j '.[] | .GPSLatitude | select( . != null )')
|
||||||
|
longitude=$(echo "$exif" | jq -j '.[] | .GPSLongitude | select( . != null )')
|
||||||
|
altitude=$(echo "$exif" | jq -j '.[] | .GPSAltitude | select( . != null )')
|
||||||
|
width=$(echo "$exif" | jq -j '.[] | .ImageWidth | select( . != null )')
|
||||||
|
height=$(echo "$exif" | jq -j '.[] | .ImageHeight | select( . != null )')
|
||||||
|
size=$(echo "$exif" | jq -j '.[] | .FileSize | select( . != null )')
|
||||||
|
city=$(echo "$exif" | jq -j '.[] | .City | select( . != null )')
|
||||||
|
state=$(echo "$exif" | jq -j '.[] | .State | select( . != null )')
|
||||||
|
country=$(echo "$exif" | jq -j '.[] | .Country | select( . != null )')
|
||||||
|
comment=$(echo "$exif" | jq -j '.[] | .Comment | select( . != null )')
|
||||||
|
software=$(echo "$exif" | jq -j '.[] | .Software | select( . != null )')
|
||||||
|
|
||||||
|
|
||||||
|
# EXIF:Artist | IPTC:By-line | XMP:Creator : Pesenti
|
||||||
|
# EXIF:Copyright | IPTC:CopyrightNotice | XMP:Rights: clicclac.info
|
||||||
|
art=$(echo "$exif" | jq -j '.[] | .Artist | select( . != null )')
|
||||||
|
#byline=$(echo "$exif" | jq -j '.[] | .By-line | select( . != null )')
|
||||||
|
creator=$(echo "$exif" | jq -j '.[] | .Creator | select( . != null )')
|
||||||
|
|
||||||
|
if [ -n "$art" ]; then artist="$art"
|
||||||
|
elif [ -n "$creator" ]; then artist="$creator"
|
||||||
|
fi
|
||||||
|
|
||||||
|
copy=$(echo "$exif" | jq -j '.[] | .Copyright | select( . != null )')
|
||||||
|
notice=$(echo "$exif" | jq -j '.[] | .CopyrightNotice | select( . != null )')
|
||||||
|
rights=$(echo "$exif" | jq -j '.[] | .Rights | select( . != null )')
|
||||||
|
|
||||||
|
if [ -n "$copy" ]; then copyright="$copy "
|
||||||
|
elif [ -n "$notice" ]; then copyright="$notice"
|
||||||
|
else copyright="$rights"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Display thumb image
|
||||||
|
|
||||||
|
if [ "$(echo "$__CFBundleIdentifier" | grep iterm2)" ]; then
|
||||||
|
tmp_path=/tmp/k2i
|
||||||
|
[ -d $tmp_path ] && rm -rf $tmp_path
|
||||||
|
mkdir $tmp_path
|
||||||
|
|
||||||
|
#tempfoo=`basename "$file"`
|
||||||
|
tempfoo=$(basename "$file")
|
||||||
|
magick "$file" -quality 50 -resize 600x600\> $tmp_path/thumb_"$tempfoo"
|
||||||
|
if [ -f "$tmp_path/thumb_$tempfoo" ]; then
|
||||||
|
[ "$width" -gt "$height" ] && w_thumb=600 || w_thumb=$(echo "600/3*2" | bc)
|
||||||
|
#printf "\n\t\033]1337;File=;width=$w_thumb px;inline=1:`cat $tmp_path/thumb_$tempfoo | base64`\a\n"
|
||||||
|
printf "\n\t\033]1337;File=;width=$w_thumb px;inline=1:$(cat $tmp_path/thumb_$tempfoo | base64)\a\n"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo
|
||||||
|
if [[ -n $iso ]] && [[ -n $speed ]] && [[ -n $aperture ]]; then
|
||||||
|
printf " %-11s %-35s \n" "Speed:" "${speed}"
|
||||||
|
printf " %-11s %-35s \n" "Aperture:" "f/${aperture}"
|
||||||
|
printf " %-11s %-35s \n" "ISO:" "${iso}"
|
||||||
|
printf " %-11s %-35s \n" "Date:" "${date_original}"
|
||||||
|
printf " %-11s %-35s \n" "Maker:" "${make}"
|
||||||
|
if [[ "$make" =~ ^SONY ]]; then
|
||||||
|
alpha
|
||||||
|
printf " %-11s %-35s \n" "APN:" "$alpha_name (${model})"
|
||||||
|
else
|
||||||
|
printf " %-11s %-35s \n" "APN:" "${model}"
|
||||||
|
fi
|
||||||
|
printf " %-11s %-35s \n" "Focal:" "${focal}"
|
||||||
|
|
||||||
|
# Many lens have the same Lensid
|
||||||
|
# https://exiftool.org/forum/index.php?topic=3833.msg82043#msg82043
|
||||||
|
|
||||||
|
# "LensInfo": "100-500mm f/?",
|
||||||
|
# "LensModel": "RF100-500mm F4.5-7.1 L IS USM",
|
||||||
|
# "Lens": "RF100-500mm F4.5-7.1 L IS USM",
|
||||||
|
# "LensID": "Canon RF 100-500mm F4.5-7.1L IS USM or Canon RF 100-500mm F4.5-7.1L IS USM + RF1.4x or Canon RF 100-500mm F4.5-7.1L IS USM + RF2x"
|
||||||
|
|
||||||
|
# "LensInfo": "600mm f/?",
|
||||||
|
# "LensModel": "EF600mm f/4L IS III USM",
|
||||||
|
# "Lens": "EF600mm f/4L IS III USM",
|
||||||
|
# "LensID": "Canon EF 600mm f/4L IS III USM"
|
||||||
|
|
||||||
|
# "LensInfo": "100mm f/?",
|
||||||
|
# "LensModel": "EF100mm f/2.8 Macro USM",
|
||||||
|
# "Lens": "EF100mm f/2.8 Macro USM",
|
||||||
|
# "LensID": "Canon EF 100mm f/2.8 Macro USM"
|
||||||
|
|
||||||
|
# "LensInfo": "24-105mm f/?",
|
||||||
|
# "LensModel": "EF24-105mm f/4L IS USM",
|
||||||
|
# "Lens": "EF24-105mm f/4L IS USM",
|
||||||
|
# "LensID": "Canon EF 24-105mm f/4L IS USM"
|
||||||
|
|
||||||
|
# "LensInfo": "17-40mm f/?",
|
||||||
|
# "LensModel": "EF17-40mm f/4L USM",
|
||||||
|
# "Lens": "EF17-40mm f/4L USM",
|
||||||
|
# "LensID": "Canon EF 17-40mm f/4L USM"
|
||||||
|
|
||||||
|
# "LensInfo": "500mm f/?",
|
||||||
|
# "LensModel": "EF500mm f/4L IS USM",
|
||||||
|
# "Lens": "EF500mm f/4L IS USM",
|
||||||
|
# "LensID": "Canon EF 500mm f/4L IS USM"
|
||||||
|
|
||||||
|
# "LensInfo": "70-200mm f/?",
|
||||||
|
# "LensModel": "EF70-200mm f/4L USM",
|
||||||
|
# "Lens": "EF70-200mm f/4L USM",
|
||||||
|
# "LensID": "Canon EF 70-200mm f/4L USM"
|
||||||
|
|
||||||
|
# "LensInfo": "24mm f/?",
|
||||||
|
# "LensModel": "24mm F1.4 DG HSM | Art 015",
|
||||||
|
# "Lens": "24mm F1.4 DG HSM | Art 015",
|
||||||
|
# "LensID": "Sigma 24-105mm f/4 DG OS HSM | A"
|
||||||
|
|
||||||
|
# "LensInfo": "24-105mm f/?",
|
||||||
|
# "LensModel": "RF24-105mm F4-7.1 IS STM",
|
||||||
|
# "Lens": "RF24-105mm F4-7.1 IS STM",
|
||||||
|
# "LensID": "Canon RF 24-105mm F4-7.1 IS STM"
|
||||||
|
|
||||||
|
# "LensInfo": "840mm f/?",
|
||||||
|
# "LensModel": "EF600mm f/4L IS III USM +1.4x III",
|
||||||
|
# "Lens": "EF600mm f/4L IS III USM +1.4x III",
|
||||||
|
# "LensID": "Canon EF 600mm f/4L IS III USM + 1.4x"
|
||||||
|
|
||||||
|
# "LensInfo": "700mm f/?",
|
||||||
|
# "LensModel": "EF500mm f/4L IS USM +1.4x III",
|
||||||
|
# "Lens": "EF500mm f/4L IS USM +1.4x III",
|
||||||
|
# "LensID": "Canon EF 500mm f/4L IS USM + 1.4x"
|
||||||
|
|
||||||
|
|
||||||
|
if [[ -n $lensID ]]; then
|
||||||
|
printf " %-11s %-35s \n" "LensID:" "${lensID}"
|
||||||
|
l="$lensID"
|
||||||
|
elif [[ -n $lensModel ]]; then
|
||||||
|
printf " %-11s %-35s \n" "LensModel:" "${lensModel}"
|
||||||
|
l="$lensModel"
|
||||||
|
else
|
||||||
|
printf " %-11s %-35s \n" "Lens:" "${lens}"
|
||||||
|
l="$lens"
|
||||||
|
fi
|
||||||
|
# width > height && w=2400 || w=1600
|
||||||
|
if [ "$width" -gt "$height" ]; then
|
||||||
|
wi=2400
|
||||||
|
he=1600
|
||||||
|
[ "$width" -ne "$wi" ] && printf " %-11s %-35b \n" "Width:" "${red}${width}${reset}" || printf " %-11s %-35s \n" "Width:" "${width}"
|
||||||
|
[ "$height" -ne "$he" ] && printf " %-11s %-35b \n" "Height:" "${red}${height}${reset}" || printf " %-11s %-35s \n" "Height:" "${height}"
|
||||||
|
elif [ "$height" -gt "$width" ]; then
|
||||||
|
wi=1600
|
||||||
|
he=2400
|
||||||
|
[ "$width" -ne "$wi" ] && printf " %-11s %-35b \n" "Width:" "${red}${width}${reset}" || printf " %-11s %-35s \n" "Width:" "${width}"
|
||||||
|
[ "$height" -ne "$he" ] && printf " %-11s %-3b \n" "Height:" "${red}${height}${reset}" || printf " %-11s %-35s \n" "Height:" "${height}"
|
||||||
|
fi
|
||||||
|
#printf " %-11s %-35s \n" "Width:" "${width}"
|
||||||
|
#printf " %-11s %-35s \n" "Height:" "${height}"
|
||||||
|
printf " %-11s %-35s \n" "Size:" "${size}"
|
||||||
|
|
||||||
|
if [[ -n $latitude ]] && [[ -n $longitude ]]; then
|
||||||
|
gps=1
|
||||||
|
|
||||||
|
printf " %-11s %-35s \n" "Latitude:" "${latitude}"
|
||||||
|
printf " %-11s %-35s \n" "Longitude:" "${longitude}"
|
||||||
|
printf " %-11s %-35s \n" "Altitude:" "${altitude}"
|
||||||
|
city=""
|
||||||
|
if [[ -n $city ]] && [[ -n $state ]] && [[ -n $country ]]; then
|
||||||
|
printf " %-11s %-35s \n" "City:" "${city}"
|
||||||
|
printf " %-11s %-35s \n" "State:" "${state}"
|
||||||
|
printf " %-11s %-35s \n" "Country:" "${country}"
|
||||||
|
else
|
||||||
|
coords=$(exiftool -n -gpslatitude -gpslongitude "$file")
|
||||||
|
lat=$(echo "$coords" | sed -n '1p' | awk -F":" '{print $2}' | xargs)
|
||||||
|
long=$(echo "$coords" | sed -n '$p' | awk -F":" '{print $2}' | xargs)
|
||||||
|
|
||||||
|
if [[ -n $GM_API_KEY ]]; then
|
||||||
|
gm=$(curl -s "https://maps.googleapis.com/maps/api/geocode/json?latlng=${lat},${long}&sensor=false&key=$GM_API_KEY" | jq -r '.results[0].address_components')
|
||||||
|
city=$(echo "$gm" | jq '. | map( select( .types | contains(["locality"]) ) ) | .[].long_name')
|
||||||
|
code=$(echo "$gm" | jq '. | map( select( .types | contains(["postal_code"]) ) ) | .[].long_name')
|
||||||
|
state=$(echo "$gm" | jq '. | map( select( .types | contains(["administrative_area_level_2"]) ) ) | .[].long_name')
|
||||||
|
region=$(echo "$gm" | jq '. | map( select( .types | contains(["administrative_area_level_1"]) ) ) | .[].long_name')
|
||||||
|
country=$(echo "$gm" | jq '. | map( select( .types | contains(["country"]) ) ) | .[].long_name')
|
||||||
|
|
||||||
|
printf " %-11s %-35s \n" "CP / City:" "${code//\"/} ${city//\"/}"
|
||||||
|
printf " %-11s %-35s \n" "State:" "${state//\"/}"
|
||||||
|
printf " %-11s %-35s \n" "Region:" "${region//\"/}"
|
||||||
|
printf " %-11s %-35s \n" "Country:" "${country//\"/}"
|
||||||
|
|
||||||
|
#url="https://maps.googleapis.com/maps/api/staticmap?center=$lat,$long&zoom=14&size=400x400&key=$GM_API_KEY"
|
||||||
|
url="https://maps.googleapis.com/maps/api/staticmap?center=$lat,$long&zoom=$zoom&markers=color:$color%7Clabel:$label%7C$lat,$long&maptype=$type&size=$map_size&key=$GM_API_KEY"
|
||||||
|
|
||||||
|
#curl "https://maps.googleapis.com/maps/api/staticmap?center=47.1275353416667,4.78201903333333&zoom=14&size=400x400&key=AIzaSyD94L2Q4K9_ErGSarTBN4FrUxDSspGzNhY" --output /tmp/gm.png
|
||||||
|
gm_path=/tmp/k2i/gm.png
|
||||||
|
curl -s "$url" --output $gm_path
|
||||||
|
if [ -f "$gm_path" ]; then
|
||||||
|
#printf "\n\t\033]1337;File=;width=$((gm_width * 2)) px;inline=1:`cat $gm_path | base64`\a\n"
|
||||||
|
printf "\n\t\033]1337;File=;width=$((gm_width * 2)) px;inline=1:$(cat $gm_path | base64)\a\n"
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf " %-11s %-35s \n" "Software:" "${software}"
|
||||||
|
printf " %-11s %-35s \n" "Comment:" "${comment}"
|
||||||
|
printf " %-11s %-35s \n" "Artist:" "${artist}"
|
||||||
|
printf " %-11s %-35s \n" "Copyright:" "${copyright}"
|
||||||
|
echo
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# gps
|
||||||
|
if [ $opt_gps = true ]; then
|
||||||
|
if [ $gps -eq 1 ]; then
|
||||||
|
echo -e "${red}GPS data available !${reset}"
|
||||||
|
|
||||||
|
d=$(echo -e "Do you want to ${bold}erase GPS data${reset} ? (k)eep or (e)rase ")
|
||||||
|
read -r -p "$d" choice
|
||||||
|
|
||||||
|
if [ "$choice" == "e" ] || [ "$choice" == "E" ]; then
|
||||||
|
echo "Erasing GPS data..."
|
||||||
|
exiftool -gps:all= "$file"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# erase GPS data
|
||||||
|
echo "Erasing GPS data..."
|
||||||
|
exiftool -gps:all= "$file"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# copyright
|
||||||
|
if [ $opt_copyright = false ]; then
|
||||||
|
b=$(echo -e "Do you want to ${bold}erase Artist and Copyright data${reset} ? (k)eep or (e)rase ")
|
||||||
|
read -r -p "$b" choice
|
||||||
|
|
||||||
|
if [ "$choice" == "e" ] || [ "$choice" == "E" ]; then
|
||||||
|
echo "Erasing Artist and Copyright data..."
|
||||||
|
#a="-EXIF:Artist= -IPTC:By-line= -XMP:Creator="
|
||||||
|
#c="-EXIF:Copyright= -IPTC:CopyrightNotice= -XMP:Rights="
|
||||||
|
exiftool -EXIF:Artist= -IPTC:By-line= -XMP:Creator= -EXIF:Copyright= -IPTC:CopyrightNotice= -XMP:Rights= "$file"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# keywords
|
||||||
|
k=$(echo "$exif" | jq --compact-output --raw-output '.[] | .Keywords[]?' | tr "\n" "," | sed 's/\,$//')
|
||||||
|
#k=$(echo "$exif" | sed -n '/^Keywords/p' | awk -F":" '{print $2}' | sed 's/^ *//g')
|
||||||
|
|
||||||
|
if [ -z "$k" ]; then
|
||||||
|
echo -e "\n${bold}${red}No Keywords found !${reset}"
|
||||||
|
echo
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
IFS="," read -r -a key <<< "$k"
|
||||||
|
|
||||||
|
|
||||||
|
for i in "${key[@]}"
|
||||||
|
do
|
||||||
|
#echo "@$i@"
|
||||||
|
# @ bouton d'or@
|
||||||
|
# xargs: unterminated quote
|
||||||
|
|
||||||
|
ii="$i"
|
||||||
|
trim ii
|
||||||
|
|
||||||
|
if [[ ! "$ii" =~ ^_ ]]; then
|
||||||
|
|
||||||
|
if [[ ${dico["$ii"]} ]] ; then
|
||||||
|
k_en=${dico["$ii"]}
|
||||||
|
else
|
||||||
|
k_en=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
k_fr="$ii"
|
||||||
|
|
||||||
|
if [ -n "$k_en" ]; then
|
||||||
|
[[ "$k_fr" = *" "* ]] && keyword_flickr+="\"${k_fr}\" " || keyword_flickr+="${k_fr} "
|
||||||
|
[[ "$k_en" = *" "* ]] && keyword_flickr+="\"${k_en}\" " || keyword_flickr+="${k_en} "
|
||||||
|
keyword_insta+="#${k_fr// /} #${k_en// /} "
|
||||||
|
[[ "$k_fr" = *" "* ]] && keyword_ccpx+="${k_fr}," || keyword_ccpx+="${k_fr},"
|
||||||
|
[[ "$k_en" = *" "* ]] && keyword_ccpx+="${k_en}," || keyword_ccpx+="${k_en},"
|
||||||
|
else
|
||||||
|
[[ "$k_fr" = *" "* ]] && keyword_flickr+="\"${k_fr}\" " || keyword_flickr+="${k_fr} "
|
||||||
|
[[ "$k_fr" = *" "* ]] && keyword_ccpx+="${k_fr}," || keyword_ccpx+="${k_fr},"
|
||||||
|
keyword_insta+="#${k_fr// /} "
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
# model
|
||||||
|
# Canon EOS R6 Canon EOS 5D Mark III Canon EOS-1D Mark IV Canon EOS 20D
|
||||||
|
#m=$(echo "$exif" | sed -n '/^Model/p' | awk -F":" '{print $2}' | xargs)
|
||||||
|
#mod=("${m}") # Canon EOS R6
|
||||||
|
|
||||||
|
# "Make": "OM Digital Solutions",
|
||||||
|
# "Model": "OM-5", "OM-1"
|
||||||
|
# "Make": "SONY",
|
||||||
|
# "Model": "ILCE-7M3", "ILCE-7M4"
|
||||||
|
# "Make": "FUJIFILM",
|
||||||
|
# "Model": "X-T5",
|
||||||
|
# "Make": "Panasonic",
|
||||||
|
# "Model": "DC-S5",
|
||||||
|
|
||||||
|
# "Make": "LEICA CAMERA AG",
|
||||||
|
# "Model": "LEICA Q3", "LEICA SL2-S"
|
||||||
|
# "Make": "NIKON CORPORATION",
|
||||||
|
# "Model": "NIKON D850",
|
||||||
|
# "Make": "NIKON CORPORATION",
|
||||||
|
# "Model": "NIKON Z 9",
|
||||||
|
# "Make": "Canon",
|
||||||
|
# "Model": "Canon EOS R7",
|
||||||
|
|
||||||
|
if [[ "$make" =~ ^Panasonic ]] || [[ "$make" =~ ^FUJI ]]; then
|
||||||
|
mod=("${make} ${model}")
|
||||||
|
mod+=("${make}")
|
||||||
|
mod+=("${model}")
|
||||||
|
mod+=("${make,,}photography")
|
||||||
|
elif [[ "$make" =~ ^SONY ]]; then
|
||||||
|
mod=("${make} ${model}")
|
||||||
|
mod+=("${make}")
|
||||||
|
mod+=("${model}")
|
||||||
|
# convertir α en Alpha
|
||||||
|
q=$(echo "${alpha_name}" | sed 's/α/Alpha /')
|
||||||
|
mod+=("$q")
|
||||||
|
mod+=("${make,,}photography")
|
||||||
|
elif [[ "$make" =~ ^"OM Digital Solutions" ]]; then
|
||||||
|
mod=("${make} ${model}") # OM Digital Solutions OM-5
|
||||||
|
mod+=("Olympus") # Olympus
|
||||||
|
mod+=("${model}") # OM-5
|
||||||
|
elif [[ "$model" =~ ^NIKON ]] || [[ "$model" =~ ^LEICA ]]; then
|
||||||
|
mod=("${make}")
|
||||||
|
z=$(echo "${make,,}" | awk '{print $1}') ## nikon
|
||||||
|
y=$(echo "${make}" | awk '{print $1}') ## NIKON
|
||||||
|
mod+=("${z}photography") # nikonphotography leicaphotography
|
||||||
|
mod+=("${y}") # NIKON LEICA
|
||||||
|
mod+=("${model}") # NIKON Z 9 LEICA Q3
|
||||||
|
w=$(echo "${model}" | awk '{$1=""; print $0}' | xargs)
|
||||||
|
mod+=("${w}")
|
||||||
|
elif [[ "$model" =~ ^Canon ]]; then
|
||||||
|
mod+=("Canon")
|
||||||
|
mod+=("${make,}photography")
|
||||||
|
[[ "$model" = *EOS* ]] || mod+=("EOS") # EOS
|
||||||
|
z=$(echo "$model" | sed 's/Canon\ //g' | xargs)
|
||||||
|
y=$(echo "$model" | sed 's/EOS//g' | sed 's/[ ][ ]*/ /g' | xargs)
|
||||||
|
mod+=("${z}") # EOS R6
|
||||||
|
mod+=("${y}") # Canon R6
|
||||||
|
fi
|
||||||
|
|
||||||
|
for i in "${mod[@]}"
|
||||||
|
do
|
||||||
|
if [[ "$i" = *" "* ]]; then
|
||||||
|
model_flickr+="\"${i}\" "
|
||||||
|
else
|
||||||
|
model_flickr+="${i} "
|
||||||
|
fi
|
||||||
|
model_ccpx+="${i},"
|
||||||
|
model_insta+="#${i// /} " # supprime tous les espaces et ajoute le #
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
#lens
|
||||||
|
|
||||||
|
# "LensModel": "E 28-200mm F2.8-5.6 A071",
|
||||||
|
# "Lens": "E 28-200mm F2.8-5.6 A071",
|
||||||
|
# "LensID": "Tamron 28-200mm F2.8-5.6 Di III RXD",
|
||||||
|
# "LensModel": "FE 35mm F2.8 ZA",
|
||||||
|
# "Lens": "FE 35mm F2.8 ZA",
|
||||||
|
# "LensID": "FE 35mm F2.8 ZA"
|
||||||
|
|
||||||
|
# LensID": "OLYMPUS M.12-45mm F4.0"
|
||||||
|
# "LensModel": "OLYMPUS M.12-45mm F4.0",
|
||||||
|
# "Lens": "OLYMPUS M.12-45mm F4.0",
|
||||||
|
# "LensModel": "OLYMPUS M.300mm F4.0",
|
||||||
|
# "Lens": "OLYMPUS M.300mm F4.0",
|
||||||
|
# "LensID": "OLYMPUS M.300mm F4.0"
|
||||||
|
|
||||||
|
# "Lens": "OLYMPUS M.300mm F4.0", "Lens": "OLYMPUS M.12-45mm F4.0",
|
||||||
|
# "LensModel": "OLYMPUS M.300mm F4.0", "LensModel": "OLYMPUS M.12-45mm F4.0",
|
||||||
|
|
||||||
|
# Leica no Lens no LensID
|
||||||
|
# "LensModel": "SUMMILUX 1:1.7/28 ASPH.", "Leica APO-Summicron-SL 35mm f/2 ASPH",
|
||||||
|
|
||||||
|
# "LensModel": "Leica APO-Summicron-SL 35mm f/2 ASPH",
|
||||||
|
# "Lens": "Leica APO-Summicron-SL 35mm f/2 ASPH",
|
||||||
|
# "LensID": "Leica APO-Summicron-SL 35mm f/2 ASPH"
|
||||||
|
|
||||||
|
# "Lens": "Fujifilm Fujinon XF18mmF1.4 R LM WR",
|
||||||
|
# "LensModel": "Fujifilm Fujinon XF18mmF1.4 R LM WR",
|
||||||
|
# LensID": "LUMIX S 20-60mm F3.5-5.6"
|
||||||
|
|
||||||
|
# "Lens": "LUMIX S 20-60/F3.5-5.6",
|
||||||
|
# "LensModel": "LUMIX S 20-60/F3.5-5.6",
|
||||||
|
# "LensID": "Fujifilm Fujinon XF18mm F1.4 R LM WR"
|
||||||
|
|
||||||
|
# "Lens": "400mm f/2.8",
|
||||||
|
# "LensID": "AF-S VR Nikkor 400mm f/2.8G ED",
|
||||||
|
# Nikon si LensModel vide => LensID
|
||||||
|
|
||||||
|
# "LensModel": "VR 300mm f/2.8G",
|
||||||
|
# "Lens": "300.0 mm f/2.8",
|
||||||
|
# "LensID": "VR 300mm f/2.8G"
|
||||||
|
|
||||||
|
# "LensModel": "EF600mm f/4L IS III USM",
|
||||||
|
# "LensID": "Canon EF 600mm f/4L IS III USM"
|
||||||
|
# "Lens": "EF600mm f/4L IS III USM",
|
||||||
|
|
||||||
|
# 1 LensID puis 2 LendModel
|
||||||
|
|
||||||
|
|
||||||
|
lens_flickr="\"${l}\" "
|
||||||
|
lens_insta="$(echo "$l" | sed 's/ //g' | sed -r 's/[^ ]+/#&/g') "
|
||||||
|
lens_ccpx+="${l},"
|
||||||
|
|
||||||
|
|
||||||
|
for i in "${wild[@]}"
|
||||||
|
do
|
||||||
|
if [[ "$i" = *" "* ]]; then
|
||||||
|
wildlife_flickr+="\"${i}\" "
|
||||||
|
else
|
||||||
|
wildlife_flickr+="${i} "
|
||||||
|
fi
|
||||||
|
wildlife_ccpx+="${i},"
|
||||||
|
wildlife_insta+="#$(echo "${i}" | iconv -s -f UTF-8-MAC -t ascii//translit | sed 's/[^a-zA-Z 0-9]//g' | sed 's/ //g') "
|
||||||
|
done
|
||||||
|
|
||||||
|
for i in "${nat[@]}"
|
||||||
|
do
|
||||||
|
if [[ "$i" = *" "* ]]; then
|
||||||
|
nature_flickr+="\"${i}\" "
|
||||||
|
else
|
||||||
|
nature_flickr+="${i} "
|
||||||
|
fi
|
||||||
|
nature_ccpx+="${i},"
|
||||||
|
nature_insta+="#$(echo "${i}" | iconv -s -f UTF-8-MAC -t ascii//translit | sed 's/[^a-zA-Z 0-9]//g' | sed 's/ //g') "
|
||||||
|
done
|
||||||
|
|
||||||
|
for i in "${reg[@]}"
|
||||||
|
do
|
||||||
|
if [[ "$i" = *" "* ]]; then
|
||||||
|
region_flickr+="\"${i}\" "
|
||||||
|
else
|
||||||
|
region_flickr+="${i} "
|
||||||
|
fi
|
||||||
|
region_ccpx+="${i},"
|
||||||
|
region_insta+="#$(echo "${i}" | iconv -s -f UTF-8-MAC -t ascii//translit | sed 's/[^a-zA-Z 0-9]//g' | sed 's/ //g') "
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
if [ $opt_all = false ]; then
|
||||||
|
|
||||||
|
if [ $opt_wildlife = false ]; then
|
||||||
|
wildlife_flickr=""
|
||||||
|
wildlife_insta=""
|
||||||
|
wildlife_ccpx=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $opt_nature = false ]; then
|
||||||
|
nature_flickr=""
|
||||||
|
nature_insta=""
|
||||||
|
nature_ccpx=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $opt_region = false ]; then
|
||||||
|
region_flickr=""
|
||||||
|
region_insta=""
|
||||||
|
region_ccpx=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $opt_lens = false ]; then
|
||||||
|
lens_flickr=""
|
||||||
|
lens_insta=""
|
||||||
|
lens_ccpx=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $opt_model = false ]; then
|
||||||
|
model_flickr=""
|
||||||
|
model_insta=""
|
||||||
|
model_ccpx=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
keywords_flickr="$keyword_flickr$model_flickr$lens_flickr$wildlife_flickr$nature_flickr$region_flickr"
|
||||||
|
keywords_ccpx="$keyword_ccpx$model_ccpx$lens_ccpx$wildlife_ccpx$nature_ccpx$region_ccpx"
|
||||||
|
keywords_insta=$(echo "$keyword_insta$model_insta$lens_insta$wildlife_insta$nature_insta$region_insta" | awk '{print tolower($0)}')
|
||||||
|
|
||||||
|
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 [[ ${dico["$i"]} ]] ; then
|
||||||
|
o_en=${dico["$i"]}
|
||||||
|
else
|
||||||
|
o_en=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
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// /} "
|
||||||
|
[[ "$i" = *" "* ]] && others_ccpx+="${i}," || others_ccpx+="${i},"
|
||||||
|
[[ "$o_en" = *" "* ]] && others_ccpx+="${o_en}," || others_ccpx+="${o_en},"
|
||||||
|
else
|
||||||
|
[[ "$i" = *" "* ]] && others_flickr+="\"${i}\" " || others_flickr+="${i} "
|
||||||
|
[[ "$i" = *" "* ]] && others_ccpx+="${i}," || others_ccpx+="${i},"
|
||||||
|
others_insta+="#${i// /} "
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
keywords_flickr+="$others_flickr"
|
||||||
|
keywords_insta+="$others_insta"
|
||||||
|
keywords_ccpx+="${others_ccpx:0:-1}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
if ! command -v iconv &> /dev/null; then
|
||||||
|
echo -e "\n${bold}iconv${reset} could not be found !\n"
|
||||||
|
echo -e "It's required for suppress accents."
|
||||||
|
echo -e "You should install ${bold}icon${reset}:"
|
||||||
|
echo -e " - brew install iconv"
|
||||||
|
echo -e ""
|
||||||
|
else
|
||||||
|
###
|
||||||
|
keywords_insta=$(echo "$keywords_insta" | iconv -s -f UTF-8-MAC -t ascii//translit | sed 's/[^a-zA-Z 0-9 \#]//g')
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# suppress duplicates (gawk)
|
||||||
|
if ! command -v gawk &> /dev/null; then
|
||||||
|
echo -e "\n${bold}gawk${reset} could not be found !\n"
|
||||||
|
echo -e "It's required for suppress duplicates."
|
||||||
|
echo -e "You should install ${bold}gawk${reset}:"
|
||||||
|
echo -e " - brew install gawk"
|
||||||
|
echo -e ""
|
||||||
|
else
|
||||||
|
keywords_insta=$(echo "$keywords_insta" | gawk -v RS="[ \n]" -v ORS=" " '!($0 in a){print;a[$0]}')
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# copy tags to clipboard
|
||||||
|
|
||||||
|
if [ "$insta" = true ]; then
|
||||||
|
|
||||||
|
if [[ "$OSTYPE" == "linux-gnu" ]] && [ -x "$(command -v xsel)" ]; then
|
||||||
|
xsel -b <<< "$keywords_insta"
|
||||||
|
elif [[ "$OSTYPE" == "darwin"* ]] && [ -x "$(command -v pbcopy)" ]; then
|
||||||
|
pbcopy <<< "$keywords_insta"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "\n${bold}The Instagram's tags are available in your clipboard !${reset}"
|
||||||
|
echo "$keywords_insta"
|
||||||
|
|
||||||
|
[ "$flickr" = true ] || [ "$ccpx" = true ] && echo -e "\nPress <Enter> to get the Flickr's or the 500px's tags..." && read -r -p ""
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$flickr" = true ]; then
|
||||||
|
if [[ "$OSTYPE" == "linux-gnu" ]] && [ -x "$(command -v xsel)" ]; then
|
||||||
|
xsel -b <<< "$keywords_flickr"
|
||||||
|
elif [[ "$OSTYPE" == "darwin"* ]] && [ -x "$(command -v pbcopy)" ]; then
|
||||||
|
pbcopy <<< "$keywords_flickr"
|
||||||
|
fi
|
||||||
|
|
||||||
|
[ "$insta" = true ] && echo -e "\n${bold}Here the Flickr's tags too !${reset}" || echo -e "\n${bold}The Flickr's tags are available in your clipboard !${reset}"
|
||||||
|
echo "$keywords_flickr"
|
||||||
|
|
||||||
|
[ "$ccpx" = true ] && echo -e "\nPress <Enter> to get the 500px's tags..." && read -r -p ""
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$ccpx" = true ]; then
|
||||||
|
if [[ "$OSTYPE" == "linux-gnu" ]] && [ -x "$(command -v xsel)" ]; then
|
||||||
|
xsel -b <<< "$keywords_ccpx"
|
||||||
|
elif [[ "$OSTYPE" == "darwin"* ]] && [ -x "$(command -v pbcopy)" ]; then
|
||||||
|
pbcopy <<< "$keywords_ccpx"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#[ "$insta" = true ] && echo -e "\n${bold}Here the Flickr's tags too !${reset}" || echo -e "\n${bold}The Flickr's tags are available in your clipboard !${reset}"
|
||||||
|
[ "$insta" = true ] || [ "$flickr" = true ] && echo -e "\n${bold}Here the 500px's tags too !${reset}" || echo -e "\n${bold}The 500px's tags are available in your clipboard !${reset}"
|
||||||
|
|
||||||
|
echo "$keywords_ccpx"
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user