A Node.js tool to check if a YouTube channel is currently live streaming.
-
Clone the repository:
git clone https://github.com/yourusername/yt-live-checker.git
-
Navigate to the project directory:
cd yt-live-checker
-
Install the dependencies:
npm install
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
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.
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"
}
This project relies on the following Node.js packages:
axios
for making HTTP requestscheerio
for parsing HTMLjsonpath-plus
for querying JSON datawinston
for logging
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.