🔥 Temporarily remove support for soundcloud
This commit is contained in:
parent
d47be162d7
commit
7783e423e9
2 changed files with 1 additions and 74 deletions
|
@ -33,7 +33,6 @@
|
||||||
"merge-options": "^2.0.0",
|
"merge-options": "^2.0.0",
|
||||||
"node-fetch": "^2.6.0",
|
"node-fetch": "^2.6.0",
|
||||||
"simple-youtube-api": "^5.2.1",
|
"simple-youtube-api": "^5.2.1",
|
||||||
"soundcloud-downloader": "^0.0.9",
|
|
||||||
"ytpl": "^0.1.21",
|
"ytpl": "^0.1.21",
|
||||||
"ytsr": "^0.1.15"
|
"ytsr": "^0.1.15"
|
||||||
},
|
},
|
||||||
|
|
|
@ -2,7 +2,6 @@ const ytdl = require('discord-ytdl-core')
|
||||||
const Discord = require('discord.js')
|
const Discord = require('discord.js')
|
||||||
const ytsr = require('ytsr')
|
const ytsr = require('ytsr')
|
||||||
const ytpl = require('ytpl')
|
const ytpl = require('ytpl')
|
||||||
const scdl = require('soundcloud-downloader')
|
|
||||||
|
|
||||||
const Queue = require('./Queue')
|
const Queue = require('./Queue')
|
||||||
const Track = require('./Track')
|
const Track = require('./Track')
|
||||||
|
@ -45,7 +44,6 @@ const filters = {
|
||||||
* @property {boolean} [leaveOnEnd=true] Whether the bot should leave the current voice channel when the queue ends.
|
* @property {boolean} [leaveOnEnd=true] Whether the bot should leave the current voice channel when the queue ends.
|
||||||
* @property {boolean} [leaveOnStop=true] Whether the bot should leave the current voice channel when the stop() function is used.
|
* @property {boolean} [leaveOnStop=true] Whether the bot should leave the current voice channel when the stop() function is used.
|
||||||
* @property {boolean} [leaveOnEmpty=true] Whether the bot should leave the voice channel if there is no more member in it.
|
* @property {boolean} [leaveOnEmpty=true] Whether the bot should leave the voice channel if there is no more member in it.
|
||||||
* @property {string} [soundcloudClientID=""] The client ID for Soundcloud, optional
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -56,8 +54,7 @@ const filters = {
|
||||||
const defaultPlayerOptions = {
|
const defaultPlayerOptions = {
|
||||||
leaveOnEnd: true,
|
leaveOnEnd: true,
|
||||||
leaveOnStop: true,
|
leaveOnStop: true,
|
||||||
leaveOnEmpty: true,
|
leaveOnEmpty: true
|
||||||
soundcloudClientID: ''
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class Player {
|
class Player {
|
||||||
|
@ -183,21 +180,6 @@ class Player {
|
||||||
const matchURL = query.match(/(?:youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=)|youtu\.be\/)([^"&?\/\s]{11})/)
|
const matchURL = query.match(/(?:youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=)|youtu\.be\/)([^"&?\/\s]{11})/)
|
||||||
if (matchURL) {
|
if (matchURL) {
|
||||||
query = matchURL[1]
|
query = matchURL[1]
|
||||||
} else if (this.options.soundcloudClientID) {
|
|
||||||
const scRegex = /^https?:\/\/(soundcloud\.com)\/(.*)$/
|
|
||||||
if (query.match(scRegex) && query.match(scRegex)[2]) {
|
|
||||||
const info = await scdl.getInfo(query, this.options.soundcloudClientID)
|
|
||||||
const details = {
|
|
||||||
title: info.title,
|
|
||||||
link: info.uri,
|
|
||||||
duration: info.duration,
|
|
||||||
description: info.description,
|
|
||||||
thumbnail: info.artwork_url,
|
|
||||||
views: info.playback_count,
|
|
||||||
author: { name: info.user.username }
|
|
||||||
}
|
|
||||||
return resolve([new Track(details, null, null)])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ytsr(query, (err, results) => {
|
ytsr(query, (err, results) => {
|
||||||
if (err) return resolve([])
|
if (err) return resolve([])
|
||||||
|
@ -835,51 +817,6 @@ class Player {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Play a Soundcloud stream in a channel
|
|
||||||
* @ignore
|
|
||||||
* @private
|
|
||||||
* @param {Queue} queue The queue to play
|
|
||||||
* @param {Boolean} updateFilter Whether this method is called to update some ffmpeg filters
|
|
||||||
* @returns {Promise<void>}
|
|
||||||
*/
|
|
||||||
_playSouncloudStream (queue, updateFilter) {
|
|
||||||
return new Promise(async (resolve) => {
|
|
||||||
const currentStreamTime = updateFilter ? queue.voiceConnection.dispatcher.streamTime / 1000 : undefined
|
|
||||||
const encoderArgsFilters = []
|
|
||||||
Object.keys(queue.filters).forEach((filterName) => {
|
|
||||||
if (queue.filters[filterName]) {
|
|
||||||
encoderArgsFilters.push(filters[filterName])
|
|
||||||
}
|
|
||||||
})
|
|
||||||
let encoderArgs
|
|
||||||
if (encoderArgsFilters.length < 1) {
|
|
||||||
encoderArgs = []
|
|
||||||
} else {
|
|
||||||
encoderArgs = ['-af', encoderArgsFilters.join(',')]
|
|
||||||
}
|
|
||||||
|
|
||||||
const info = await scdl.getInfo(queue.playing.url, this.options.soundcloudClientID)
|
|
||||||
const opus = scdl.filterMedia(info.media.transcodings, { format: scdl.FORMATS.OPUS })
|
|
||||||
const newStream = await scdl.downloadFromURL(opus[0].url, this.options.soundcloudClientID)
|
|
||||||
setTimeout(() => {
|
|
||||||
queue.voiceConnection.play(newStream, {
|
|
||||||
type: 'ogg/opus'
|
|
||||||
})
|
|
||||||
queue.voiceConnection.dispatcher.setVolumeLogarithmic(queue.calculatedVolume / 200)
|
|
||||||
// When the track starts
|
|
||||||
queue.voiceConnection.dispatcher.on('start', () => {
|
|
||||||
resolve()
|
|
||||||
})
|
|
||||||
// When the track ends
|
|
||||||
queue.voiceConnection.dispatcher.on('finish', () => {
|
|
||||||
// Play the next track
|
|
||||||
return this._playTrack(queue.guildID, false)
|
|
||||||
})
|
|
||||||
}, 1000)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start playing a track in a guild
|
* Start playing a track in a guild
|
||||||
* @ignore
|
* @ignore
|
||||||
|
@ -909,15 +846,6 @@ class Player {
|
||||||
// Reset lastSkipped state
|
// Reset lastSkipped state
|
||||||
queue.lastSkipped = false
|
queue.lastSkipped = false
|
||||||
|
|
||||||
if (queue.playing.url.includes('soundcloud.com')) {
|
|
||||||
this._playSouncloudStream(queue, false).then(() => {
|
|
||||||
// Emit trackChanged event
|
|
||||||
if (!firstPlay) {
|
|
||||||
queue.emit('trackChanged', nowPlaying, wasPlaying, queue.lastSkipped, queue.repeatMode)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this._playYTDLStream(queue, false).then(() => {
|
this._playYTDLStream(queue, false).then(() => {
|
||||||
// Emit trackChanged event
|
// Emit trackChanged event
|
||||||
if (!firstPlay) {
|
if (!firstPlay) {
|
||||||
|
|
Loading…
Reference in a new issue