/** * FileGoat file Hosting * base: https://filego.at * Creator: ShanMolvyr * reupload/modif cantumkan sumber ini woii parah * * Note: cek https://snippet.vyr.my.id/shanmolvyr/filegoat/README.md * Sumber Scraper: https://whatsapp.com/channel/0029VbB4Kw8EFeXfeExaXc3Q */ const axios = require("axios"); const FormData = require("form-data"); const fs = require("fs"); const path = require("path"); const mime = require("mime-types"); const { randomUUID } = require("crypto"); const BASE = "https://filego.at"; const S3_BASE = "https://filegoat.s3.de.io.cloud.ovh.net"; const HEADERS = { "accept-language": "id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7", "sec-ch-ua": '"Mises";v="141", "Not?A_Brand";v="8", "Chromium";v="141"', "sec-ch-ua-mobile": "?1", "sec-ch-ua-platform": '"Android"', "user-agent": "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Mobile Safari/537.36", referer: `${BASE}/`, origin: BASE, }; async function uploadFile(fp) { const form = new FormData(); form.append("file", fs.createReadStream(fp), { filename: path.basename(fp), contentType: mime.lookup(fp) || "application/octet-stream", }); const res = await axios.post(`${BASE}/api/file/upload`, form, { headers: { ...HEADERS, ...form.getHeaders(), accept: "application/json, text/plain, */*", }, maxBodyLength: Infinity, maxContentLength: Infinity, }); return res.data; } async function createBucket(fileIds, options = {}) { const { days = 7, extendOnView = false } = options; const res = await axios.post( `${BASE}/api/bucket`, { fileIds, deleteTime: days, extendOnView, clientId: randomUUID() }, { headers: { ...HEADERS, "content-type": "application/json", accept: "*/*", }, } ); return res.data; } async function getBucketFiles(slug) { const res = await axios.get(`${BASE}/api/bucket/${slug}`, { headers: { ...HEADERS, accept: "application/json" }, }); return res.data; } async function upload(filePaths, options = {}) { const files = Array.isArray(filePaths) ? filePaths : [filePaths]; const fileIds = []; for (const fp of files) { const res = await uploadFile(fp); const ids = res.fileIds ?? res.ids ?? [res.id]; fileIds.push(...ids); } const bucket = await createBucket(fileIds, options); const detail = await getBucketFiles(bucket.slug); const fileList = (detail.files || []).map((f) => { const name = f.fileName ?? f.file_name; const saved = f.savedName ?? f.saved_name; return { name, size: f.bytes, direct: `${S3_BASE}/${saved}/${name}`, download: `${S3_BASE}/${saved}/${name}?download=true`, }; }); return { slug: bucket.slug, url: `${BASE}/bucket/${bucket.slug}`, expires: bucket.delete_time, files: fileList, }; } async function get(slug) { const data = await getBucketFiles(slug); const fileList = (data.files || []).map((f) => { const name = f.fileName ?? f.file_name; const saved = f.savedName ?? f.saved_name; return { name, size: f.bytes, downloads: f.downloads, createdAt: f.createdAt ?? f.created_at, direct: `${S3_BASE}/${saved}/${name}`, download: `${S3_BASE}/${saved}/${name}?download=true`, }; }); return { slug: data.slug, url: `${BASE}/bucket/${data.slug}`, expires: data.delete_time, extendOnView: data.extend_on_view, views: data.views, files: fileList, }; } const [, , cmd, ...args] = process.argv; (async () => { if (cmd === "upload") { const daysIdx = args.indexOf("--days"); const days = daysIdx !== -1 ? parseInt(args[daysIdx + 1]) : 7; const extend = args.includes("--extend"); const files = args.filter((a) => !a.startsWith("--") && isNaN(Number(a))); if (!files.length) { console.log(JSON.stringify({ error: "no files specified" }, null, 2)); process.exit(1); } const result = await upload(files, { days, extendOnView: extend }); console.log(JSON.stringify(result, null, 2)); } else if (cmd === "get") { const slug = args[0]; if (!slug) { console.log(JSON.stringify({ error: "slug required" }, null, 2)); process.exit(1); } const result = await get(slug); console.log(JSON.stringify(result, null, 2)); } else { console.log( JSON.stringify( { error: "unknown command", usage: { upload: "node filegoat.js upload [file2] [--days 7] [--extend]", get: "node filegoat.js get ", }, }, null, 2 ) ); process.exit(1); } })().catch((err) => { console.log(JSON.stringify({ error: err.response?.data ?? err.message }, null, 2)); process.exit(1); });