Coder Social home page Coder Social logo

youtube-chat's Introduction

youtube-chat

Fetch Youtube live chat without API

This module is a fork of youtube-chat, which was written by LinaTsukusu and fixed up by IcedCoffeee.

Since the original maintainer doesn't work on this package, we forked it and maintain it for the needs of FreeTube.

You will need to take full responsibility for your actions

Getting started

  1. Install
    • npm i @freetube/youtube-chat
    • yarn add @freetube/youtube-chat
  2. Import
    • Javascript
    const LiveChat = require('@freetube/youtube-chat').LiveChat
    • Typescript
    import {LiveChat} from '@freetube/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

chunkyprogrammer avatar dependabot[bot] avatar domhawken avatar efb4f5ff-1298-471a-8973-3d47447115dc avatar icedcoffeee avatar neverclear86 avatar pikachuexe avatar prestonn avatar svallinn avatar

Watchers

 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.