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

youtube-watch

v1.0.1

Published

Get YouTube notifications when channels upload, modify, or delete videos

Downloads

8

Readme

youtube-watch

youtube-watch is a basic wrapper for Pubsubhubbub. It allows you to efficiently receive YouTube notifications when your favorite channels upload, modify, or delete a video.

This release only supports notifications when a video is uploaded.

Install

Installation is easy with npm

npm install youtube-watch

Example

const YouTubeWatch = require('youtube-watch');

const yw = new YouTubeWatch({
	secretKey: 'something_unique',
	hubCallback: 'http://your-ip-or-domain/',
	hubPort: 9001,
});

yw.on('start', () => {
    let channels = ['UCY_UYz9m6XYmCpqC5EuqKMg',
                    'UCGY2w6hIZWwyxasBUN7wbaQ'];

    yw.watch(channels);
});

yw.on('notified', video => {
	console.log(`${video.author} just uploaded a new video titled: ${video.title}`);
});

yw.start();

Events

  • 'start' - The service is available to begin watching feeds.
  • 'stop' - The service is no longer available to watch feeds.
  • 'watch' - A channel has been verified to begin receiving notifications.
  • 'unwatch' - A channel has been verified to stop receiving notifications.
  • 'notified'(video) - A channel has uploaded/modified/deleted a video.
    • video is an object which contains the following properties: channelId, videoId, author, title, and published.
  • 'error'(err) - An error has occurred.
    • err is an Error object.

API

YouTubeWatch.constructor(options)

options is an object that you may write your own properties to. The following properties are read by YouTubeWatch:

  • secret - A private key used by Pubsubhubbub, it is not required to include this property but it is highly recommended that you do. Defaults to 'change me!'
  • hubCallback - Your ip/domain name that will be used as a callback URL by Pubsubhubbub. It must be in a URL format, ex: 'http://example.com/'. This is a required property as the default is undefined.
  • hubPort - The port Pubsubhubbub will listen on. This must be an open port on your system. Defaults to port 9001.
  • hubUrl - The URL in which we listen to updates from. This shouldn't be changed unless you know what you're doing.

YouTubeWatch.start()

This function will start the internal service used by Pubsubhubbub. If the service successfully starts up then the start event is emitted otherwise the error event is. Once the start event has been sent you may begin to watch for channel updates via the YouTubeWatch.watch() function. If this function is called while the service has already been start an error is emitted.

YouTubeWatch.stop()

This functions will stop the internal service. After it has been stopped a stop event is emitted. If the service is not running and this function is called then an error is emitted.

YouTubeWatch.watch(channels=[])

Watches a list of channels IDs. Channels may either be a string or an array of strings. After each successful channel has been verified to receive updates a watch event is ommited.

YouTubeWatch.unwatch(channels=[])

Removes the watch state from a list of channel IDs. Channels may either be a string or an array of strings. After each successful channel has been verified to stop receiving updates an unwatch event is ommited.

License

Copyright (c) 2016 SysDevs

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.