1.0.4 • Published 4 years ago

twitch-video-comments-analyser v1.0.4

Weekly downloads
3
License
ISC
Repository
github
Last release
4 years ago

Twitch video comments analyser

NPM

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

Installation

npm install twitch-video-comments-analyser

NPM

Usage

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))

Examples :

    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'
            }
            ...
        ]    
    **/

Patterns

Comment

Commenter

Message

Emoticon

Badge

UserCountComment

TimeRangeComment

Methods

Verbose mode

Verbose mode adds some logs and also a progress bar in the console showing the progress in retrieving comments.

example :

[======         ] 50% of comments retrieved