JSON function
This commit is contained in:
parent
ed6092a005
commit
a58f4b69ef
17
apt-cyg
17
apt-cyg
|
@ -306,6 +306,11 @@ apt-search () {
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jn () {
|
||||||
|
# parse json
|
||||||
|
awk '$1 ~ key {print $2}' RS='"?[,{}]' FS='": ?"?' key="$1" "$2"
|
||||||
|
}
|
||||||
|
|
||||||
proxy () {
|
proxy () {
|
||||||
local msg url dt pool px cn
|
local msg url dt pool px cn
|
||||||
msg=$1
|
msg=$1
|
||||||
|
@ -313,7 +318,7 @@ proxy () {
|
||||||
set --
|
set --
|
||||||
dt=proxy.txt
|
dt=proxy.txt
|
||||||
cd /tmp
|
cd /tmp
|
||||||
printf 'request %s... ' "$msg"
|
printf 'request %s... ' "$msg" >&2
|
||||||
while :
|
while :
|
||||||
do
|
do
|
||||||
if (( ! $# ))
|
if (( ! $# ))
|
||||||
|
@ -337,7 +342,7 @@ proxy () {
|
||||||
shift
|
shift
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
case $(awk '/responseStatus/,$0=$2' RS='(, |})' web.json) in
|
case $(jn responseStatus web.json) in
|
||||||
200) # OK
|
200) # OK
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
|
@ -350,7 +355,7 @@ proxy () {
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
printf '%s\n' "$px"
|
printf '%s\n' "$px" >&2
|
||||||
printf '%s\n' "$@" > $dt
|
printf '%s\n' "$@" > $dt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -364,11 +369,11 @@ apt-searchall () {
|
||||||
(( nof++ )) && echo
|
(( nof++ )) && echo
|
||||||
proxy pages "$api?$qs"
|
proxy pages "$api?$qs"
|
||||||
grep -q pages web.json || continue
|
grep -q pages web.json || continue
|
||||||
awk '$2 == "start" {print $4}' RS='[{,]' FS='"' web.json |
|
jn start web.json |
|
||||||
while read start
|
while read start
|
||||||
do
|
do
|
||||||
proxy "start $start" "$api?$qs&start=$start" >&2
|
proxy "start $start" "$api?$qs&start=$start"
|
||||||
awk '$2 == "url" {print $4}' RS=, FS='"' web.json
|
jn url web.json
|
||||||
done > urls.txt
|
done > urls.txt
|
||||||
awk '!s[$7]++ {print $7}' FS=/ urls.txt
|
awk '!s[$7]++ {print $7}' FS=/ urls.txt
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in New Issue