notmebotz-tools
Version:
Sebuah Tools yang berfungsi untuk mendownload Video atau Foto dari media sosial, serta sebagai tools yang berguna untuk aplikasi kamu seperti untuk BOT
49 lines (43 loc) • 1.59 kB
JavaScript
/*
SCRAPE BY https://whatsapp.com/channel/0029Vb2mOzL1Hsq0lIEHoR0N/144
*/
const axios = require('axios');
const cheerio = require('cheerio');
async function capcutdl(url) {
try {
const response = await axios.get(url);
const html = response.data;
const $ = cheerio.load(html);
const videoElement = $('video.player-o3g3Ag');
const videoSrc = videoElement.attr('src');
const posterSrc = videoElement.attr('poster');
const title = $('h1.template-title').text().trim();
const actionsDetail = $('p.actions-detail').text().trim();
const [date, uses, likes] = actionsDetail.split(',').map(item => item.trim());
const authorAvatar = $('span.lv-avatar-image img').attr('src');
const authorName = $('span.lv-avatar-image img').attr('alt');
if (!videoSrc || !posterSrc || !title || !date || !uses || !likes || !authorAvatar || !authorName) {
throw new Error('Beberapa elemen penting tidak ditemukan di halaman.');
}
return {
author: "Herza",
status: 200,
results: {
title: title,
date: date,
pengguna: uses,
likes: likes,
author: {
name: authorName,
avatarUrl: authorAvatar
},
videoUrl: videoSrc,
posterUrl: posterSrc
}
};
} catch (error) {
console.error('Error fetching video details:', error.message);
return null;
}
}
module.exports = { capcutdl }