npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

yt-notifier

v2.1.0

Published

Run when a spicific channel video is published

Downloads

21

Readme

YouTube Notify

An npm package that run codes when a specified channel publishes a video.

Summary

  1. Installation.
  2. Use.
  3. Change Logs.
  4. Documentation.
  5. Extensions.

Installation

npm install yt-notifier
yarn add yt-notifier

Use

const { Notify } = require("yt-notifier");
const notify = new Notify({
  apiKey: "Your youtube ApiKey",
});

notify.on("ready", async () => {
  const id = await notify.getChannelId("https://www.youtube.com/@example"); // Youtube channel url

  // Create the listener
  await notify.createListener({ channelId: id });
});

// Event for when the video is published
notify.on("newVideo", (items) => {
  console.log(items);
});

Change Logs

v2.0.4: (last-release)

  • Added the files for the yarn page.
  • Fixed a problem with the listener.

Documentation

Inizialization

const { Notify } = require("yt-notifier");
const notify = new Notify({
  apiKey: "Your youtube ApiKey",
});

Functions

The functions that can be used with this package.

getChannelId()

Gets the channel id from url delete event.

Use

const channelId = await notify.getChannelId("https://www.youtube.com/@example");

Returns

channelId

createListener()

Creates a listener and active create, when the listener is create, and newVideo, when the specified channel upload a video, events.

Use

await notify.createListener({ channelId: id });

stopListener()

Stops a listener and active delete event.

Use

await notify.stopListener({ channelId: id });

Events

The events that can be actived.



This event is only active when instance is ready.

Use

notify.on('ready', (i) => {
  ...
});

Returns

currentInstance

Example

const { Notify } = require("yt-notifier");
const notify = new Notify({
  apiKey: "Your youtube ApiKey",
});

notify.on("ready", async (i) => {
  console.log(i);
});


This event is activated when a new listener is created.

Use

notify.on('create', (channelId, id) => {
  ...
});

Returns

channelId, currentInstance

Example

const { Notify } = require('yt-notifier');
const notify = new Notify({
   apiKey: "Your youtube ApiKey"
});

...

notify.on('create', (channelId, i) => {
  console.log(channelId);
});


This event is activated when a listener is deleted.

Use

notify.on('delete', (channelId, i) => {
  ...
});

Returns

channelId, currentInstance

Example

const { Notify } = require('yt-notifier');
const notify = new Notify({
   apiKey: "Your youtube ApiKey"
});

...

notify.on('delete', (channelId, i) => {
  console.log(channelId);
});


This event is activated when a cahnnel publish a new video.

Use

notify.on('newVideo', (items) => {
  ...
});

Returns

{
  id: '{videoId}',
  title: '{videoTitle}',
  description: '{videoDescription}',
  link: '<videoUrl>',
  releaed: '<releaseDate>',
  thumbnails: {
    default: '<thumbnailUrl>',
    medium: '<thumbnailUrl>',
    high: '<thumbnailUrl>',
    standard: '<thumbnailUrl>',
    maxres: '<thumbnailUrl>',
  },
  statistics: {
    viewCount: '<viewsNumber>',
    likeCount: '<likeCount>',
    favoriteCount: '<favoriteCount>',
    commentCount: '<commentsNumber>'
  },
  author: {
    link: '<channelUrl>',
    name: '<channelName>',
    description: '<channelDescription>',
    avatars: {
      default: '<avatarUrl>'
      medium: '<avatarUrl>',
      high: '<avatarUrl>',
    },
    statistics: {
      subscribers: '<subscribersCount>',
      videoCount: '<videoCount>',
      views: '<viewsNumber>',
    },
  },
}

Example

const { Notify } = require('yt-notifier');
const notify = new Notify({
   apiKey: "Your youtube ApiKey"
});

...

notify.on('newVideo', (items) => {
  console.log(items);
});

Extensions

Twitch

Use

const { Notify, TwitchExtension } = require("yt-notify");
const notify = new Notify({
  apiKey: "Your youtube ApiKey",
  extensions: {
    twitch: new TwitchExtension({
      clientId: "Twitch client id",
      token: "Twitch token id",
    }),
  },
});
const twitch = notify.twitch;

Function

createListener()

Creates a listener and active create, when the listener is create, and newVideo, when the specified channel upload a video, events.

Use
await twitch.createListener({ channel: channelName });

stopListener()

Stops a listener and active delete event.

Use
await twitch.stopListener({ channel: channelName });

Events

The events that can be actived with this extension.



This event is only active when instance is ready.

Use

twitch.on('ready', (i) => {
  ...
});

Returns

currentInstance

Example

const { Notify, TwitchExtension } = require("yt-notify");
const notify = new Notify({
  apiKey: "Your youtube ApiKey",
  extensions: {
    twitch: new TwitchExtension({
      clientId: "Twitch client id",
      token: "Twitch token id",
    }),
  },
});
const twitch = notify.twitch;

twitch.on("ready", async (i) => {
  console.log(i);
});


This event is activated when a new listener is created.

Use

twitch.on('create', (channelId, id) => {
  ...
});

Returns

{
   id: '<channelId>',
   login: '<channelUsername>',
   display_name: '<channelName>',
   broadcaster_type: '<brodcastType>',
   description: '<channelDescription>',
   profile_image_url: '<profileImage>',
   offline_image_url: '<offlineImage>',
   view_count: <viewCount>,
   created_at: '<creationTime>'
},
currentInstance

Example

const { Notify, TwitchExtension } = require("yt-notify");
const notify = new Notify({
   apiKey: "Your youtube ApiKey",
   extensions: {
      twitch: new TwitchExtension({
         clientId: "Twitch client id",
         token: "Twitch token id",
      })
   }
});
const twitch = notify.twitch;

...

twitch.on('create', (streamerInfo, i) => {
  console.log(streamerInfo);
});


This event is activated when a listener is deleted.

Use

twitch.on('delete', (streamerInfo, i) => {
  ...
});

Returns

{
   id: '<channelId>',
   login: '<channelUsername>',
   display_name: '<channelName>',
   broadcaster_type: '<brodcastType>',
   description: '<channelDescription>',
   profile_image_url: '<profileImage>',
   offline_image_url: '<offlineImage>',
   view_count: <viewCount>,
   created_at: '<creationTime>'
}
currentInstance

Example

const { Notify, TwitchExtension } = require("yt-notify");
const notify = new Notify({
   apiKey: "Your youtube ApiKey",
   extensions: {
      twitch: new TwitchExtension({
         clientId: "Twitch client id",
         token: "Twitch token id",
      })
   }
});
const twitch = notify.twitch;

...

twitch.on('delete', (streamerInfo, i) => {
  console.log(streamerInfo);
});


This event is activated when a streamer start a new live.

Use

twitch.on('isLive', (items) => {
  ...
});

Returns

{
  id: '<id>',
  user_id: '<userId>',
  user_login: '<username>',
  user_name: '<channelName>',
  game_id: '<gameId>',
  game_name: '<gameName>',
  type: '<type>',
  title: '<liveTitle>',
  viewer_count: <viewerCount>,
  started_at: '<startedTime>',
  language: '<lenguage>',
  thumbnail_url: '<thumbnailUrl>',
  tag_ids: <arrayOfTagsId>,
  tags: <arrayOfTags>,
  is_mature: false
}

Example

const { Notify, TwitchExtension } = require("yt-notify");
const notify = new Notify({
   apiKey: "Your youtube ApiKey",
   extensions: {
      twitch: new TwitchExtension({
         clientId: "Twitch client id",
         token: "Twitch token id",
      })
   }
});
const twitch = notify.twitch;

...

twitch.on('isLive', (items) => {
  console.log(items);
});