Spaces:
Paused
Paused
Update index.js
Browse files
index.js
CHANGED
|
@@ -406,8 +406,12 @@ async function getAudioMP3Url(videoUrl) {
|
|
| 406 |
const id_video = await GetId(videoUrl);
|
| 407 |
const infoVids = await getVideoDetailsWithApi(id_video);
|
| 408 |
|
|
|
|
|
|
|
|
|
|
| 409 |
const video = await fetchCobaltOnly(videoUrl, { downloadMode: "audio", audioBitrate: "128", filenameStyle: "pretty", audioFormat: "mp3"})
|
| 410 |
console.log(video)
|
|
|
|
| 411 |
|
| 412 |
// Unduh file audio terlebih dahulu
|
| 413 |
/*
|
|
@@ -427,7 +431,7 @@ async function getAudioMP3Url(videoUrl) {
|
|
| 427 |
'User-Agent': 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Mobile Safari/537.36',
|
| 428 |
'Referer': 'https://cobalt.tools/pustaka/'
|
| 429 |
};
|
| 430 |
-
const response = await axios.get(video.
|
| 431 |
fs.writeFileSync(path_audio, response.data);
|
| 432 |
|
| 433 |
// Periksa apakah file input valid
|
|
@@ -479,7 +483,7 @@ async function getAudioMP3Url(videoUrl) {
|
|
| 479 |
status: 200,
|
| 480 |
title: infoVids.title,
|
| 481 |
result: {
|
| 482 |
-
fileName: video.filename,
|
| 483 |
url_path: `https://${process.env.SPACE_HOST}/temp/${path.basename(path_audio)}`,
|
| 484 |
curl_path: `https://${process.env.SPACE_HOST}/temp/${path.basename(path_audio)}?download=1&filename=${infoVids.title}`,
|
| 485 |
path: path_audio
|
|
|
|
| 406 |
const id_video = await GetId(videoUrl);
|
| 407 |
const infoVids = await getVideoDetailsWithApi(id_video);
|
| 408 |
|
| 409 |
+
const video = await axios.get("https://api.siputzx.my.id/api/dl/youtube/mp3?url=" + videoUrl)
|
| 410 |
+
|
| 411 |
+
/*
|
| 412 |
const video = await fetchCobaltOnly(videoUrl, { downloadMode: "audio", audioBitrate: "128", filenameStyle: "pretty", audioFormat: "mp3"})
|
| 413 |
console.log(video)
|
| 414 |
+
*/
|
| 415 |
|
| 416 |
// Unduh file audio terlebih dahulu
|
| 417 |
/*
|
|
|
|
| 431 |
'User-Agent': 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Mobile Safari/537.36',
|
| 432 |
'Referer': 'https://cobalt.tools/pustaka/'
|
| 433 |
};
|
| 434 |
+
const response = await axios.get(video.data, { responseType: 'arraybuffer', headers });
|
| 435 |
fs.writeFileSync(path_audio, response.data);
|
| 436 |
|
| 437 |
// Periksa apakah file input valid
|
|
|
|
| 483 |
status: 200,
|
| 484 |
title: infoVids.title,
|
| 485 |
result: {
|
| 486 |
+
fileName: video.filename || infoVids.title + ".mp3",
|
| 487 |
url_path: `https://${process.env.SPACE_HOST}/temp/${path.basename(path_audio)}`,
|
| 488 |
curl_path: `https://${process.env.SPACE_HOST}/temp/${path.basename(path_audio)}?download=1&filename=${infoVids.title}`,
|
| 489 |
path: path_audio
|