This commit is contained in:
parent
075418af21
commit
0243eb33dd
1 changed files with 15 additions and 13 deletions
28
following
28
following
|
@ -8,14 +8,12 @@ set -e
|
||||||
# editing this script.
|
# editing this script.
|
||||||
# downloading a python script.
|
# downloading a python script.
|
||||||
# python 2 or 3.
|
# python 2 or 3.
|
||||||
# a web browser
|
# a web browser.
|
||||||
# curl
|
# curl.
|
||||||
# GNU sort
|
# GNU sort.
|
||||||
# GNU awk
|
# GNU awk.
|
||||||
|
|
||||||
# KNOWN ISSUES:
|
# KNOWN ISSUES:
|
||||||
# stops printing at the first = character per field.
|
|
||||||
# this should be an easy fix but i'm lazy.
|
|
||||||
# output is not always sorted by viewer count.
|
# output is not always sorted by viewer count.
|
||||||
|
|
||||||
# TODO:
|
# TODO:
|
||||||
|
@ -46,19 +44,23 @@ client_id="client-id: [fill me in!]"
|
||||||
json2() {
|
json2() {
|
||||||
# download this from https://github.com/vi/json2/blob/master/json2
|
# download this from https://github.com/vi/json2/blob/master/json2
|
||||||
# and edit this line accordingly.
|
# and edit this line accordingly.
|
||||||
python ~/src/json2/json2 "$@"
|
~/python3 ~/src/json2/json2 "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
curl -LsS 'https://api.twitch.tv/kraken/streams/followed?limit=100&stream_type=all' \
|
curl -LsS 'https://api.twitch.tv/kraken/streams/followed?limit=100&stream_type=all' \
|
||||||
-H 'accept: application/vnd.twitchtv.v5+json' \
|
-H 'accept: application/vnd.twitchtv.v5+json' \
|
||||||
-H "$cookie" \
|
-H "$cookie" \
|
||||||
-H "$client_id" | json2 | sort -n | awk -F'=' '
|
-H "$client_id" | json2 | sort -n | awk '
|
||||||
function trunc(s,L) {
|
function trunc(s,L) {
|
||||||
e = length(s) > L ? "…" : "";
|
e = length(s) > L ? "…" : "";
|
||||||
return (substr(s, 0, L -(e ? 1 : 0)) e);
|
return (substr(s, 0, L -(e ? 1 : 0)) e);
|
||||||
}
|
}
|
||||||
$1~/\/game$/{game=$2}
|
$1~/\/game$/{game=substr($2,2)}
|
||||||
$1~/\/channel\/status$/{status=$2}
|
$1~/\/channel\/status$/{status=substr($2,2)}
|
||||||
$1~/\/channel\/name$/{name=$2}
|
$1~/\/channel\/name$/{name=substr($2,2)}
|
||||||
$1~/\/viewers$/{printf "\x1b[90m%5s\x1b[0m \x1b[97m%-25s\x1b[0m %s\n \x1b[1m%s\x1b[0m\n",$2,name,trunc(game,48),status}
|
$1~/\/viewers$/{
|
||||||
'
|
viewers=substr($2,2);
|
||||||
|
printf "\x1b[90m%5s\x1b[0m \x1b[97m%-25s\x1b[0m %s\n \x1b[1m%s\x1b[0m\n",
|
||||||
|
viewers, name, trunc(game, 48), status;
|
||||||
|
}
|
||||||
|
' FPAT='(^[^=]+)|(=.*)'
|
||||||
|
|
Loading…
Add table
Reference in a new issue