This commit is contained in:
parent
bd2496fa0e
commit
d31b7b580e
1 changed files with 19 additions and 24 deletions
31
following
31
following
|
@ -13,9 +13,6 @@ set -e
|
||||||
# GNU sort.
|
# GNU sort.
|
||||||
# GNU awk.
|
# GNU awk.
|
||||||
|
|
||||||
# KNOWN ISSUES:
|
|
||||||
# output is not always sorted by viewer count.
|
|
||||||
|
|
||||||
# TODO:
|
# TODO:
|
||||||
# fix known issues.
|
# fix known issues.
|
||||||
# automatically extract relevant values from a cURL string.
|
# automatically extract relevant values from a cURL string.
|
||||||
|
@ -36,31 +33,29 @@ set -e
|
||||||
# in Chromium, it's in a submenu as "copy as cURL (bash)"
|
# in Chromium, it's in a submenu as "copy as cURL (bash)"
|
||||||
# 6. paste into a text editor and extract the following header values:
|
# 6. paste into a text editor and extract the following header values:
|
||||||
# (each header is specified by a -H flag)
|
# (each header is specified by a -H flag)
|
||||||
cookie="cookie: [fill me in!]"
|
authorization="Authorization: OAuth abcdefghijklmnopqrstuvwxyz1234"
|
||||||
client_id="client-id: [fill me in!]"
|
|
||||||
|
|
||||||
# note: technically, you only need the "persistent" cookie.
|
|
||||||
|
|
||||||
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://gql.twitch.tv/gql' \
|
||||||
-H 'accept: application/vnd.twitchtv.v5+json' \
|
-H "$authorization" \
|
||||||
-H "$cookie" \
|
--data-binary '[{"variables":{"limit":100},"extensions":{},"operationName":"FollowingLive_CurrentUser","query":"query FollowingLive_CurrentUser($limit: Int, $cursor: Cursor) {\n currentUser {\n follows {\n totalCount\n }\n followedLiveUsers(first: $limit, after: $cursor) {\n edges {\n node {\n login\n displayName\n stream {\n game {\n name\n }\n viewersCount\n title\n type\n }\n }\n }\n pageInfo {\n hasNextPage\n }\n }\n }\n}\n"}]' \
|
||||||
-H "$client_id" | json2 | sort -n | awk '
|
| json2 | tr -d '\r' | 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=substr($2,2)}
|
$1~/\/stream\/game\/name$/{game=substr($2,2)}
|
||||||
$1~/\/channel\/status$/{status=substr($2,2)}
|
$1~/\/stream\/title$/{title=substr($2,2)}
|
||||||
$1~/\/channel\/name$/{name=substr($2,2)}
|
$1~/\/login$/{name=substr($2,2)}
|
||||||
$1~/\/viewers$/{
|
$1~/\/viewersCount$/{viewers=substr($2,2)}
|
||||||
viewers=substr($2,2);
|
$1~/\/stream\/type$/{
|
||||||
printf "\x1b[90m%5s\x1b[0m \x1b[97m%-25s\x1b[0m %s\n \x1b[1m%s\x1b[0m\n",
|
printf "\x1b[90m%5s\x1b[0m \x1b[97m%-25s\x1b[0m %s\n \x1b[36m%s\x1b[0m\n",
|
||||||
viewers, name, trunc(game, 48), status;
|
viewers, name, trunc(game, 48), title;
|
||||||
}
|
}
|
||||||
' FPAT='(^[^=]+)|(=.*)'
|
' FPAT='(^[^=]+)|(=.*)'
|
||||||
|
|
Loading…
Reference in a new issue