Skip to content

Instantly share code, notes, and snippets.

@Pmmlabs
Created October 27, 2017 18:38
Show Gist options
  • Save Pmmlabs/ce80d53acc7d187fdcb58ea9c886d985 to your computer and use it in GitHub Desktop.
Save Pmmlabs/ce80d53acc7d187fdcb58ea9c886d985 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
JQ="jq"
TEMP="temp.json"
COMMENTS="comments.txt"
CURSOR=""
PARAM=""
echo "" > ${TEMP}
echo "" > ${COMMENTS}
while [ "$CURSOR" != "null" ]
do
[ -z "$CURSOR" ] && echo 1 || PARAM="cursor=$CURSOR"
curl "https://api.twitch.tv/v5/videos/$VIDEO/comments?$PARAM" -H "client-id: $CLIENT_ID" --compressed > ${TEMP}
${JQ} -r '.comments|.[]|"[" + (.content_offset_seconds/3600|floor|tostring) + ":" + (.content_offset_seconds%3600/60|floor|tostring) + ":" + (.content_offset_seconds%60|floor|tostring) + "] " + .commenter.name + ": " + .message.body' ${TEMP} >> $COMMENTS
CURSOR=`${JQ} -r "._next" ${TEMP}`
done
echo "DONE"
@WuvorWenda
Copy link

There is an token error when adding a channel witch contains topic Food \u0026 Drink
solution: TOKEN="echo $RESP | $JQ '.token' | sed 's/\\\\"/"/g' | sed 's*\\\\**' | sed 's/\(^.\)//g' | sed 's/\(.$\)//g'"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment