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

53 lines (44 loc) 1.69 kB
/* PXPIC (removebg, enhance, upscale, restore, colorize) * By *Shannz* (Versi tanpa *qs*) */ const fs = require('fs') const axios = require('axios') const { fromBuffer } = require('file-type') async function Pxpic(path, func) { const tool = ['removebg', 'enhance', 'upscale', 'restore', 'colorize'] if (!tool.includes(func)) return `Tersedia: ${tool.join(', ')}` const buffer = fs.readFileSync(path) const fileInfo = await fromBuffer(buffer) const ext = fileInfo?.ext || 'bin' const mime = fileInfo?.mime || 'application/octet-stream' const fileName = Math.random().toString(36).slice(2, 8) + '.' + ext const { data } = await axios.post("https://pxpic.com/getSignedUrl", { folder: "uploads", fileName }, { headers: { "Content-Type": "application/json" } }) await axios.put(data.presignedUrl, buffer, { headers: { "Content-Type": mime } }) const url = "https://files.fotoenhancer.com/uploads/" + fileName const api = await axios.post("https://pxpic.com/callAiFunction", new URLSearchParams({ imageUrl: url, targetFormat: 'png', needCompress: 'no', imageQuality: '100', compressLevel: '6', fileOriginalExtension: 'png', aiFunction: func, upscalingLevel: '' }).toString(), { headers: { 'User-Agent': 'Mozilla/5.0 (Android 10; Mobile; rv:131.0) Gecko/131.0 Firefox/131.0', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/png,image/svg+xml,*/*;q=0.8', 'Content-Type': 'application/x-www-form-urlencoded', 'accept-language': 'id-ID' } }) return { author: "Herza", status: 200, ...api.data } } module.exports = { Pxpic }