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