get station names once only once
This commit is contained in:
parent
2637fc3e8f
commit
fbfad98020
32
departure.sh
32
departure.sh
|
@ -133,6 +133,25 @@ append_five_line_symbol()
|
|||
esac
|
||||
}
|
||||
|
||||
get_cvag_station_name()
|
||||
{
|
||||
local -n _STANAME=$1
|
||||
local -n _STATIONS=$2
|
||||
|
||||
FOO=$(curl --connect-timeout 5 -s "http://www.cvag.de/eza/mis/stations?minLat=0&maxLat=100&minLon=0&maxLon=100")
|
||||
for ((i=0; i<${#_STATIONS[*]}; i++)); do
|
||||
case ${_STATIONS[$i]} in
|
||||
''|*[!0-9]*)
|
||||
_STANAME[$i]=$(echo -n "$FOO" | jq -r '.stations | .[] | select(.displayName | contains("'"${_STATIONS[$i]}"'")) | .number')
|
||||
;;
|
||||
|
||||
*)
|
||||
_STANAME[$i]=$(echo -n "$FOO" | jq -r '.stations | .[] | select(.number | contains('"${_STATIONS[$i]}"')) | .displayName')
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
while true; do
|
||||
if ! ping -q -c1 chch.it>/dev/null; then
|
||||
echo -e "\\n\\n\\n\\tNo internet connection!"
|
||||
|
@ -148,18 +167,7 @@ while true; do
|
|||
|
||||
LOGO_TIME=("${CHCHLOGO_S[@]}")
|
||||
|
||||
FOO=$(curl --connect-timeout 5 -s "http://www.cvag.de/eza/mis/stations?minLat=0&maxLat=100&minLon=0&maxLon=100")
|
||||
for ((i=0; i<${#STATIONS[*]}; i++)); do
|
||||
case ${STATIONS[$i]} in
|
||||
''|*[!0-9]*)
|
||||
STANAME[$i]=$(echo -n "$FOO" | jq -r '.stations | .[] | select(.displayName | contains("'"${STATIONS[$i]}"'")) | .number')
|
||||
;;
|
||||
|
||||
*)
|
||||
STANAME[$i]=$(echo -n "$FOO" | jq -r '.stations | .[] | select(.number | contains('"${STATIONS[$i]}"')) | .displayName')
|
||||
;;
|
||||
esac
|
||||
done
|
||||
[ ${#STANAME[@]} -eq 0 ] && get_cvag_station_name STANAME STATIONS
|
||||
|
||||
MYOUTPUT="\\n "
|
||||
|
||||
|
|
Loading…
Reference in New Issue