#!/usr/bash

for (( i=1; i<=$2; i++ ))
do
    uuidd=$(od -x /dev/urandom | head -1 | awk '{OFS="-"; print $2$3,$4,$5,$6,$7$8$9}')
    guid="{\"guid\":\"$uuidd\"}"
    
    authCurl=$(curl -x $1 'https://t.api.viewevo.net/auth/login/guid' \
    -X POST \
    -H 'Host: t.api.viewevo.net' \
    -H 'X-ViewEvo-Device-Type: iOS' \
    -H 'Connection: keep-alive' \
    -H 'Accept: application/json' \
    -H 'User-Agent: ViewEvo / ios /' \
    -H 'Accept-Language: ru-US;q=1.0' \
    -H 'Content-Length: 47' \
    -H 'Content-Type: application/json' \
    -d $guid | python3 -c "import sys, json; print(json.load(sys.stdin)['token'])")

    auth=$(echo  "Authorization: bearer" $authCurl )

    curl -x $1 'https://t.api.viewevo.net/config?lang=ru' \
    -H 'Host: t.api.viewevo.net' \
    -H 'Connection: keep-alive' \
    -H 'X-ViewEvo-Device-Type: iOS' \
    -H 'Accept: application/json' \
    -H 'User-Agent: ViewEvo / ios /' \
    -H "$auth" \
    -H 'Accept-Language: ru-US;q=1.0' > out.json
    sleep $3
done
