How to download multiple images from the camera at once

@Jqck I will try to simplify the script. Please let me know if you still need help. The script below assumes Bash on Ubuntu, not Fish or Windows.

Install Required Programs

sudo apt-get install curl jq --yes

Set Auth Info

Be sure to replace YOUR_EMAIL and YOUR_PASSWORD with appropriate values.

TOKEN=`curl -H "Content-Type: application/json" \
     -X POST \
     -d '{"user":{"email":"YOUR_EMAIL","password":"YOUR_PASSWORD"}}' \
     https://my.farm.bot/api/tokens | jq ".token.encoded" --raw-output`

Run Script in Download Directory

curl -H "Authorization: Bearer ${TOKEN}" https://my.farm.bot/api/images | jq 'map(.attachment_url)' | jq -r '.[]'

IMAGES=`curl -H "Authorization: Bearer ${TOKEN}" https://my.farm.bot/api/images | jq 'map(.attachment_url)' | jq -r '.[]'`

for url in $IMAGES; do
  curl ${url} --remote-name;
done

Done

You should see a bunch of JPG images in whatever directory you ran the command in.

1 Like