more accurate output

This commit is contained in:
localhost_frssoft 2024-12-31 09:57:06 +03:00
parent bb7048151f
commit d4fc7d3471

View file

@ -4,7 +4,8 @@ selected_station=$(cat stations.json | jq -r '.[] | "\(.station_id | tostring) \
fetch_buses_from_station() {
echo "Nearest buses from station $1:"
curl -s -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:127.0) Gecko/20100101 Firefox/127.0' --compressed "https://api.merlin.tvercard.ru/api/client/v1/stations/$1/schedules/nearest?nearest_vehicle_amount=10" | jq .
cat stations.json | jq -r --arg id $1 'map(select(.station_id == ($id | tonumber))) | .[0] | "https://www.openstreetmap.org/?mlat=\(.lat)&mlon=\(.lng)#map=18/\(.lat)/\(.lng)"'
curl -s -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:127.0) Gecko/20100101 Firefox/127.0' --compressed "https://api.merlin.tvercard.ru/api/client/v1/stations/$1/schedules/nearest?nearest_vehicle_amount=3" | jq -r '.[] | "\(.vehicle_arrival_time[].arrival_time) \(.vehicle_arrival_time[].arrival_time_comment) <- \(.route.name) \(.route.comment)"' | sort | uniq
}
export -f fetch_buses_from_station
watch --interval 5 -x bash -c "fetch_buses_from_station $selected_station"
watch --interval 15 -x bash -c "fetch_buses_from_station $selected_station"