Last active
July 3, 2019 15:52
-
-
Save aiwas/5c77007c8e86c7b1cd1144895584e246 to your computer and use it in GitHub Desktop.
フォローしているアカウントの数 / フォローしているアカウントが所属するサーバーの数 を出すやつ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env zsh | |
setopt NO_NOMATCH | |
list_url=() | |
list_tmp=() | |
res=0 | |
page=1 | |
while [ $res = 0 ]; do | |
list_tmp=$(curl -sS "https://${1}/users/${2}/following.json?page=${page}" | jq -r ".orderedItems[]") | |
if [ -n "$list_tmp" ]; then | |
for next_url in $(echo $list_tmp); do | |
list_url=($list_url $next_url) | |
done | |
((page++)) | |
echo -n "page: $page\r" | |
else | |
res=1 | |
fi | |
done | |
typeset -aU list_unique | |
for url in $list_url; do | |
url_tmp=$(echo $url | sed -E "s,https://([^/]+).*,\1,") | |
list_unique=($list_unique $url_tmp) | |
done | |
echo -n "\e[2K"; echo $(( (${#list_url} * 1.0) / (${#list_unique} * 1.0) )) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
./bunsan.zsh <server> <account>
APIはAPのやつだけどエンドポイントはMastodonのやつで固定なので他で使えるかは不明