Skip to content

Instantly share code, notes, and snippets.

@tsuzu
Created May 3, 2016 16:07
Show Gist options
  • Save tsuzu/c43847b07337770ab9ff284eccd799f2 to your computer and use it in GitHub Desktop.
Save tsuzu/c43847b07337770ab9ff284eccd799f2 to your computer and use it in GitHub Desktop.
Show comments of AbemaTV
request = require 'request'
process = require 'process'
if process.argv.length < 3
# coffee abema_comment.coffee "https://api.abema.io/v1/slots/PrqEfeD2wpT/comments?limit=20"
console.log "nodejs abema_comment.coffee [endpoint]"
process.exit 1
loaded = []
getComments = ->
options = {
url: process.argv[2],
method: 'GET',
headers: {
"authorization": "bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkZXYiOiJjZjVmNDRiMS00MzhjLTRiODEtYWM1Zi1hOTYwYjJjZWM1ZDciLCJleHAiOjIxNDc0ODM2NDcsImlzcyI6ImFiZW1hLmlvL3YxIiwic3NzIjowLCJzdWIiOiJQMkZVYUZhTmM4RCJ9.j-LfPHZGw16Qfxd5Aa6jAj3XoZtQAdR29PzzZk1CQCQ"
}
}
request(options, (err, resp, body)->
if err || resp.statusCode != 200
console.log "error"
return
json = JSON.parse body
for com, idx in json["comments"]
if !(com["id"] in loaded)
loaded.push com["id"]
console.log com["message"]
getComments()
)
getComments()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment