Spaces:
Paused
Paused
Update index.js
Browse files
index.js
CHANGED
|
@@ -160,13 +160,16 @@ async function getAudioMP3Url(videoUrl) {
|
|
| 160 |
try {
|
| 161 |
const info = await ytdl.getInfo(videoUrl);
|
| 162 |
const audioFormat = ytdl.chooseFormat(info.formats, { filter: 'audioonly', quality: 'highestaudio' });
|
|
|
|
|
|
|
|
|
|
| 163 |
const path_audio = path.join(tempDir, generateRandomName(10) + '.mp3');
|
| 164 |
let uploadResult;
|
| 165 |
let convert;
|
| 166 |
|
| 167 |
await new Promise((resolve, reject) => {
|
| 168 |
ffmpeg()
|
| 169 |
-
.input(
|
| 170 |
.outputOptions('-f mp3')
|
| 171 |
.outputOptions('-acodec libmp3lame')
|
| 172 |
.outputOptions('-ab 128k')
|
|
|
|
| 160 |
try {
|
| 161 |
const info = await ytdl.getInfo(videoUrl);
|
| 162 |
const audioFormat = ytdl.chooseFormat(info.formats, { filter: 'audioonly', quality: 'highestaudio' });
|
| 163 |
+
const requestData = {"url":videoUrl,"vQuality":"360","filenamePattern":"pretty","isAudioOnly":"true"}
|
| 164 |
+
const config = { headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', 'User-Agent': 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36', 'Referer': 'https://cobalt.tools/' } };
|
| 165 |
+
const { data: video } = await axios.post('https://api.cobalt.tools/api/json', requestData, config);
|
| 166 |
const path_audio = path.join(tempDir, generateRandomName(10) + '.mp3');
|
| 167 |
let uploadResult;
|
| 168 |
let convert;
|
| 169 |
|
| 170 |
await new Promise((resolve, reject) => {
|
| 171 |
ffmpeg()
|
| 172 |
+
.input(video.url)
|
| 173 |
.outputOptions('-f mp3')
|
| 174 |
.outputOptions('-acodec libmp3lame')
|
| 175 |
.outputOptions('-ab 128k')
|