GithubHelp home page GithubHelp logo

code-ga / youtube-chat Goto Github PK

View Code? Open in Web Editor NEW

This project forked from linatsukusu/youtube-chat

0.0 0.0 0.0 671 KB

Fetch YouTube Live comments

License: MIT License

JavaScript 3.19% TypeScript 96.81%

youtube-chat's Introduction

youtube-chat

Fetch Youtube live chat without API

You will need to take full responsibility for your action

Getting started

  1. Install
    • npm i youtube-chat
    • yarn add youtube-chat
  2. Import
    • Javascript
    const LiveChat = require('youtube-chat').LiveChat
    • Typescript
    import {LiveChat} from 'youtube-chat'
  3. Create instance with ChannelID or LiveID
    // If channelId is specified, liveId in the current stream is automatically acquired.
    const liveChat = new LiveChat({channelId: 'UCxkOLgdNumvVIQqn5ps_bJA?'})
    
    // Or specify LiveID in Stream manually.
    const liveChat = new LiveChat({liveId: 'bc5DoKBZRIo'})
  4. Add events
    // Emit at start of observation chat.
    // liveId: string
    liveChat.on('start', (liveId) => {})
    
    // Emit at end of observation chat.
    // reason: string?
    liveChat.on('end', (reason) => {})
    
    // Emit at receive chat.
    // comment: CommentItem
    liveChat.on('comment', (comment) => {})
    
    // Emit when an error occurs
    // err: Error
    liveChat.on('error', (err) => {})

Types

CommentItem

interface CommentItem {
  id: string
  author: {
    name: string
    thumbnail?: ImageItem
    channelId: string
    badge?: {
      thumbnail: ImageItem
      label: string
    }
  }
  message: MessageItem[]
  superchat?: {
    amount: string
    color: number
  }
  membership: boolean
  isOwner: boolean
  timestamp: number
}

MessageItem

type MessageItem = { text: string } | ImageItem

ImageItem

interface ImageItem {
  url: string
  alt: string
  width: number
  height: number
}

youtube-chat's People

Contributors

neverclear86 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.