wolfyflutter

www.onlineconverter.com [converter] [webp] [mp4]

Jul 1st, 2025 (edited)
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 2.71 KB | Source Code | 0 0
  1. /*
  2.    base   : https://www.onlineconverter.com/webp-to-mp4
  3.    fungsi : ngubah file .webp jadi .mp4
  4.             cikal bakal fitur sticker to video
  5.    node   : v24.2.0
  6.    req    : ghofar
  7.    by     : wolep
  8.    update : 1 Juli 2025, 14:00 WITA
  9.    note   : gabisa spam hit ya bre, ada cooldown nya sejam.
  10.             makek fetch dan formdata bawaan cuy..
  11.             boleh makek axios + form-data kalau mauu
  12. */
  13.  
  14.  
  15. const oc = {
  16.     upload: async (webpBuffer) => {
  17.         const file = new File([webpBuffer], Date.now() + ".webp", { type: "image/webp" })
  18.         const body = new FormData()
  19.         body.append("file", file)
  20.         body.append("class", "video")
  21.         body.append("from", "webp")
  22.         body.append("to", "mp4")
  23.         body.append("source", "online")
  24.  
  25.         const r = await fetch("https://host21.onlineconverter.com/file/send", {
  26.             "headers": {
  27.                 "Referer": "https://www.onlineconverter.com/",
  28.                 ...body.headers
  29.             },
  30.             body,
  31.             "method": "POST"
  32.         })
  33.  
  34.         if (!r.ok) throw Error(`fetch upload is not ok! ${r.status} ${r.statusText}\n${await r.text() || null}`)
  35.         const url = await r.text()
  36.         return url
  37.     },
  38.  
  39.     cekProgress: async (validUploadUrl) => {
  40.         const id = validUploadUrl?.match(/https:\/\/www.onlineconverter.com\/convert\/(\w+)/)?.[1]
  41.         if (!id) throw Error(`unexpected link input di fungsi cekProgress`)
  42.         let status
  43.         do {
  44.             const r = await fetch(`https://host21.onlineconverter.com/file/${id}`)
  45.             if (!r.ok) throw Error(`fetch cekProgress is not ok! ${r.status} ${r.statusText}\n${await r.text() || null}`)
  46.             status = await r.text()
  47.             const lagi_ngapain =
  48.                 status == "s" ? "lagi ngantre" :
  49.                     status == "c" ? "lagi converting.." :
  50.                         status == "d" ? "udah nih" : "eee gatau.. status " + status
  51.  
  52.             console.log(`${id} - ${lagi_ngapain}`)
  53.             if (status == "i") throw Error(`kebanyakan request, lu kena cooldown sejam.`)
  54.             if (status == "d") return `https://host21.onlineconverter.com/file/${id}/download`
  55.             await new Promise(re => setTimeout(re, 5000))
  56.         } while (["w", "s", "c"].includes(status))
  57.     },
  58.  
  59.     run: async (webpBuffer) => {
  60.         const url = await oc.upload(webpBuffer)
  61.         const result = await oc.cekProgress(url)
  62.         return result
  63.     }
  64. }
  65.  
  66. // cara pakai
  67. const myBuff = require("fs").readFileSync("./sticker.webp")
  68. oc.run(myBuff)
  69.     .then(console.log)
  70.     .catch(error => console.log(error.message))
  71.  
  72. // result https://host21.onlineconverter.com/file/218e1bd72c8ebd1be388b7f4bbb9aa3e4c/download
Tags: mp4 convert webp
Advertisement
Add Comment
Please, Sign In to add comment