diff --git a/keywords2insta.sh b/keywords2insta.sh index fd5a544..e3388ee 100755 --- a/keywords2insta.sh +++ b/keywords2insta.sh @@ -42,6 +42,13 @@ long_path=`pwd`"/"`basename "$0"` # /Users/bruno/Documents/Scripts/kymsu2/keywor dir=$(dirname "$0") # /Users/bruno/Documents/Scripts/keywords2insta +dotenv () { + set -a + [ -f .env ] && . .env + set +a +} + +dotenv trim () { read -rd '' $1 <<<"${!1}" @@ -380,13 +387,13 @@ if [[ -n $iso ]] && [[ -n $speed ]] && [[ -n $aperture ]]; then if [ $width -gt $height ]; then wi=2400 he=1600 - [ $width -ne $wi ] && printf " %-11s %-35s \n" "Width:" "${red}${width}${reset}" || printf " %-11s %-35s \n" "Width:" "${width}" - [ $height -ne $he ] && printf " %-11s %-35s \n" "Height:" "${red}${height}${reset}" || printf " %-11s %-35s \n" "Height:" "${height}" + [ $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 %-35s \n" "Width:" "${red}${width}${reset}" || printf " %-11s %-35s \n" "Width:" "${width}" - [ $height -ne $he ] && printf " %-11s %-35s \n" "Height:" "${red}${height}${reset}" || printf " %-11s %-35s \n" "Height:" "${height}" + [ $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}" @@ -402,16 +409,18 @@ if [[ -n $iso ]] && [[ -n $speed ]] && [[ -n $aperture ]]; then lat=$(echo "$coords" | sed -n '1p' | awk -F":" '{print $2}' | xargs) long=$(echo "$coords" | sed -n '$p' | awk -F":" '{print $2}' | xargs) - gm=$(curl -s "https://maps.googleapis.com/maps/api/geocode/json?latlng=${lat},${long}&sensor=false&key=AIzaSyD94L2Q4K9_ErGSarTBN4FrUxDSspGzNhY" | 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') + 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 / Ville:" "${code//\"/} ${city//\"/}" - printf " %-11s %-35s \n" "Région:" "${state//\"/}" - printf " %-11s %-35s \n" "Pays:" "${country//\"/}" + printf " %-11s %-35s \n" "CP / Ville:" "${code//\"/} ${city//\"/}" + printf " %-11s %-35s \n" "Région:" "${state//\"/}" + printf " %-11s %-35s \n" "Pays:" "${country//\"/}" + fi fi echo