Advertisement
kolbka_

Untitled

Mar 15th, 2022
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.25 KB | None | 0 0
  1. #!/usr/bin/env bash
  2. if [ $# -eq 0 ]; then
  3.   cur_data=$(date --date=$(date -I) '+%s')
  4. else
  5.   date_=$(echo "$1" | cut -d . -f 3)
  6.   date_="$(echo "$1" | cut -d . -f 3)-$(echo "$1" | cut -d . -f 2)-$(echo "$1" | cut -d . -f 1)"
  7.   echo $date_
  8.   cur_data=$(date --date="$date_" '+%s')
  9. fi
  10. next_day=$((cur_data + 86400 - 1))
  11. echo $cur_data
  12. echo $next_day
  13.  
  14. cnt=1
  15. flag=1
  16. while (($flag == 1)); do
  17. a=$(GET "https://kudago.com/public-api/v1.4/events/?&expand=object&order_by=&ids=&location=spb&fields=dates,title,id&actual_since=$cur_data&page=$cnt" | jq '.results[].id')
  18. #echo "$a"
  19.  
  20. echo "$a" | while read -r id; do
  21. #  (GET "https://kudago.com/public-api/v1.4/events/$id/?lang=&fields=&expand=") | jq '.dates[]'
  22.   JSON=$(GET "https://kudago.com/public-api/v1.4/events/$id/?lang=&fields=&expand=")
  23.   math=$(echo "$JSON" | jq ".dates[] | select(.start <= $next_day and .end >= $cur_data)")
  24.   if [ "$math" ]; then
  25. #    echo "$JSON" | jq -r ".dates[]"
  26. #    echo $math
  27.     echo "$JSON" | jq -r ".title"
  28.     fi
  29.   done
  30.  
  31.   if (GET "https://kudago.com/public-api/v1.4/events/?&expand=object&order_by=&ids=&location=spb&fields=dates,title,id&actual_since=$cur_data&page=$cnt"|jq -e '.next == null' >>/dev/null); then
  32.     flag=0
  33.   else
  34.     cnt=$((cnt + 1))
  35.     fi
  36. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement