Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # This script is intended to see from which country some project committers are.
- # Requirements: Linux, Bash, curl, jq
- # Replace !!!GITHUB_TOKEN!!! variable below with your github token for this script to work.
- # URL Specify
- url="https://api.github.com/repos"
- #user="/dogecoin"
- #repo="/dogecoin"
- user="/electroneum"
- repo="/electroneum-pool"
- section="/contributors"
- headers="authorization: Bearer !!!GITHUB_TOKEN!!!"
- # Get project contributors
- echo $url$user$repo$section
- curl -s --header "$headers" $url$user$repo$section | jq -r '.[].login' > users
- p=2; r="123"
- until [[ $r == "" ]]; do
- r=$(curl -s --header "$headers" $url$user$repo$section?page=$p | jq -r '.[].login')
- printf "%s\n" $r >> users
- (( p++ ))
- done
- ## printf "%s\n" $ActiveIPs > ActiveIPs.txt
- echo "finished building user list of $repo, now loading users locations..."
- # Get contributors countries
- while read p; do
- loc=$(curl -s --header "$headers" https://api.github.com/users/$p | jq -r '.location')
- echo $p : $loc
- done < ./users
- ## Some sources for ideas (you can safely remove that)
- # curl -s https://api.github.com/repos/dogecoin/dogecoin/contributors?page=2 | jq '.[].login'
- # Clean & neat way (requires curl and jq)
- # curl -s https://api.github.com/users/MarcoFalke | jq '.location'
- # Another option
- # curl -sb -H "Accept: application/json" https://api.github.com/users/MarcoFalke | jq '.location'
- # Dirty way (reqires curl, grep and awk)
- # curl https://github.com/MarcoFalke | grep "Home location" | awk -F\" '{ print $6 }' | awk -F: '{ print $2 }'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement