music: try readable wrap

This commit is contained in:
Cynthia Foxwell 2023-09-12 22:51:51 -06:00
parent 07b1b93a3e
commit 96b2a600a8

View file

@ -1,5 +1,6 @@
const {Collection} = require("@projectdysnomia/dysnomia");
const {Readable} = require("node:stream");
const ffprobe = require("node-ffprobe");
const Command = require("../lib/command.js");
@ -230,9 +231,11 @@ async function enqueue({
length = info?.duration * 1000;
thumbnail = info?.thumbnailUrl;
media = await fetch(
info?.audioStreams?.sort((a, b) => a.bitrate - b.bitrate)?.[0]?.url
).then((res) => res.body);
media = Readable.from(
await fetch(
info?.audioStreams?.sort((a, b) => a.bitrate - b.bitrate)?.[0]?.url
).then((res) => res.body)
);
} else if (type == "sc") {
if (url?.startsWith("sc:"))
url = url.replace(/^sc:/, "https://soundcloud.com/");