feat(Queue): add spotifyBridge option
This commit is contained in:
parent
44b30ad615
commit
edb517c8c6
2 changed files with 6 additions and 3 deletions
|
@ -105,7 +105,8 @@ class Queue<T = unknown> {
|
|||
highWaterMark: 1 << 25
|
||||
},
|
||||
initialVolume: 100,
|
||||
bufferingTimeout: 3000
|
||||
bufferingTimeout: 3000,
|
||||
spotifyBridge: true
|
||||
} as PlayerOptions,
|
||||
options
|
||||
);
|
||||
|
@ -638,7 +639,7 @@ class Queue<T = unknown> {
|
|||
const customDownloader = typeof this.onBeforeCreateStream === "function";
|
||||
|
||||
if (["youtube", "spotify"].includes(track.raw.source)) {
|
||||
if (track.raw.source === "spotify" && !track.raw.engine) {
|
||||
if (this.options.spotifyBridge && track.raw.source === "spotify" && !track.raw.engine) {
|
||||
track.raw.engine = await YouTube.search(`${track.author} ${track.title}`, { type: "video" })
|
||||
.then((x) => x[0].url)
|
||||
.catch(() => null);
|
||||
|
@ -647,7 +648,7 @@ class Queue<T = unknown> {
|
|||
if (!link) return void this.play(this.tracks.shift(), { immediate: true });
|
||||
|
||||
if (customDownloader) {
|
||||
stream = (await this.onBeforeCreateStream(track, "youtube", this)) ?? null;
|
||||
stream = (await this.onBeforeCreateStream(track, track.raw.source || "youtube", this)) ?? null;
|
||||
if (stream)
|
||||
stream = ytdl
|
||||
.arbitraryStream(stream, {
|
||||
|
|
|
@ -128,6 +128,7 @@ export interface PlayerProgressbarOptions {
|
|||
* @property {YTDLDownloadOptions} [ytdlOptions={}] The youtube download options
|
||||
* @property {number} [initialVolume=100] The initial player volume
|
||||
* @property {number} [bufferingTimeout=3000] Buffering timeout for the stream
|
||||
* @property {boolean} [spotifyBridge=true] If player should bridge spotify source to youtube
|
||||
* @property {Function} [onBeforeCreateStream] Runs before creating stream
|
||||
*/
|
||||
export interface PlayerOptions {
|
||||
|
@ -139,6 +140,7 @@ export interface PlayerOptions {
|
|||
ytdlOptions?: downloadOptions;
|
||||
initialVolume?: number;
|
||||
bufferingTimeout?: number;
|
||||
spotifyBridge?: boolean;
|
||||
onBeforeCreateStream?: (track: Track, source: TrackSource, queue: Queue) => Promise<Readable>;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue