Add a .env
Feature: -the Googlemaps API KEY is now in a separate .env file Bugfix: -display l x h in red if image size smaller than 2400x1600
This commit is contained in:
@@ -42,6 +42,13 @@ long_path=`pwd`"/"`basename "$0"` # /Users/bruno/Documents/Scripts/kymsu2/keywor
|
|||||||
|
|
||||||
dir=$(dirname "$0") # /Users/bruno/Documents/Scripts/keywords2insta
|
dir=$(dirname "$0") # /Users/bruno/Documents/Scripts/keywords2insta
|
||||||
|
|
||||||
|
dotenv () {
|
||||||
|
set -a
|
||||||
|
[ -f .env ] && . .env
|
||||||
|
set +a
|
||||||
|
}
|
||||||
|
|
||||||
|
dotenv
|
||||||
|
|
||||||
trim () {
|
trim () {
|
||||||
read -rd '' $1 <<<"${!1}"
|
read -rd '' $1 <<<"${!1}"
|
||||||
@@ -380,13 +387,13 @@ if [[ -n $iso ]] && [[ -n $speed ]] && [[ -n $aperture ]]; then
|
|||||||
if [ $width -gt $height ]; then
|
if [ $width -gt $height ]; then
|
||||||
wi=2400
|
wi=2400
|
||||||
he=1600
|
he=1600
|
||||||
[ $width -ne $wi ] && printf " %-11s %-35s \n" "Width:" "${red}${width}${reset}" || printf " %-11s %-35s \n" "Width:" "${width}"
|
[ $width -ne $wi ] && printf " %-11s %-35b \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}"
|
[ $height -ne $he ] && printf " %-11s %-35b \n" "Height:" "${red}${height}${reset}" || printf " %-11s %-35s \n" "Height:" "${height}"
|
||||||
elif [ $height -gt $width ]; then
|
elif [ $height -gt $width ]; then
|
||||||
wi=1600
|
wi=1600
|
||||||
he=2400
|
he=2400
|
||||||
[ $width -ne $wi ] && printf " %-11s %-35s \n" "Width:" "${red}${width}${reset}" || printf " %-11s %-35s \n" "Width:" "${width}"
|
[ $width -ne $wi ] && printf " %-11s %-35b \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}"
|
[ $height -ne $he ] && printf " %-11s %-3b \n" "Height:" "${red}${height}${reset}" || printf " %-11s %-35s \n" "Height:" "${height}"
|
||||||
fi
|
fi
|
||||||
#printf " %-11s %-35s \n" "Width:" "${width}"
|
#printf " %-11s %-35s \n" "Width:" "${width}"
|
||||||
#printf " %-11s %-35s \n" "Height:" "${height}"
|
#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)
|
lat=$(echo "$coords" | sed -n '1p' | awk -F":" '{print $2}' | xargs)
|
||||||
long=$(echo "$coords" | sed -n '$p' | 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')
|
if [[ -n $GM_API_KEY ]]; then
|
||||||
city=$(echo "$gm" | jq '. | map( select( .types | contains(["locality"]) ) ) | .[].long_name')
|
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')
|
||||||
code=$(echo "$gm" | jq '. | map( select( .types | contains(["postal_code"]) ) ) | .[].long_name')
|
city=$(echo "$gm" | jq '. | map( select( .types | contains(["locality"]) ) ) | .[].long_name')
|
||||||
state=$(echo "$gm" | jq '. | map( select( .types | contains(["administrative_area_level_2"]) ) ) | .[].long_name')
|
code=$(echo "$gm" | jq '. | map( select( .types | contains(["postal_code"]) ) ) | .[].long_name')
|
||||||
region=$(echo "$gm" | jq '. | map( select( .types | contains(["administrative_area_level_1"]) ) ) | .[].long_name')
|
state=$(echo "$gm" | jq '. | map( select( .types | contains(["administrative_area_level_2"]) ) ) | .[].long_name')
|
||||||
country=$(echo "$gm" | jq '. | map( select( .types | contains(["country"]) ) ) | .[].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" "CP / Ville:" "${code//\"/} ${city//\"/}"
|
||||||
printf " %-11s %-35s \n" "Région:" "${state//\"/}"
|
printf " %-11s %-35s \n" "Région:" "${state//\"/}"
|
||||||
printf " %-11s %-35s \n" "Pays:" "${country//\"/}"
|
printf " %-11s %-35s \n" "Pays:" "${country//\"/}"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
echo
|
echo
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user