-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
55 lines (47 loc) · 1.65 KB
/
Copy pathindex.js
File metadata and controls
55 lines (47 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
const fs = require('fs')
const express = require('express')
const axios = require('axios')
const app = express()
app.use(express.json())
app.use(express.static('public'))
let transcriptions = 0, forumpost = 0, annotations = 0, answers = 0, questions = 0, iq = 0
function sendRequest(name, id) {
axios({
"method":"GET",
"url":`https://api.genius.com/users/${id}`,
"headers":{
"content-type":"application/json",
"useQueryString":true
},
"params":{
"access_token":"ACCESS_TOKEN_HERE" //Get this at api.genius.com
}
})
.then((response) => {
const json = response.data.response.user
transcriptions += json.stats.transcriptions_count
annotations += json.stats.annotations_count
answers += json.stats.answers_count
questions += json.stats.questions_count
forumpost += json.stats.forum_posts_count
iq += json.iq
})
.catch((error) => {
console.log(error)
})
}
app.listen(3000, async () => {
const json = JSON.parse(fs.readFileSync('./public/users.json'))
for (user in json.users) {
await sendRequest(user, json.users[user])
}
setTimeout(() => {
console.log('-----------------------')
console.log(`Transcripties 📝: ${transcriptions}`)
console.log(`Annotaties ✍️: ${annotations}`)
console.log(`Forum Posts 📥: ${forumpost}`)
console.log(`Vragen gesteld ❓: ${questions}`)
console.log(`Vragen geantwoord 🙋♂️: ${answers}`)
console.log(`IQ van de community 💡: ${iq}`)
}, 3000)
})