UNPKG

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

77 lines (65 loc) 2.19 kB
/* ################## ERROR WEB GET CLOUDFLARE ############### const got = require('got'); const cheerio = require('cheerio'); const SFILE_MOBI_URL_REGEX = /sfile\.mobi/i; const DOWNLOAD_VAR_REGEX = /var z = (.*?);/i; const DB_VAR_REGEX = /var db = "(.*?)"/i; const SF_VAR_REGEX = /var sf = "(.*?)"/i; const ICON_REGEX = /\/smallicon\/(.*?)\.svg/; async function sfilemobi(url) { if (!SFILE_MOBI_URL_REGEX.test(url)) throw new Error(`Invalid URL: ${url}`); const response = await got(url); const html = response.body; const $ = cheerio.load(html); const $k = DOWNLOAD_VAR_REGEX.exec($.html())?.[1]; const dlUrl = ( (DB_VAR_REGEX.exec($.html())?.[1] || SF_VAR_REGEX.exec($.html())?.[1])?.replace(/\\(\\)?/gi, '') || $('#download').attr('href') ) + `&k=${$k}`; const filename = $('div.intro-container > img').attr('alt') || $('div.intro-container > h1').text(); const icon = $('div.intro-container > img').attr('src'); const type = ICON_REGEX.exec(icon)?.[1]; const $list = $('div.list'); const mimetype = $list.eq(0).text().split('-')[1]?.trim(); const aploud = $list.eq(2).text().split('Uploaded:')[1]?.trim(); const $aploud = $list.eq(1).find('a'); const aploudby = $aploud.eq(0).text(); const aploudbyUrl = $aploud.eq(0).attr('href'); const aploudon = $aploud.eq(1).text(); const aploudonUrl = $aploud.eq(1).attr('href'); const downloads = parseInt($list.eq(3).text().split('Downloads:')[1]?.trim()); const filesizeH = /\((.*?)\)/i.exec($('#download').text())?.[1]; const filesize = filesizeH && parseFileSize(filesizeH); const result = { url: dlUrl, filename, icon, type, mimetype, aploud, aploudby, aploudbyUrl, aploudon, aploudonUrl, downloads, filesizeH, filesize }; return { author: "Herza", status: 200, result }; } function parseFileSize(filesize) { const units = { B: 1, KB: 1024, MB: 1024 * 1024, GB: 1024 * 1024 * 1024 }; const match = filesize.match(/(\d+(?:\.\d+)?)\s*(B|KB|MB|GB)/i); if (!match) return null; const [, value, unit] = match; return parseFloat(value) * units[unit.toUpperCase()]; } module.exports = { sfilemobi }; */