@elara-services/youtube-videos
Version:
Listen for YouTube videos for creators
72 lines (56 loc) • 1.62 kB
Markdown
```js
const { YouTubeVideos } = require("@elara-services/youtube-videos"),
youtube = new YouTubeVideos();
```
```js
// Adding a single creator
youtube.creators.add("UCzEnk4KWFlSj_PjXLz0"); // Adds the channelID to the 'data' set
// Bulk adding creators
youtube.creators.bulk([
"UCzEnk4KWFlSj_PjXLz0",
"UC....",
"UC.....",
]);
// Adds all of the channelIDs to the 'data' set.
```
```js
youtube.creators.remove("UCzEnk4KWFlSj_PjXLz0"); // Remove the channelID from the 'data' set
```
```js
youtube.creators.list(); // Returns an array of channelIDs
```
```js
youtube.setSearch(1); // The interval will be 1 minute
// DEFAULT: 2 minutes
```
```js
youtube.listen("video", async (channelID, videos) => {
// Code to do whatever when a new video is found.
// channelID: the creator's channelID
// videos: The array of videos found for the user.
});
```
```js
youtube.listen("searching", async (channels) => {
// Code to do whatever when this event gets triggered.
// Channels: the array of creator channelIDs
});
```
```js
youtube.run();
```
```js
const { util: { fetchVideos } } = require("@elara-services/youtube-videos");
// `[ ... ]` provide the video IDs in an array!
const videos = await fetchVideos([ ... ], "YOUTUBE_API_KEY");
// Array of videos found
```