@livecord/notify
Advanced tools
Comparing version 1.0.4 to 1.0.5
const { YouTube } = require('../src/index'); | ||
const youtube = new YouTube({ | ||
channels: [ 'UCaZGQt419Ptsdk_lh2mz9lQ', 'UCna9_me1UQAu3zbxv-dIhCQ' ], // Array of channels (required) | ||
channels: [], // Array of channels (required) | ||
interval: 1000, // check channels every 1000ms (1 second) (optional) (default: 60000 [60 seconds])]) | ||
@@ -8,2 +8,4 @@ useDatabase: true // use database to store videos (optional) (default: true) | ||
youtube.subscribe('UCaZGQt419Ptsdk_lh2mz9lQ'); // Subscribe to a channel | ||
youtube.on('ready', (ready) => { | ||
@@ -10,0 +12,0 @@ console.log('Youtube connected at: ', ready); |
{ | ||
"name": "@livecord/notify", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "Notifier for Youtube and Twitch.", | ||
@@ -5,0 +5,0 @@ "main": "./src/index.js", |
@@ -31,5 +31,9 @@ const EventEmitter = require('events'); | ||
if (useDatabase) { | ||
JSON.parse(fs.readFileSync('videos.json')).forEach(video => { | ||
if (!this.postedVideos.includes(video)) this.postedVideos.push(video); | ||
}); | ||
if (fs.existsSync('./livecord.json')) { | ||
JSON.parse(fs.readFileSync('livecord.json')).forEach(video => { | ||
if (!this.postedVideos.includes(video)) this.postedVideos.push(video); | ||
}); | ||
} else { | ||
fs.writeFileSync('livecord.json', JSON.stringify([])); | ||
} | ||
} | ||
@@ -44,10 +48,6 @@ this.emit('ready', Date.now()); | ||
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 | ||
])); | ||
} | ||
fs.writeFileSync('livecord.json', JSON.stringify([ | ||
...JSON.parse(fs.readFileSync('livecord.json')), | ||
$.id | ||
])); | ||
this.postedVideos.push($.id); | ||
@@ -69,2 +69,14 @@ return this.emit('upload', $); | ||
}; | ||
subscribe(channel) { | ||
if (!channel) throw new Error('LivecordYoutube: channel is required'); | ||
if (typeof channel === 'string') { | ||
this.channels.push(channel); | ||
} else if (Array.isArray(channel)) { | ||
channel.forEach(c => { | ||
this.channels.push(c); | ||
}) | ||
} else { | ||
throw new Error('LivecordYoutube: channel must be a string or array'); | ||
} | ||
} | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11094
8
172