Loading snippets...
download for multiple platforms from one for all
import fs from "node:fs/promises";
import axios from "axios";
import * as cheerio from "cheerio";
const API = "https://savefbs.com/api/v1/aio/html";
async function getVideoData(videoUrl) {
const { data: html } = await axios.post(
API,
{
vid: videoUrl,
prefix: "savefbs.com",
ex: "",
format: ""
},
{
headers: {
"content-type": "application/json",
referer: "https://savefbs.com/all-in-one-video-downloader/",
"user-agent":
"Mozilla/5.0 (Linux; Android 10) AppleWebKit/537.36 Chrome/137 Mobile Safari/537.36"
}
}
);
const $ = cheerio.load(html);
// ===== BASIC INFO =====
const title = $("h3.text-sm").text().trim() || null;
const description =
$(".text-gray-700").text().trim() ||
$(".text-gray-600").text().trim() ||
null;
const owner =
$("p.text-gray-600")
.first()
.text()
.replace("Owner:", "")
.trim() || null;
const thumbnail = $("img.aio-thumbnail").attr("src") || null;
// ===== DOWNLOAD LINKS =====
const downloads = [];
$("a.download-btn").each((_, el) => {
const url = $(el).attr("href");
const label = $(el).text().trim();
if (url) {
downloads.push({
type: label,
url
});
}
});
// ===== RESULT =====
const result = {
title,
description,
owner,
thumbnail,
downloads
};
await fs.writeFile(
"result.json",
JSON.stringify(result, null, 2)
);
// download thumbnail optional
if (thumbnail) {
const img = await axios.get(thumbnail, {
responseType: "arraybuffer"
});
await fs.writeFile("thumbnail.jpg", img.data);
}
console.log("DONE ✔");
console.log(result);
return result;
}
// RUN
getVideoData("https://vt.tiktok.com/ZSx4HhBh8/");