1.0.13 • Published 2 years ago

@eslym/youtube-utilities v1.0.13

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

YouTube Utilities

This is a library to help crawl data from YouTube, currently support channel metadata and video details.

This project is inspired by LinaTsukusu/youtube-chat, a lot of code are from that project also, so please take a look on that.

Disclaimer

This library is not using standard API to extract data, so it does not guarantee to work in the future. It uses a crawling method to extract data from YouTube, so use it at your own risk.

Features

  1. Identify page type (video/channel)
  2. Extract metadata and video details from page
  3. Fetch chat from public livestream

Installation

npm install @eslym/youtube-utilities
yarn add @eslym/youtube-utilities

Usage

Extract data from a youtube url

import {crawl} from "@eslym/youtube-utilities";

let result = await crawl('https://youtube.com/...');

if (result.type === 'profile') {
    console.log('This is a channel page, named ' + result.metadata.title);
} else if (result.type === 'video') {
    console.log('This is a video page, named ' + result.metadata.title);
}

Fetch YouTube chat from livestream

import {crawl, ChatFetcher} from "@eslym/youtube-utilities";

let result = await crawl('https://youtube.com/watch?v=VIDEO_ID');

let state = {
    apiKey: result.apiKey,
    clientVersion: result.clientVersion,
    continuation: result.liveAbility.continuations.reverse()[0],
};

let fetcher = new ChatFetcher(state);

fetcher.on('chat', chat => {
    console.log(chat);
});

fetcher.start();
1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago