Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- base : https://www.onlineconverter.com/webp-to-mp4
- fungsi : ngubah file .webp jadi .mp4
- cikal bakal fitur sticker to video
- node : v24.2.0
- req : ghofar
- by : wolep
- update : 1 Juli 2025, 14:00 WITA
- note : gabisa spam hit ya bre, ada cooldown nya sejam.
- makek fetch dan formdata bawaan cuy..
- boleh makek axios + form-data kalau mauu
- */
- const oc = {
- upload: async (webpBuffer) => {
- const file = new File([webpBuffer], Date.now() + ".webp", { type: "image/webp" })
- const body = new FormData()
- body.append("file", file)
- body.append("class", "video")
- body.append("from", "webp")
- body.append("to", "mp4")
- body.append("source", "online")
- const r = await fetch("https://host21.onlineconverter.com/file/send", {
- "headers": {
- "Referer": "https://www.onlineconverter.com/",
- ...body.headers
- },
- body,
- "method": "POST"
- })
- if (!r.ok) throw Error(`fetch upload is not ok! ${r.status} ${r.statusText}\n${await r.text() || null}`)
- const url = await r.text()
- return url
- },
- cekProgress: async (validUploadUrl) => {
- const id = validUploadUrl?.match(/https:\/\/www.onlineconverter.com\/convert\/(\w+)/)?.[1]
- if (!id) throw Error(`unexpected link input di fungsi cekProgress`)
- let status
- do {
- const r = await fetch(`https://host21.onlineconverter.com/file/${id}`)
- if (!r.ok) throw Error(`fetch cekProgress is not ok! ${r.status} ${r.statusText}\n${await r.text() || null}`)
- status = await r.text()
- const lagi_ngapain =
- status == "s" ? "lagi ngantre" :
- status == "c" ? "lagi converting.." :
- status == "d" ? "udah nih" : "eee gatau.. status " + status
- console.log(`${id} - ${lagi_ngapain}`)
- if (status == "i") throw Error(`kebanyakan request, lu kena cooldown sejam.`)
- if (status == "d") return `https://host21.onlineconverter.com/file/${id}/download`
- await new Promise(re => setTimeout(re, 5000))
- } while (["w", "s", "c"].includes(status))
- },
- run: async (webpBuffer) => {
- const url = await oc.upload(webpBuffer)
- const result = await oc.cekProgress(url)
- return result
- }
- }
- // cara pakai
- const myBuff = require("fs").readFileSync("./sticker.webp")
- oc.run(myBuff)
- .then(console.log)
- .catch(error => console.log(error.message))
- // result https://host21.onlineconverter.com/file/218e1bd72c8ebd1be388b7f4bbb9aa3e4c/download
Advertisement
Add Comment
Please, Sign In to add comment