From: Cian Bagshaw Date: Tue, 6 Jun 2023 00:42:01 +0000 (+0100) Subject: Fixed quotes X-Git-Url: https://tests.cianb.xyz/?a=commitdiff_plain;h=dfa7b92e900687967b6049f98e2dfff1aa605e6d;p=buseir Fixed quotes --- diff --git a/buseir b/buseir index e72fd24..06c3f37 100755 --- a/buseir +++ b/buseir @@ -2,9 +2,9 @@ # Download Bus Eireann data to CSV file cache, and provide useful functions to # view data -SITE=https://buseireann.ie -CACHE=$XDG_CACHE_HOME/buseir -TMP=/tmp/buseir +SITE="https://buseireann.ie" +CACHE="$XDG_CACHE_HOME/buseir" +TMP="/tmp/buseir" menu() { fzf -m --reverse --height=12; } @@ -13,25 +13,24 @@ readCsv() { then cat "$1"; else echo "$2" | while read -r key do echo "\(\"\|^\|,\)$key\(\"\|$\|,\)" - done | grep -f - "$1" + done | grep -f - "$1" fi | cut -d, -f "$3" | tr -d \" } sync() { - echo Syncing data... - [ ! -d "$TMP" ] && mkdir -p "$TMP" - rm -f "$TMP"/* - wget -qP "$TMP" "$SITE" "$SITE"/inc/proto/bus_stop_points.php \ + echo "Syncing data..." + [ ! -d "$TMP" ] && mkdir -p "$TMP" || rm -rf "$TMP"/* + wget -qP "$TMP" "$SITE" "$SITE/inc/proto/bus_stop_points.php" \ || (echo "Connection failed!" && exit); xmllint --html --xpath \ - "//select[@id='form-fare-finder-service']/option/text()" "$TMP"/index.html 2>/dev/null \ - | sed 's/\s*:\s*/,/; /Select Service/d' > "$TMP"/routes.csv - readCsv "$TMP"/routes.csv all 1 | while read -r bus - do echo "$SITE"/inc/proto/fareDestinations.php?fare="$bus"; done \ + "//select[@id='form-fare-finder-service']/option/text()" "$TMP/index.html" 2>"/dev/null" \ + | sed 's/\s*:\s*/,/; /Select Service/d' > "$TMP/routes.csv" + readCsv "$TMP/routes.csv" all 1 | while read -r bus + do echo "$SITE/inc/proto/fareDestinations.php?fare=$bus"; done \ | wget -q -i - -O - | jq -r '[.fareDestinations[]|.name]|@csv' \ - | paste -d, "$TMP"/routes.csv - > "$CACHE"/routes.csv - grep -o "{.*}" "$TMP"/bus_stop_points.php \ - | jq -r '.bus_stops[]|[.name,.num,.duid,.lat,.lng]|@csv' > "$CACHE"/stops.csv + | paste -d, "$TMP/routes.csv" - > "$CACHE/routes.csv" + grep -o "{.*}" "$TMP/bus_stop_points.php" \ + | jq -r '.bus_stops[]|[.name,.num,.duid,.lat,.lng]|@csv' > "$CACHE/stops.csv" } stops() { @@ -39,7 +38,7 @@ stops() { all) COL=1-;; num) COL=2;; duid) COL=3;; pos) COL=4-5;; *) COL=1;; esac - readCsv "$CACHE"/stops.csv "$1" "$COL" + readCsv "$CACHE/stops.csv" "$1" "$COL" } printStop() {