diff --git a/prog/download.sh b/prog/download.sh deleted file mode 100755 index 617fa15d6cb48b289dbe0aa2dda53c5e2590b9de..0000000000000000000000000000000000000000 --- a/prog/download.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/bash - -pwd - -mkdir -p data/realtime -mkdir -p fail/realtime -mkdir -p tmp/realtime - -while true -do - sleep $(bc <<< "10 - $(date +%S.%N) % 10") - datetime="$(date '+%Y-%m-%d--%H-%M-%S')" - ymd=${datetime:0:10} - hms=${datetime:12} - h=${hms:0:2} - ms=${hms:3} - dir=$ymd/$h/$ms - timestamp="$(date '+%s')" - ( - limit=10000 - from=0 - to=$limit - from_to=$(printf "%05d" $from)--$(printf "%05d" $to) - file=$from_to.json.gz - echo start $datetime $file - mkdir tmp/realtime/$datetime - curl -X 'GET' "https://api.golemio.cz/v2/vehiclepositions?limit=$limit&offset=$from&includeNotTracking=true&includePositions=false&preferredTimezone=Europe/Prague" -H 'accept: application/json' -H "X-Access-Token: $(cat golemio_key)" --silent --fail | gzip -8 > tmp/realtime/$datetime/$file - curl_code="${PIPESTATUS[0]}" - timestamp_end="$(date '+%s')" - timestamp_diff=$((timestamp_end - timestamp)) - if [[ "$curl_code" != 0 ]] - then - echo FAIL $datetime $file in $timestamp_diff s returned $curl_code - cat tmp/realtime/$datetime/$file | gzip -d | head -c 100 - mv tmp/realtime/$datetime fail/realtime/$file--$curl_code - else - if [[ $timestamp_diff -gt 10 ]] - then - echo TOO LATE $file in $timestamp_diff s - cat tmp/realtime/$datetime/$file | gzip -d | head -c 100 - mv tmp/realtime/$datetime fail/realtime/$datetime--to-late - else - mkdir -p data/realtime/$ymd/$h - mv tmp/realtime/$datetime data/realtime/$dir - echo done $datetime $file in $timestamp_diff s - fi - fi - )& - sleep 5 -done