Skip to content

Instantly share code, notes, and snippets.

Created February 19, 2016 05:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/9eeb3f30e8ef65b803d5 to your computer and use it in GitHub Desktop.
Save anonymous/9eeb3f30e8ef65b803d5 to your computer and use it in GitHub Desktop.
#!/bin/zsh
function usage() {
>&$2 echo -e "Usage: $1 <cookie> <user> [<since>]\nExample:"
>&$2 echo -e "\t$1 user=f25bf40e0bc05d002b407a53bb76c63ee20ef8f8 hirthwork 'week ago'"
}
if [ "$1" = --help ]
then
usage $0 1
exit 0
elif [ -z $1 -o -z $2 ]
then
usage $0 2
exit 1
fi
if [ -z $3 ]
then
since='week ago'
else
since=$3
fi
since=$(date +%s -d $since)
declare -A comments
before=0
while :
do
data=$(curl -H "Cookie: $1" -s "http://point.im/api/blog/$2?before=$before" | jq -c '.posts[] | {uid: .uid | tostring, created:.post.created, id:.post.id, author:.post.author.login}' | tr '"' ' ' | tr -d ,)
if [ -z "$data" ]
then
break
fi
echo $data | awk '{if ($13 == "'$2'"){print $7" "$10}}' | while read date id
do
echo "Requesting post #$id written at $date"
curl -H "Cookie: $1" -s "http://point.im/api/post/$id" | jq '.comments[].author.login' | tr -d '"' | while read fox
do
((++comments[$fox]))
((++total))
done
sleep 1
done
echo $data|tail -n1| read _ _ _ before _ _ date _
date=$(date +%s -d $date)
if [ $date -lt $since ]
then
break
fi
done
echo
echo Total comments: $total, total foxes: ${#comments}
echo
for key in ${(@k)comments}
do
echo $key ${comments[$key]}
done | sort -n -r -k 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment