Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- if [ $# -eq 0 ]; then
- cur_data=$(date --date=$(date -I) '+%s')
- else
- date_=$(echo "$1" | cut -d . -f 3)
- date_="$(echo "$1" | cut -d . -f 3)-$(echo "$1" | cut -d . -f 2)-$(echo "$1" | cut -d . -f 1)"
- echo $date_
- cur_data=$(date --date="$date_" '+%s')
- fi
- next_day=$((cur_data + 86400 - 1))
- echo $cur_data
- echo $next_day
- cnt=1
- flag=1
- while (($flag == 1)); do
- 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')
- #echo "$a"
- echo "$a" | while read -r id; do
- # (GET "https://kudago.com/public-api/v1.4/events/$id/?lang=&fields=&expand=") | jq '.dates[]'
- JSON=$(GET "https://kudago.com/public-api/v1.4/events/$id/?lang=&fields=&expand=")
- math=$(echo "$JSON" | jq ".dates[] | select(.start <= $next_day and .end >= $cur_data)")
- if [ "$math" ]; then
- # echo "$JSON" | jq -r ".dates[]"
- # echo $math
- echo "$JSON" | jq -r ".title"
- fi
- done
- 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
- flag=0
- else
- cnt=$((cnt + 1))
- fi
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement