From d4fc7d34717e01987aa2920a13f35a2bed4968a3 Mon Sep 17 00:00:00 2001 From: localhost_frssoft Date: Tue, 31 Dec 2024 09:57:06 +0300 Subject: [PATCH] more accurate output --- when_my_bus.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/when_my_bus.sh b/when_my_bus.sh index f353d18..9c2c126 100755 --- a/when_my_bus.sh +++ b/when_my_bus.sh @@ -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"