Commit d8c9e14d authored by Dmitri Popov's avatar Dmitri Popov

Fix geotagging, add getopt

parent 2eca18b5
......@@ -4,11 +4,11 @@
# License: GPLv3 https://www.gnu.org/licenses/gpl-3.0.txt
# Source code: https://gitlab.com/dmpop/momo
# opkg install bc jq curl rsync perl-image-exiftool
# opkg install getopt bc jq curl perl-image-exiftool
# Check whether the required packages are installed
if [ ! -x "$(command -v bc)" ] || [ ! -x "$(command -v jq)" ] || [ ! -x "$(command -v curl)" ] || [ ! -x "$(command -v exiftool)" ]; then
echo "Make sure that the following tools are installed on your system: bc, jq, curl, exiftool"
if [ ! -x "$(command -v getopt)" ] || [ ! -x "$(command -v bc)" ] || [ ! -x "$(command -v jq)" ] || [ ! -x "$(command -v curl)" ] || [ ! -x "$(command -v exiftool)" ]; then
echo "Make sure that the following tools are installed on your system: getopt, bc, jq, curl, exiftool"
exit 1
fi
......@@ -105,6 +105,7 @@ for line in $(seq 1 $lines)
echo "$file"
cp "$file" "$target"
done
cd "$target"
if [ ! -z "$location" ]; then
......@@ -124,6 +125,7 @@ if [ ! -z "$location" ]; then
fi
fi
if [ ! -z "$location" ]; then
echo
echo "--------------"
echo "Geotagging ..."
......@@ -135,7 +137,8 @@ fi
do
file=$(echo -e "$results" | sed -n "$line p")
exiftool -overwrite_original -GPSLatitude=$lat -GPSLatitudeRef=$latref -GPSLongitude=$lon -GPSLongitudeRef=$lonref "$file"
done
done
fi
# Check whether the Dark Sky API is reachable
check2=$(wget -q --spider https://api.darksky.net/)
......@@ -157,7 +160,7 @@ check2=$(wget -q --spider https://api.darksky.net/)
curl -k "https://api.darksky.net/forecast/"$api_key"/"$lat","$lon","$t"?units=si&exclude=currently,hourly,flags" > "$json"
w_sum=$(jq '.daily | .data | .[0] | .summary' "$json" | tr -d '"')
w_temp=$(jq '.daily | .data | .[0] | .temperatureHigh' "$json" | tr -d '"')
exiftool -overwrite_original -copyright="$copyright" -comment="$camera, $lens, $w_temp°C, $w_sum" "$file"
exiftool -overwrite_original -copyright="$copyright" -comment="$camera, $lens, $w_temp°C, $w_sum" "$file" -ext JPG
done
else
echo
......@@ -172,14 +175,17 @@ echo "--------------------------"
echo "Renaming and organizing..."
echo "--------------------------"
echo
exiftool -r -d %Y%m%d-%H%M%S%%-c.%%e '-FileName<DateTimeOriginal' "$target"
exiftool -r '-Directory<CreateDate' -d ./%Y-%m-%d "$target"
exiftool -d %Y%m%d-%H%M%S%%-c.%%e '-FileName<DateTimeOriginal' "$target"
exiftool '-Directory<CreateDate' -d ./%Y-%m-%d "$target"
if [ -f "$json" ]; then
rm "$json"
fi
cd
find "$target" -type d -exec chmod 755 {} \;
if [ ! -z "$notify_token" ]; then
curl -k \
"https://us-central1-notify-b7652.cloudfunctions.net/sendNotification?to=${notify_token}&text=Momo%20is%20done!" \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment