New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@livecord/notify

Package Overview
Dependencies
Maintainers
2
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@livecord/notify - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

4

examples/youtube.test.js
const { YouTube } = require('../src/index');
const youtube = new YouTube({
channels: [ 'UCaZGQt419Ptsdk_lh2mz9lQ', 'UCna9_me1UQAu3zbxv-dIhCQ' ], // Array of channels (required)
postedVideos: [ "" ], // Array of videos that have been posted (optional)
interval: 1000 // check channels every 1000ms (1 second) (optional) (default: 60000 [60 seconds])])
interval: 1000, // check channels every 1000ms (1 second) (optional) (default: 60000 [60 seconds])])
useDatabase: true // use database to store videos (optional) (default: true)
});

@@ -7,0 +7,0 @@

{
"name": "@livecord/notify",
"version": "1.0.3",
"version": "1.0.4",
"description": "Notifier for Youtube and Twitch.",

@@ -5,0 +5,0 @@ "main": "./src/index.js",

@@ -60,3 +60,4 @@ # [@livecord/notify](https://npmjs.com/package/@livecord/notify)

channels: [ '' ], // Array of channel ids (required)
interval: 1000 // check channels every 1000ms (1 second) (optional) (default: 60000 [60 seconds])])
interval: 1000, // check channels every 1000ms (1 second) (optional) (default: 60000 [60 seconds])])
useDatabase: true // use database to store videos (optional) (default: true)
});

@@ -63,0 +64,0 @@

@@ -8,3 +8,3 @@ const EventEmitter = require('events');

module.exports = class LivecordYoutube extends EventEmitter {
constructor({ postedVideos = [], channels, interval = 60000 }) {
constructor({ postedVideos = [], channels, interval = 60000, useDatabase = true }) {
super();

@@ -15,2 +15,3 @@

if (interval && typeof interval !== 'number') throw new Error('LivecordYoutube: interval must be a number');
if (useDatabase && typeof useDatabase !== 'boolean') throw new Error('LivecordYoutube: useDatabase must be a boolean');
if (!channels) throw new Error('LivecordYoutube: You must provide a list of channels.');

@@ -31,5 +32,7 @@ if (!Array.isArray(channels)) throw new Error('LivecordYoutube: channels must be an array');

this.ws.on('open', () => {
JSON.parse(fs.readFileSync('videos.json')).forEach(video => {
if(!this.postedVideos.includes(video)) this.postedVideos.push(video);
});
if (useDatabase) {
JSON.parse(fs.readFileSync('videos.json')).forEach(video => {
if (!this.postedVideos.includes(video)) this.postedVideos.push(video);
});
}
this.emit('ready', Date.now());

@@ -41,14 +44,18 @@ setInterval(() => {

let $ = data.items[0];
if(postedVideos.includes($.id)) return;
if(!fs.existsSync('videos.json')) {
fs.writeFileSync('videos.json', JSON.stringify([$.id]));
if (useDatabase) {
if (postedVideos.includes($.id)) return;
if (!fs.existsSync('videos.json')) {
fs.writeFileSync('videos.json', JSON.stringify([$.id]));
} else {
fs.writeFileSync('videos.json', JSON.stringify([
...JSON.parse(fs.readFileSync('videos.json')),
$.id
]));
}
this.postedVideos.push($.id);
return this.emit('upload', $);
} else {
fs.writeFileSync('videos.json', JSON.stringify([
...JSON.parse(fs.readFileSync('videos.json')),
$.id
]));
return this.emit('upload', $);
}
this.postedVideos.push($.id);
return this.emit('upload', $);
}).catch(() => {});
}).catch(() => { });
})

@@ -55,0 +62,0 @@ }, interval || 60000);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc