relative time
This commit is contained in:
parent
5d42dd2d72
commit
61f05f9d1e
|
@ -5,7 +5,16 @@ selected_station=$(cat stations.json | jq -r '.[] | "\(.station_id | tostring) \
|
||||||
fetch_buses_from_station() {
|
fetch_buses_from_station() {
|
||||||
echo "Nearest buses from station $1:"
|
echo "Nearest buses from station $1:"
|
||||||
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)\ngeo:\(.lat),\(.lng)?z=18"'
|
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)\ngeo:\(.lat),\(.lng)?z=18"'
|
||||||
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
|
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 | awk -F' ' '{
|
||||||
|
cmd = "date -d " $1 " +%s"
|
||||||
|
cmd | getline future_time
|
||||||
|
close(cmd)
|
||||||
|
cmd = "date +%s"
|
||||||
|
cmd | getline current_time
|
||||||
|
close(cmd)
|
||||||
|
diff = (future_time - current_time) / 60
|
||||||
|
printf "%s min " "%s %s %s\n", diff, $2, $3, $4
|
||||||
|
}'
|
||||||
}
|
}
|
||||||
export -f fetch_buses_from_station
|
export -f fetch_buses_from_station
|
||||||
watch --interval 15 -x bash -c "fetch_buses_from_station $selected_station"
|
watch --interval 15 -x bash -c "fetch_buses_from_station $selected_station"
|
||||||
|
|
Loading…
Reference in a new issue