Spaces:
Paused
Paused
Update index.js
Browse files
index.js
CHANGED
|
@@ -345,8 +345,7 @@ async function getAudioMP3Url(videoUrl) {
|
|
| 345 |
const infoVids = await getVideoDetailsWithApi(id_video);
|
| 346 |
|
| 347 |
// Unduh file audio terlebih dahulu
|
| 348 |
-
|
| 349 |
-
const video = await fetchCobaltOnly(obj.url, { isAudioOnly: 'audio', vQuality: 'max', filenamePattern:"pretty"})
|
| 350 |
const path_audio = path.join(tempDir, generateRandomName(10) + '.mp3');
|
| 351 |
const path_audio_edit = path_audio.replace('.mp3', '_edit.mp3');
|
| 352 |
|
|
@@ -357,7 +356,7 @@ async function getAudioMP3Url(videoUrl) {
|
|
| 357 |
// Tambahkan metadata ke file yang diunduh
|
| 358 |
await new Promise((resolve, reject) => {
|
| 359 |
ffmpeg(path_audio)
|
| 360 |
-
.outputOptions('-
|
| 361 |
.on('end', async () => {
|
| 362 |
try {
|
| 363 |
// Tambahkan metadata
|
|
@@ -395,13 +394,14 @@ async function getAudioMP3Url(videoUrl) {
|
|
| 395 |
};
|
| 396 |
} catch (error) {
|
| 397 |
console.error('Error:', error);
|
| 398 |
-
throw new Error('Failed to process audio URL');
|
| 399 |
}
|
| 400 |
}
|
| 401 |
|
| 402 |
|
| 403 |
|
| 404 |
|
|
|
|
| 405 |
app.get('/ytmp3', async (req, res) => {
|
| 406 |
try {
|
| 407 |
const { url } = req.query;
|
|
|
|
| 345 |
const infoVids = await getVideoDetailsWithApi(id_video);
|
| 346 |
|
| 347 |
// Unduh file audio terlebih dahulu
|
| 348 |
+
const video = await fetchCobaltOnly(videoUrl, { isAudioOnly: 'audio', vQuality: 'max' });
|
|
|
|
| 349 |
const path_audio = path.join(tempDir, generateRandomName(10) + '.mp3');
|
| 350 |
const path_audio_edit = path_audio.replace('.mp3', '_edit.mp3');
|
| 351 |
|
|
|
|
| 356 |
// Tambahkan metadata ke file yang diunduh
|
| 357 |
await new Promise((resolve, reject) => {
|
| 358 |
ffmpeg(path_audio)
|
| 359 |
+
.outputOptions('-acodec', 'libmp3lame', '-ab', '128k', '-ar', '44100')
|
| 360 |
.on('end', async () => {
|
| 361 |
try {
|
| 362 |
// Tambahkan metadata
|
|
|
|
| 394 |
};
|
| 395 |
} catch (error) {
|
| 396 |
console.error('Error:', error);
|
| 397 |
+
throw new Error('Failed to process audio URL :\n\n' + error);
|
| 398 |
}
|
| 399 |
}
|
| 400 |
|
| 401 |
|
| 402 |
|
| 403 |
|
| 404 |
+
|
| 405 |
app.get('/ytmp3', async (req, res) => {
|
| 406 |
try {
|
| 407 |
const { url } = req.query;
|