music: woo! parsing hlswith regex! woo! yeah!
This commit is contained in:
parent
ecaea6b9e2
commit
964dc27308
1 changed files with 13 additions and 3 deletions
|
@ -184,6 +184,7 @@ async function createVoiceConnection(guild_id, voice_id, text_id) {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const REGEX_HLS_AUDIO_TRACK = /#EXT-X-MEDIA:URI="(.+?)",TYPE=AUDIO,/;
|
||||||
async function enqueue({
|
async function enqueue({
|
||||||
guild_id,
|
guild_id,
|
||||||
voice_id,
|
voice_id,
|
||||||
|
@ -233,13 +234,22 @@ async function enqueue({
|
||||||
thumbnail = info?.thumbnailUrl;
|
thumbnail = info?.thumbnailUrl;
|
||||||
|
|
||||||
const hlsUrl = new URL(info.hls);
|
const hlsUrl = new URL(info.hls);
|
||||||
|
const hlsBase = await fetch(info.hls)
|
||||||
|
.then((res) => res.text())
|
||||||
|
.then((data) =>
|
||||||
|
data.replaceAll(
|
||||||
|
"/api/manifest/",
|
||||||
|
`https://${hlsUrl.hostname}/api/manifest/`
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
media = Readable.from(
|
media = Readable.from(
|
||||||
await fetch(info.hls)
|
await fetch(hlsBase.match(REGEX_HLS_AUDIO_TRACK)[1])
|
||||||
.then((res) => res.text())
|
.then((res) => res.text())
|
||||||
.then((data) =>
|
.then((data) =>
|
||||||
data.replaceAll(
|
data.replaceAll(
|
||||||
"/api/manifest/",
|
"/videoplayback/",
|
||||||
`https://${hlsUrl.hostname}/api/manifest/`
|
`https://${hlsUrl.hostname}/videoplayback/`
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue