From 783761806258bedb35366a7fc981904bbb7bc7f3 Mon Sep 17 00:00:00 2001 From: kx1t <15090643+kx1t@users.noreply.github.com> Date: Tue, 17 Dec 2024 04:40:28 -0500 Subject: [PATCH] Improve Canadian tail number lookups --- rootfs/usr/share/planefence/airlinename.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/rootfs/usr/share/planefence/airlinename.sh b/rootfs/usr/share/planefence/airlinename.sh index fd86100..7c9a9bd 100755 --- a/rootfs/usr/share/planefence/airlinename.sh +++ b/rootfs/usr/share/planefence/airlinename.sh @@ -85,6 +85,7 @@ CLEANUP_CACHE () # First, let's try to see if it's a regular airline by looking up the argument in our own database: a="$1" # get the flight number or tail number from the command line argument a="${a#@}" # strip off any leading "@" signs - this is a Planefence feature +a="${a^^}" # capitalize it if [[ -n "$2" ]]; then c="$2"; else c=""; fi # C is optional ICAO @@ -142,11 +143,8 @@ fi # If it's a Canadian tail number, let's use the Canadian lookup if [[ -z "$b" ]] && [[ "${a:0:1}" == "C" ]]; then - a_clean="$a" - if [[ "${a_clean:0:2}" == "CF" ]]; then a_clean="${a_clean:2}" - elif [[ "${a_clean:0:1}" == "C" ]]; then a_clean="${a_clean:1}" - fi - if [[ "${a_clean:0:1}" == "-" ]]; then a_clean="${a_clean:1}"; fi + a_clean="${a//-/}" # remove any - + a_clean="${a_clean:1}" # remove the leading C b="$(timeout 5 curl --compressed -sSL -A "Mozilla/5.0 (X11; Linux x86_64; rv:133.0) Gecko/20100101 Firefox/133.0" "https://wwwapps.tc.gc.ca/saf-sec-sur/2/ccarcs-riacc/RchSimpRes.aspx?m=%7c${a_clean}%7c" | hxclean | hxselect -i -c div#dvOwnerName div.col-md-6 | xargs | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')" # If we got something, make sure it will get added to the cache: