Spaces:
Paused
Paused
Update index.js
Browse files
index.js
CHANGED
|
@@ -345,25 +345,31 @@ async function getAudioMP3Url(videoUrl) {
|
|
| 345 |
try {
|
| 346 |
const id_video = await GetId(videoUrl);
|
| 347 |
const infoVids = await getVideoDetailsWithApi(id_video);
|
|
|
|
| 348 |
|
| 349 |
const video = await fetchCobaltOnly(videoUrl, { downloadMode: "audio", audioBitrate: "128" })
|
| 350 |
console.log(video)
|
|
|
|
| 351 |
|
| 352 |
|
| 353 |
// Unduh file audio terlebih dahulu
|
| 354 |
-
|
| 355 |
const video = await cobalt({
|
| 356 |
url: videoUrl,
|
|
|
|
| 357 |
filenameStyle: "pretty",
|
| 358 |
audioFormat: "mp3",
|
| 359 |
audioBitrate: "128"
|
| 360 |
-
})
|
| 361 |
-
*/
|
| 362 |
const path_audio = path.join(tempDir, generateRandomName(10) + '.mp3');
|
| 363 |
const path_audio_edit = path_audio.replace('.mp3', '_edit.mp3');
|
| 364 |
|
| 365 |
// Download file audio
|
| 366 |
-
const
|
|
|
|
|
|
|
|
|
|
|
|
|
| 367 |
fs.writeFileSync(path_audio, response.data);
|
| 368 |
|
| 369 |
// Periksa apakah file input valid
|
|
@@ -415,6 +421,7 @@ async function getAudioMP3Url(videoUrl) {
|
|
| 415 |
status: 200,
|
| 416 |
title: infoVids.title,
|
| 417 |
result: {
|
|
|
|
| 418 |
url_path: `https://${process.env.SPACE_HOST}/temp/${path.basename(path_audio)}`,
|
| 419 |
curl_path: `https://${process.env.SPACE_HOST}/temp/${path.basename(path_audio)}?download=1&filename=${infoVids.title}`,
|
| 420 |
path: path_audio
|
|
|
|
| 345 |
try {
|
| 346 |
const id_video = await GetId(videoUrl);
|
| 347 |
const infoVids = await getVideoDetailsWithApi(id_video);
|
| 348 |
+
/*
|
| 349 |
|
| 350 |
const video = await fetchCobaltOnly(videoUrl, { downloadMode: "audio", audioBitrate: "128" })
|
| 351 |
console.log(video)
|
| 352 |
+
*/
|
| 353 |
|
| 354 |
|
| 355 |
// Unduh file audio terlebih dahulu
|
| 356 |
+
|
| 357 |
const video = await cobalt({
|
| 358 |
url: videoUrl,
|
| 359 |
+
downloadMode: "audio",
|
| 360 |
filenameStyle: "pretty",
|
| 361 |
audioFormat: "mp3",
|
| 362 |
audioBitrate: "128"
|
| 363 |
+
})
|
|
|
|
| 364 |
const path_audio = path.join(tempDir, generateRandomName(10) + '.mp3');
|
| 365 |
const path_audio_edit = path_audio.replace('.mp3', '_edit.mp3');
|
| 366 |
|
| 367 |
// Download file audio
|
| 368 |
+
const headers = {
|
| 369 |
+
'User-Agent': 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Mobile Safari/537.36',
|
| 370 |
+
'Referer': 'https://cobalt.tools/pustaka/'
|
| 371 |
+
};
|
| 372 |
+
const response = await axios.get(video.result.url, { responseType: 'arraybuffer', headers });
|
| 373 |
fs.writeFileSync(path_audio, response.data);
|
| 374 |
|
| 375 |
// Periksa apakah file input valid
|
|
|
|
| 421 |
status: 200,
|
| 422 |
title: infoVids.title,
|
| 423 |
result: {
|
| 424 |
+
fileName: video.result.filename,
|
| 425 |
url_path: `https://${process.env.SPACE_HOST}/temp/${path.basename(path_audio)}`,
|
| 426 |
curl_path: `https://${process.env.SPACE_HOST}/temp/${path.basename(path_audio)}?download=1&filename=${infoVids.title}`,
|
| 427 |
path: path_audio
|