From 36418c57b348dfc31f3569742af5493603bae5ee Mon Sep 17 00:00:00 2001 From: Christian Quest Date: Sun, 18 Jun 2023 15:51:50 +0200 Subject: [PATCH] download-collection script --- scripts/README.md | 9 +++++++++ scripts/download-collection | 25 +++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100755 scripts/download-collection diff --git a/scripts/README.md b/scripts/README.md index 6793c2f..106197a 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -8,3 +8,12 @@ Usage: ./blurdir directory-path Will create a "blur" directory in the original directory to store the blurred version of the pictures with the same name as original pictures. +## download-collection + +Downloads all pictures in a sequence/collection + +Usage: ./download-collection collection-url + +Exemple: ./download-collection https://panoramax.openstreetmap.fr/api/collections/90d9c033-bfc2-411c-9769-622dfb0e7431 + +A directory is created to store the pictures, named with the timestamp of the first picture in the sequence and pictures are named with their timestamp, diff --git a/scripts/download-collection b/scripts/download-collection new file mode 100755 index 0000000..dd401f9 --- /dev/null +++ b/scripts/download-collection @@ -0,0 +1,25 @@ +#! /bin/bash + +IFS=$'\n' + +mkdir -p $(basename $1) +cd $(basename $1) + +JSON=collection.json + +echo "Retrieving collection items list" +curl -sl $1/items > $JSON +echo "$(jq .features[].properties.datetime $JSON | wc -l) pictures to download" +for P in $(jq .features[] $JSON -c) +do + URL=$(echo $P | jq .assets.hd.href -r) + TS=$(echo $P | jq .properties.datetime -r) + curl -sl $URL > tmp.jpg + mv tmp.jpg $TS.jpg + echo -n '.' +done +echo "" +cd ..; mv $(basename $1) $(jq -r .features[0].properties.datetime $(basename $1)/$JSON) +echo 'Done' + +