fix message and added other links support
This commit is contained in:
@@ -21,11 +21,10 @@ export async function requestSong(
|
|||||||
url: string,
|
url: string,
|
||||||
data: Partial<HistoryObject>
|
data: Partial<HistoryObject>
|
||||||
) {
|
) {
|
||||||
getAudioFile(url).then((path) => {
|
const path = await getAudioFile(url)
|
||||||
queue.songList.push({ path, url })
|
queue.songList.push({ path, url })
|
||||||
add_to_history({ url, user: data.user })
|
add_to_history({ url, user: data.user })
|
||||||
updatePlayer()
|
await updatePlayer()
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function forceRequestSong(
|
export async function forceRequestSong(
|
||||||
|
|||||||
@@ -18,8 +18,13 @@ export async function getAudioFile(url: string): Promise<string> {
|
|||||||
return path
|
return path
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isYTLink(url: string) {
|
||||||
|
return url.startsWith("https://youtube") ||
|
||||||
|
url.startsWith("https://youtu.be");
|
||||||
|
}
|
||||||
|
|
||||||
export async function extractId(url: string): Promise<string> {
|
export async function extractId(url: string): Promise<string> {
|
||||||
if (url.startsWith("https://soundcloud")) { // soundcloud
|
if (!isYTLink(url)) {
|
||||||
const ytDlpBin = process.env.YT_DLP_BIN_PATH! ?? "yt-dlp";
|
const ytDlpBin = process.env.YT_DLP_BIN_PATH! ?? "yt-dlp";
|
||||||
return await new Promise<string>((resolve, reject) => {
|
return await new Promise<string>((resolve, reject) => {
|
||||||
const p = spawn(ytDlpBin, [
|
const p = spawn(ytDlpBin, [
|
||||||
|
|||||||
Reference in New Issue
Block a user