Retreive and extract various informations from from Twitch VOD comments
Features :
- A simplified and convenient version of Twitch video comments
- Possibility to choose the time range of the video to analyze
- Get datas about emoticons used
- Sort comments according to the number of comments sent by people
- Parse the Twitch video by time range to highlight the moments with the most comments
npm install twitch-video-comments-analyser
import { CommentAnalyser } from 'twitch-video-comments-analyser' // For TypeScript
let anaylser = require('twitch-video-comments-analyser') // For Javascript
// You have to add your own Client ID. The second parameter is to enable the verbose mode.
const anaylser = new CommentAnalyser('TWITCH_CLIENT_ID', true)
const run = async () => {
// Retreive the comments for the specified time range and return an array of Comments (see the "patterns" section)
const comments = await anaylser.getComments(619607685, 500, 800)
// Retreive the comments for the whole video and return an array of Comments (see the "patterns" section)
const comments = await anaylser.getAllComment(619607685)
// Return an array with the ID of each emoticon used and its number of occurences
const emoticonsDatas = anaylser.emoticonStats(comments)
// Return an array with the name of each commenter and their number of occurences
const sortByUsers = anaylser.sortByUsers(comments)
// Return an array with, for each time range, the number of comments sent
const highlights = anaylser.sortByTimeRange(comments, 20) // 20 is the length of the time range with which the video will be analyzed
}
run().catch(error => console.log(error))
let comments = await anaylser.getComments(619607685, 500, 800)
// or the same result : comments = await anaylser.getCommentsAll(619607685)
console.log(comments)
/** Returns :
[
{
created_at: '2020-05-13T10:08:54.05Z',
updated_at: '2020-05-13T10:08:54.05Z',
time: 780.35,
commenter: {
display_name: 'its_Weasel',
name: 'its_Weasel',
type: 'user',
bio: null,
logo: 'https://static-cdn.jtvnw.net/jtv_user_pictures/7e2e34f8-af57-4cb1-928e-d8107a7e8a17-profile_image-300x300.png'
},
message: {
message: 'I have AdBlockPlus, NoScript, uBlock Origin and DNS level ad server blocking LUL',
user_color: '#FF0000',
user_badges: [],
emoticons: [
{
id: 9
link: "https://static-cdn.jtvnw.net/emoticons/v1/9/1.0"
}
]
}
},
{
created_at: '2020-05-13T10:09:09.643Z',
updated_at: '2020-05-13T10:09:09.643Z',
time: 795.943,
commenter: {
display_name: 'vTz_iLewis_x',
name: 'vTz_iLewis_x',
type: 'user',
bio: 'WATP',
logo: 'https://static-cdn.jtvnw.net/jtv_user_pictures/7e2e34f8-af57-4cb1-928e-d8107a7e8a17-profile_image-300x300.png'
},
message: {
message: 'onsW1 onsW2 onsW3 onsW4',
user_color: "#00FF7F",
user_badges: [
{
id: "premium"
version: 1
}
],
emoticons: []
}
}
...
]
**/
let usersSorted = anaylser.sortByUsers(comments)
console.log(usersSorted)
/** Returns :
[
{ user: 'benschie', count: 5 },
{ user: 'n1trux', count: 5 },
{ user: 'Samir2061', count: 4 },
{ user: 'm_c__j', count: 4 },
{ user: 'Nigelyap', count: 3 },
{ user: 'Gwapple', count: 3 },
{ user: 'its_Weasel', count: 2 }
...
]
**/
let highlights = anaylser.sortByTimeRange(comments)
console.log(highlights)
/** Returns :
[
{ range: { start: 436.769, end: 456.769 }, count: 4 },
{ range: { start: 460.458, end: 480.458 }, count: 3 },
{ range: { start: 480.554, end: 500.554 }, count: 9 },
{ range: { start: 501.073, end: 521.073 }, count: 3 }
...
]
**/
let emoticonStats = anaylser.emoticonStats(comments)
console.log(emoticonStats)
/** Returns :
[
{
emoticonId: 86,
count: 13,
link: 'https://static-cdn.jtvnw.net/emoticons/v1/86/1.0'
},
{
emoticonId: 11,
count: 4,
link: 'https://static-cdn.jtvnw.net/emoticons/v1/11/1.0'
},
{
emoticonId: 15,
count: 1,
link: 'https://static-cdn.jtvnw.net/emoticons/v1/15/1.0'
}
...
]
**/
-
created_at
<string> : ISO Date- ex: "2020-05-12T19:30:55.704Z"
-
updated_at
<string> : ISO Date- ex: "2020-05-12T19:30:55.704Z"
-
time
<string> : Time in seconds of the comment- ex: 203
-
commenter
<Commenter> : The commenter -
message
<Message> : The main content of the comment
-
display_name
<string> : The name displayed on the Twitch stream- ex: "felix"
-
name
<string> : The Twitch username of the commenter -
display_name
<string> : If the commenter is a BOT or a real user- ex: "user"
-
bio
<string> : The Twitch bio of the user- ex: "don't read me"
-
logo
<string> : A link to the commenter's avatar
-
message
<string> : The content of the comment- ex: "hahahahhahahahhaha"
-
user_color
<string> : The color of the user in the chat (HEX)- ex: "#8A2BE2"
-
emoticons
Array<Emoticon> -
user_badges
Array<Badge>
-
id
<number> : The ID of the comment- ex: 1566988
-
link
<string> : The link to the image of the emoticon
-
user
<string> : The name of the commenter- ex: "nas"
-
count
<number> : The number of comments sent by the commenter- ex: 23
-
range
<{start: number, end: number}> : The time range of analysis (in seconds)- ex: {start: 278, end: 298} (if the time range is 20 seconds)
-
count
<number> : The number of comments sent during this period- ex: 109
-
CommentAnalyser(TWITCH_CLIENT_ID, verbose=true)
-
getComments(videoId, start, end)
<Promise<Array<Comment>>>videoId
: The ID of the video from Twitchstart
: The start of the extract (in seconds)end
: The end of the extract (in seconds)
Note : If the time range is large, the process can be a bit long
-
getAllComments(videoId)
<Promise<Array<Comment>>>videoId
: The ID of the video from Twitch
Note : The process can be a bit long, especially if the video is long
-
sortByUsers(comments)
<Array<UserCountComment>> in ascending ordercomment
: The array of comments from thegetComments()
method
-
sortByTimeRange(comments)
<Array<TimeRangeComment>>comment
: The array of comments from thegetComments()
method
Verbose mode adds some logs and also a progress bar in the console showing the progress in retrieving comments.
example :
[====== ] 50% of comments retrieved