Skip to content

A tool to check if a YouTube channel is currently live streaming.

License

Notifications You must be signed in to change notification settings

roadrunner21/yt-live-checker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

yt-live-checker

A Node.js tool to check if a YouTube channel is currently live streaming.

Table of Contents

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/yt-live-checker.git
  2. Navigate to the project directory:

    cd yt-live-checker
  3. Install the dependencies:

    npm install

Usage

As a Standalone Tool

To use yt-live-checker as a standalone CLI tool, run the following command with the YouTube channel ID as an argument:

node index.js <channelId>

Replace <channelId> with the ID of the YouTube channel you want to check.

Example:

node index.js UCCAfRoTJrKPbSrh_Eg3i4vg

As a Dependency

To use yt-live-checker in your project, first install it via npm:

npm install yt-live-checker

Then, import and use it in your code:

const { checkChannelLiveStatus } = require('yt-live-checker');

// Optional: Use your own logger
const winston = require('winston');
const customLogger = winston.createLogger({
    level: 'info',
    format: winston.format.simple(),
    transports: [new winston.transports.Console()]
});

checkChannelLiveStatus('UCCAfRoTJrKPbSrh_Eg3i4vg', { logger: customLogger })
    .then(result => {
        console.log(result);
    })
    .catch(error => {
        console.error(error);
    });

If you don't provide a custom logger, yt-live-checker will use its default logging configuration based on the NODE_ENV environment variable.

Example Output

When a channel is live, you’ll see output similar to:

{
  "isLive": true,
  "videoId": "mf2fCLtUUVA",
  "title": "Bowblax: Criticism Not Welcome",
  "viewCount": "243989",
  "channelName": "TomDark",
  "channelId": "UCCAfRoTJrKPbSrh_Eg3i4vg",
  "videoUrl": "https://www.youtube.com/watch?v=mf2fCLtUUVA"
}

When a channel is not live, the output will be:

{
  "isLive": false,
  "channelId": "UCCAfRoTJrKPbSrh_Eg3i4vg",
  "channelName": "TomDark"
}

Dependencies

This project relies on the following Node.js packages:

  • axios for making HTTP requests
  • cheerio for parsing HTML
  • jsonpath-plus for querying JSON data
  • winston for logging

License

This project is licensed under the Prosperity Public License. You are free to use this software non-commercially. For commercial use, please contact the author for permission or refer to the terms in the license.

About

A tool to check if a YouTube channel is currently live streaming.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published