Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Aritek API Wrapper
- * Feature : Text To Video & Text To Image
- * Author : gienetic
- * Base : https://play.google.com/store/apps/details?id=ai.video.generator.text.video
- */
- const axios = require("axios")
- const { randomUUID } = require("crypto")
- const AUTH_TOKEN = "eyJzdWIiwsdeOiIyMzQyZmczNHJ0MzR0weMzQiLCJuYW1lIjorwiSm9objMdf0NTM0NT"
- const SIGN_TOKEN = "e5fce0f8136217ad645df2a0cb1f1188dd2fbab8"
- const API_BASE = "https://t2v2.aritek.app"
- function getRandomDeviceID() {
- return randomUUID().replace(/-/g, "").slice(0, 16)
- }
- async function translateToEnglish(text) {
- try {
- const url = "https://translate.googleapis.com/translate_a/single"
- const params = { client: "gtx", sl: "auto", tl: "en", dt: "t", q: text }
- const res = await axios.get(url, { params })
- return res.data[0][0][0]
- } catch {
- return text
- }
- }
- async function generateVideo(prompt) {
- const translatedPrompt = await translateToEnglish(prompt)
- try {
- let key = null
- while (!key) {
- try {
- const submit = await axios.post(
- `${API_BASE}/videos`,
- {
- deviceID: getRandomDeviceID(),
- isPremium: 1,
- prompt: translatedPrompt,
- used: [],
- versionCode: 6
- },
- {
- headers: {
- authorization: AUTH_TOKEN,
- "content-type": "application/json; charset=utf-8",
- "accept-encoding": "gzip",
- "user-agent": "okhttp/5.1.0"
- },
- decompress: true
- }
- )
- if (submit.data?.key) {
- key = submit.data.key
- console.log("✅ Video job submitted. Key:", key)
- } else {
- console.log("⚠️ Server busy, retrying in 5s...")
- await new Promise(r => setTimeout(r, 5000))
- }
- } catch (err) {
- if (err.response?.data?.error?.includes("No available slot")) {
- console.log("⚠️ No slot available, retrying in 5s...")
- await new Promise(r => setTimeout(r, 5000))
- } else {
- throw err
- }
- }
- }
- while (true) {
- const res = await axios.post(
- `${API_BASE}/videos/batch`,
- { keys: [key] },
- {
- headers: {
- authorization: AUTH_TOKEN,
- "content-type": "application/json; charset=utf-8",
- "accept-encoding": "gzip",
- "user-agent": "okhttp/5.1.0"
- },
- decompress: true
- }
- )
- const result = res.data?.datas?.[0]
- if (result?.url) {
- console.log("🎬 Video ready:", result.url)
- return {
- url: result.url,
- video_id: result.id || key,
- ...result
- }
- }
- console.log("⏳ Belum siap, tunggu 5 detik...")
- await new Promise(r => setTimeout(r, 5000))
- }
- } catch (err) {
- console.error("❌ Video request failed:", err.response?.data || err.message)
- throw err
- }
- }
- async function generateImage(prompt) {
- try {
- const res = await axios.post(
- `${API_BASE}/images`,
- {
- ctry_target: "others",
- prompt
- },
- {
- headers: {
- authorization: AUTH_TOKEN,
- sign: SIGN_TOKEN,
- pt: "",
- "content-type": "application/json; charset=UTF-8",
- "accept-encoding": "gzip",
- "user-agent": "okhttp/5.1.0"
- },
- decompress: true
- }
- )
- if (res.data?.code === 0 && res.data?.data) {
- console.log("🖼️ Image ready:", res.data.data)
- return { url: res.data.data }
- } else {
- throw new Error("Image generation failed (no URL returned)")
- }
- } catch (err) {
- console.error("❌ Image request failed:", err.response?.data || err.message)
- throw err
- }
- }
- module.exports = { generateVideo, generateImage }
Advertisement
Add Comment
Please, Sign In to add comment