Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return new Promise((resolve, reject) => {
const bar = new ProgressBar()
const youTubeUrl = `https://youtube.com/${youTubeId}`
let currentEmoji = getRandomEmoji()
const emojiUpdateInterval = setInterval(() => currentEmoji = getRandomEmoji(), 1000) // eslint-disable-line
updateProgress()
const pulsBarInterval = setInterval(() => bar.pulse(currentEmoji), 60)
const YD = new YoutubeMp3Downloader({
ffmpegPath,
outputPath: path.join(userHome, 'Desktop'),
youtubeVideoQuality: 'highest',
queueParallelism: 2,
progressTimeout: 250,
})
YD.download(youTubeId)
YD.on('finished', ({file}) => {
cleanup()
resolve({file, episode})
})
YD.on('error', error => {
cleanup()
reject(error)
})
import fs from 'fs';
import chalk from 'chalk';
import os from 'os';
const libraryPath = configModule.get().plugins.music.library ? configModule.get().plugins.music.library + '/youtube' : (os.platform() === 'win32' ? 'C:/Windows/Temp/discord-bot-api/youtube' : '/tmp/discord-bot-api/youtube');
const youtubeOptions = {
outputPath: libraryPath,
queueParallelism: 10,
};
if (configModule.get().plugins.music.ffmpeg) youtubeOptions.ffmpegPath = configModule.get().plugins.music.ffmpeg;
let YD = new YoutubeMp3Downloader(youtubeOptions);
events.on('config reloaded', () => {
if (configModule.get().plugins.music.ffmpeg) youtubeOptions.ffmpegPath = configModule.get().plugins.music.ffmpeg;
YD = new YoutubeMp3Downloader(youtubeOptions);
});
const playlist = []; // All requested songs will be saved in this array
let voiceChannelID = null; // The ID of the voice channel the bot has entered will be saved in this variable
let currentSong = null; // The current song will be saved in this variable
const downloadQueue = {};
let usersWantToSkip = []; // The id of the users that want to skip the current song will be stored in this array
let currentStream = null;
let disableLiveDownloadProgress = true; // Because of rate limiting
let finishedListener = function() { // Wrapper lets this function called only once (because of the weird event emits from the YouTube download library)
events.on('config reloaded', () => {
if (configModule.get().plugins.music.ffmpeg) youtubeOptions.ffmpegPath = configModule.get().plugins.music.ffmpeg;
YD = new YoutubeMp3Downloader(youtubeOptions);
});