Spaces:
Sleeping

File size: 992 Bytes
30dafdf
 
fee8415
30dafdf
 
fee8415
30dafdf
 
f40d904
30dafdf
f857cfd
 
 
 
 
 
 
 
 
 
 
 
 
 
fee8415
 
 
c152519
f857cfd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const express = require('express');
const cors = require('cors');
const { exec } = require('child_process');

const app = express();
app.use(cors({ origin: '*' }));
app.use(express.json());

app.post('/api/download', (req, res) => {
  const { url } = req.body;
  if (!url) return res.status(400).json({ success: false, message: "URL kosong" });

  // Menggunakan biner yt-dlp hasil unduhan release-files untuk mengambil format gabungan terbaik
  const command = `yt-dlp -g -f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best" --no-warnings --no-check-certificates "${url.trim()}"`;

  exec(command, { timeout: 30000 }, (error, stdout) => {
    if (error) {
      return res.status(500).json({ success: false, message: "Banned IP oleh YouTube." });
    }
    const lines = stdout.trim().split('\n');
    res.json({
      success: true,
      videoUrl: lines[0],
      audioUrl: lines[1] || lines[0]
    });
  });
});

app.listen(7860, () => console.log("Server Biner Release Siap."));