-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathspots
86 lines (70 loc) · 2.23 KB
/
spots
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# -b band, -m mode
band=
mode=
while getopts ':b:m:h' OPTION; do
case "$OPTION" in
b)
band=$(echo "$OPTARG" | sed 's/m//g' | sed 's/c//g')
;;
m)
mode=$(echo "$OPTARG" | tr 'a-z' 'A-Z')
;;
h|?)
echo "Usage: $(basename $0) [-b band] [-m mode] [-h|-?]"
exit 1
;;
esac
done
shift "$(($OPTIND -1))"
function b2fr {
f="$1"
case $1 in
160) range1=1800; range2=2000 ;;
80) range1=3525; range2=4000 ;;
40) range1=7000; range2=7300 ;;
30) range1=10100; range2=10150 ;;
20) range1=14000; range2=14350 ;;
17) range1=18068; range2=18168 ;;
15) range1=21000; range2=21450 ;;
12) range1=24890; range2=24990 ;;
10) range1=28000; range2=29700 ;;
6) range1=50000; range2=54000 ;;
2) range1=144000; range2=148000 ;;
440) range1=420000; range2=450000 ;;
*) range1=0; range2=0 ;;
esac
}
url='https://api.pota.app/spot/activator'
curl -s $url > temp.json
jq 'sort_by([(.mode), (.frequency|tonumber)])' temp.json > temp1.json
if [ ! -z $mode ]; then
jq "map(select(.mode == \"$mode\"))" temp1.json > temp.json
else
mv temp1.json temp.json
fi
if [ ! -z $band ]; then
b2fr $band
jq "map(select((.frequency >= \"$range1\") and (.frequency <= \"$range2\")))" temp.json > spots.json
else
mv temp.json spots.json
fi
n=$(cat spots.json | jq '. [] | {reference: .reference, activatoper: .activator, freq: .frequency}' | jq '. .reference' | wc -l)
let n=$(($n - 1))
rm -f temp.json temp.out.txt
rows="%-10s %-20s %-5s %-12s %-10s %s\n"
echo "Park\tCall\tMode\tFreq\tLoc\tGrid" > temp.out.txt
for s in $(seq 0 $n); do
ref=$(cat spots.json | jq ". [$s] | .reference")
activator=$(cat spots.json | jq ". [$s] | .activator")
freq=$(cat spots.json | jq ". [${s}] | .frequency")
mode=$(cat spots.json | jq ". [${s}] | .mode")
loc=$(cat spots.json | jq ". [${s}] | .locationDesc")
grid=$(cat spots.json | jq ". [${s}] | .grid6")
#echo "${ref}\t\t${activator}\t\t${mode}\t${freq}\t${loc}\t${grid}" | tr -d '"' >> temp.out.txt
printf "$rows" ${ref} ${activator} ${mode} ${freq} ${loc} ${grid} | tr -d '"' >> temp.out.txt
done
txt=$(cat temp.out.txt)
notify-send -u critical -t 0 'POTA spots:' "${txt}"
cat temp.out.txt
rm -f temp.json temp.out.txt temp.out.data.txt
rm -f spots.json