Spaces:
Paused
Paused
Update index.js
Browse files
index.js
CHANGED
|
@@ -249,7 +249,7 @@ function generateRandomName(length) {
|
|
| 249 |
|
| 250 |
async function fetchCobaltOnly(url, opts = {}) {
|
| 251 |
try {
|
| 252 |
-
const response = await axios.post('https://
|
| 253 |
return response.data;
|
| 254 |
} catch (error) {
|
| 255 |
if (error.response) {
|
|
@@ -273,7 +273,8 @@ async function getAudioMP3Url(videoUrl) {
|
|
| 273 |
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/' } };
|
| 274 |
*/
|
| 275 |
let obj = { url: videoUrl }
|
| 276 |
-
const video = await
|
|
|
|
| 277 |
const path_audio = path.join(tempDir, generateRandomName(10) + '.mp3');
|
| 278 |
const id_video = await GetId(videoUrl);
|
| 279 |
const infoVids = await getVideoDetailsWithApi(id_video);
|
|
@@ -282,7 +283,7 @@ async function getAudioMP3Url(videoUrl) {
|
|
| 282 |
|
| 283 |
await new Promise((resolve, reject) => {
|
| 284 |
ffmpeg()
|
| 285 |
-
.input(video)
|
| 286 |
.outputOptions('-f mp3')
|
| 287 |
.outputOptions('-acodec libmp3lame')
|
| 288 |
.outputOptions('-ab 128k')
|
|
|
|
| 249 |
|
| 250 |
async function fetchCobaltOnly(url, opts = {}) {
|
| 251 |
try {
|
| 252 |
+
const response = await axios.post('https://cobalt-7.kwiatekmiki.com/api/json', { url, ...opts }, { headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' } } );
|
| 253 |
return response.data;
|
| 254 |
} catch (error) {
|
| 255 |
if (error.response) {
|
|
|
|
| 273 |
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/' } };
|
| 274 |
*/
|
| 275 |
let obj = { url: videoUrl }
|
| 276 |
+
const video = await fetchCobaltOnly(obj.url, { isAudioOnly: 'audio', vQuality: 'max' })
|
| 277 |
+
|
| 278 |
const path_audio = path.join(tempDir, generateRandomName(10) + '.mp3');
|
| 279 |
const id_video = await GetId(videoUrl);
|
| 280 |
const infoVids = await getVideoDetailsWithApi(id_video);
|
|
|
|
| 283 |
|
| 284 |
await new Promise((resolve, reject) => {
|
| 285 |
ffmpeg()
|
| 286 |
+
.input(video.url)
|
| 287 |
.outputOptions('-f mp3')
|
| 288 |
.outputOptions('-acodec libmp3lame')
|
| 289 |
.outputOptions('-ab 128k')
|