Informations Vidéo

This commit is contained in:
MasterAcnolo
2025-06-27 15:42:46 +02:00
parent 95701bf56e
commit d4d36c39ca
4 changed files with 121 additions and 1 deletions

View File

@@ -9,6 +9,8 @@ if (!fs.existsSync("downloads")) { // Si jamais il n'y a pas de dossier download
fs.mkdirSync("downloads"); // On le crée
}
app.use(express.static("public")); // Ca c'est pour ouvrir le serveur, comme ça plus besoin d'utiliser live server
app.post("/download", (req, res) => {
const options = {
url: req.body.url,
@@ -56,6 +58,26 @@ app.post("/download", (req, res) => {
});
});
app.post("/info", (req,res) =>{
const url = req.body.url;
if (!url) return res.status(400).send("❌ URL manquante");
const command = `yt-dlp --dump-json "${url}"`;
exec(command, (error, stdout, stderr) => {
if (error) {
return res.status(500).send("❌ Impossible de récupérer les infos.");
}
try {
const info = JSON.parse(stdout);
res.json(info);
} catch (e) {
res.status(500).send("❌ JSON illisible.");
}
});
});
app.listen(8080, () => {
console.log("🟢 Serveur prêt sur http://localhost:8080");
});