projects
/
buseir
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
412241c
)
Fixed quotes
master
author
Cian Bagshaw
<cian@cianb.xyz>
Tue, 6 Jun 2023 00:42:01 +0000
(
01:42
+0100)
committer
Cian Bagshaw
<cian@cianb.xyz>
Tue, 6 Jun 2023 00:42:01 +0000
(
01:42
+0100)
buseir
patch
|
blob
|
history
diff --git
a/buseir
b/buseir
index
e72fd24
..
06c3f37
100755
(executable)
--- a/
buseir
+++ b/
buseir
@@
-2,9
+2,9
@@
# Download Bus Eireann data to CSV file cache, and provide useful functions to
# view data
# 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; }
menu() { fzf -m --reverse --height=12; }
@@
-13,25
+13,24
@@
readCsv() {
then cat "$1";
else echo "$2" | while read -r key
do echo "\(\"\|^\|,\)$key\(\"\|$\|,\)"
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() {
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 \
|| (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' \
| 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() {
}
stops() {
@@
-39,7
+38,7
@@
stops() {
all) COL=1-;; num) COL=2;; duid) COL=3;;
pos) COL=4-5;; *) COL=1;;
esac
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() {
}
printStop() {