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