Update plugins/sora2.js
Browse files- plugins/sora2.js +74 -62
plugins/sora2.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
const axios = require('axios');
|
| 2 |
const dns = require('dns').promises;
|
| 3 |
|
| 4 |
-
const PROXY_URL = 'https://
|
| 5 |
|
| 6 |
dns.setServers([
|
| 7 |
'1.1.1.1',
|
|
@@ -24,30 +24,8 @@ function generatePassword() {
|
|
| 24 |
return password;
|
| 25 |
}
|
| 26 |
|
| 27 |
-
let cachedProxyIP = null;
|
| 28 |
-
|
| 29 |
-
async function resolveProxyIP() {
|
| 30 |
-
if (cachedProxyIP) {
|
| 31 |
-
return cachedProxyIP;
|
| 32 |
-
}
|
| 33 |
-
|
| 34 |
-
try {
|
| 35 |
-
const hostname = 'young-sunset-2246.herzfnf.workers.dev';
|
| 36 |
-
const addresses = await dns.resolve4(hostname);
|
| 37 |
-
cachedProxyIP = addresses[0];
|
| 38 |
-
console.log(`DNS Resolved: ${hostname} -> ${cachedProxyIP}`);
|
| 39 |
-
return cachedProxyIP;
|
| 40 |
-
} catch (error) {
|
| 41 |
-
console.error('DNS resolution failed:', error.message);
|
| 42 |
-
return null;
|
| 43 |
-
}
|
| 44 |
-
}
|
| 45 |
-
|
| 46 |
async function proxyRequest(url, options = {}) {
|
| 47 |
const targetPath = url.startsWith('http') ? url : url;
|
| 48 |
-
const encodedPath = encodeURIComponent(targetPath);
|
| 49 |
-
|
| 50 |
-
let proxyUrl = `${PROXY_URL}?url=${encodedPath}`;
|
| 51 |
|
| 52 |
const headers = {
|
| 53 |
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
|
|
@@ -56,10 +34,12 @@ async function proxyRequest(url, options = {}) {
|
|
| 56 |
};
|
| 57 |
|
| 58 |
const axiosConfig = {
|
| 59 |
-
url: proxyUrl,
|
| 60 |
method: options.method || 'GET',
|
| 61 |
headers: headers,
|
| 62 |
timeout: 30000,
|
|
|
|
|
|
|
|
|
|
| 63 |
validateStatus: function (status) {
|
| 64 |
return status >= 200 && status < 600;
|
| 65 |
}
|
|
@@ -73,32 +53,27 @@ async function proxyRequest(url, options = {}) {
|
|
| 73 |
|
| 74 |
for (let attempt = 1; attempt <= 3; attempt++) {
|
| 75 |
try {
|
| 76 |
-
|
|
|
|
|
|
|
| 77 |
const response = await axios(axiosConfig);
|
| 78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
|
| 80 |
} catch (error) {
|
| 81 |
lastError = error;
|
| 82 |
console.error(`Attempt ${attempt} failed:`, error.code || error.message);
|
| 83 |
|
| 84 |
-
if (error.code === 'ENOTFOUND' || error.code === 'EAI_AGAIN') {
|
| 85 |
-
console.log('DNS issue detected, trying to resolve...');
|
| 86 |
-
const ip = await resolveProxyIP();
|
| 87 |
-
|
| 88 |
-
if (ip && attempt === 1) {
|
| 89 |
-
console.log(`Retrying with resolved IP: ${ip}`);
|
| 90 |
-
axiosConfig.url = proxyUrl.replace('young-sunset-2246.herzfnf.workers.dev', ip);
|
| 91 |
-
axiosConfig.headers['Host'] = 'young-sunset-2246.herzfnf.workers.dev';
|
| 92 |
-
}
|
| 93 |
-
|
| 94 |
-
if (attempt < 3) {
|
| 95 |
-
await new Promise(resolve => setTimeout(resolve, 2000 * attempt));
|
| 96 |
-
continue;
|
| 97 |
-
}
|
| 98 |
-
}
|
| 99 |
-
|
| 100 |
if (attempt < 3) {
|
| 101 |
-
await new Promise(resolve => setTimeout(resolve,
|
| 102 |
}
|
| 103 |
}
|
| 104 |
}
|
|
@@ -107,6 +82,7 @@ async function proxyRequest(url, options = {}) {
|
|
| 107 |
}
|
| 108 |
|
| 109 |
async function createTempEmail() {
|
|
|
|
| 110 |
const { data } = await axios.post('https://api.internal.temp-mail.io/api/v3/email/new', {
|
| 111 |
min_name_length: 10,
|
| 112 |
max_name_length: 10
|
|
@@ -120,10 +96,12 @@ async function createTempEmail() {
|
|
| 120 |
timeout: 15000
|
| 121 |
});
|
| 122 |
|
|
|
|
| 123 |
return data;
|
| 124 |
}
|
| 125 |
|
| 126 |
async function getHcaptchaToken() {
|
|
|
|
| 127 |
const { data } = await axios.get(
|
| 128 |
'https://anabot.my.id/api/tools/bypass?url=https%3A%2F%2Fapi.hcaptcha.com&siteKey=6f70c0f2-3ef6-4972-9fb6-c0b4bade3af8&type=hcaptcha-invisible&apikey=freeApikey',
|
| 129 |
{
|
|
@@ -135,10 +113,12 @@ async function getHcaptchaToken() {
|
|
| 135 |
throw new Error('Failed to get hCaptcha token');
|
| 136 |
}
|
| 137 |
|
|
|
|
| 138 |
return data.data.result.token;
|
| 139 |
}
|
| 140 |
|
| 141 |
async function sendVerificationEmail(email) {
|
|
|
|
| 142 |
const hcaptchaToken = await getHcaptchaToken();
|
| 143 |
const encodedEmail = encodeURIComponent(email);
|
| 144 |
|
|
@@ -158,11 +138,13 @@ async function sendVerificationEmail(email) {
|
|
| 158 |
throw new Error(`Failed to send verification email: ${data.msg || 'Unknown error'}`);
|
| 159 |
}
|
| 160 |
|
|
|
|
| 161 |
await new Promise(resolve => setTimeout(resolve, 3000));
|
| 162 |
return true;
|
| 163 |
}
|
| 164 |
|
| 165 |
async function getVerificationCode(email) {
|
|
|
|
| 166 |
let attempts = 0;
|
| 167 |
const maxAttempts = 30;
|
| 168 |
|
|
@@ -188,11 +170,13 @@ async function getVerificationCode(email) {
|
|
| 188 |
const codeMatch = bodyText.match(/Verification Code:\s*(\d{6})/);
|
| 189 |
|
| 190 |
if (codeMatch) {
|
|
|
|
| 191 |
return codeMatch[1];
|
| 192 |
}
|
| 193 |
}
|
| 194 |
|
| 195 |
attempts++;
|
|
|
|
| 196 |
} catch (error) {
|
| 197 |
console.log(`Email check attempt ${attempts} failed:`, error.message);
|
| 198 |
attempts++;
|
|
@@ -203,6 +187,7 @@ async function getVerificationCode(email) {
|
|
| 203 |
}
|
| 204 |
|
| 205 |
async function registerAccount(email, password, verificationCode) {
|
|
|
|
| 206 |
const { data } = await proxyRequest('/api/auth/register', {
|
| 207 |
method: 'POST',
|
| 208 |
headers: {
|
|
@@ -223,10 +208,12 @@ async function registerAccount(email, password, verificationCode) {
|
|
| 223 |
throw new Error(`Registration failed: ${data.msg || 'Unknown error'}`);
|
| 224 |
}
|
| 225 |
|
|
|
|
| 226 |
return data.data.token;
|
| 227 |
}
|
| 228 |
|
| 229 |
async function createVideo(prompt, ratio, authToken, email) {
|
|
|
|
| 230 |
await new Promise(resolve => setTimeout(resolve, 2000));
|
| 231 |
|
| 232 |
const { data } = await proxyRequest('/aimodels/api/v1/ai/video/create', {
|
|
@@ -257,6 +244,7 @@ async function createVideo(prompt, ratio, authToken, email) {
|
|
| 257 |
throw new Error(`Failed to create video: ${data.message || 'Unknown error'}`);
|
| 258 |
}
|
| 259 |
|
|
|
|
| 260 |
return data.data;
|
| 261 |
}
|
| 262 |
|
|
@@ -276,6 +264,7 @@ async function getTaskStatus(taskId, authToken) {
|
|
| 276 |
}
|
| 277 |
|
| 278 |
async function waitForVideoCompletion(taskId, authToken) {
|
|
|
|
| 279 |
let attempts = 0;
|
| 280 |
const maxAttempts = 120;
|
| 281 |
|
|
@@ -284,8 +273,11 @@ async function waitForVideoCompletion(taskId, authToken) {
|
|
| 284 |
|
| 285 |
const taskData = await getTaskStatus(taskId, authToken);
|
| 286 |
|
|
|
|
|
|
|
| 287 |
if (taskData.state === 1 && taskData.completeData) {
|
| 288 |
const completeData = JSON.parse(taskData.completeData);
|
|
|
|
| 289 |
return completeData.data.result_urls[0];
|
| 290 |
}
|
| 291 |
|
|
@@ -296,32 +288,26 @@ async function waitForVideoCompletion(taskId, authToken) {
|
|
| 296 |
attempts++;
|
| 297 |
}
|
| 298 |
|
| 299 |
-
throw new Error('Video generation timeout');
|
| 300 |
}
|
| 301 |
|
| 302 |
async function sora2(prompt, ratio = 'portrait') {
|
| 303 |
-
console.log('Starting Sora2
|
|
|
|
|
|
|
| 304 |
|
| 305 |
const tempMail = await createTempEmail();
|
| 306 |
const email = tempMail.email;
|
| 307 |
const password = generatePassword();
|
| 308 |
|
| 309 |
-
console.log(`Email created: ${email}`);
|
| 310 |
-
|
| 311 |
await sendVerificationEmail(email);
|
| 312 |
-
console.log('Verification email sent');
|
| 313 |
-
|
| 314 |
const verificationCode = await getVerificationCode(email);
|
| 315 |
-
console.log(`Verification code received: ${verificationCode}`);
|
| 316 |
-
|
| 317 |
const authToken = await registerAccount(email, password, verificationCode);
|
| 318 |
-
console.log('Account registered successfully');
|
| 319 |
-
|
| 320 |
const taskId = await createVideo(prompt, ratio, authToken, email);
|
| 321 |
-
console.log(`Video task created: ${taskId}`);
|
| 322 |
-
|
| 323 |
const videoUrl = await waitForVideoCompletion(taskId, authToken);
|
| 324 |
-
|
|
|
|
|
|
|
| 325 |
|
| 326 |
return {
|
| 327 |
success: true,
|
|
@@ -333,6 +319,8 @@ async function sora2(prompt, ratio = 'portrait') {
|
|
| 333 |
}
|
| 334 |
|
| 335 |
const handler = async (req, res) => {
|
|
|
|
|
|
|
| 336 |
try {
|
| 337 |
const { prompt, key, ratio = 'portrait' } = req.query;
|
| 338 |
|
|
@@ -340,7 +328,8 @@ const handler = async (req, res) => {
|
|
| 340 |
return res.status(400).json({
|
| 341 |
author: 'Herza',
|
| 342 |
success: false,
|
| 343 |
-
msg: 'Missing required parameter: prompt'
|
|
|
|
| 344 |
});
|
| 345 |
}
|
| 346 |
|
|
@@ -360,8 +349,21 @@ const handler = async (req, res) => {
|
|
| 360 |
});
|
| 361 |
}
|
| 362 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 363 |
const result = await sora2(prompt, ratio);
|
| 364 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 365 |
res.json({
|
| 366 |
author: 'Herza',
|
| 367 |
success: true,
|
|
@@ -374,25 +376,35 @@ const handler = async (req, res) => {
|
|
| 374 |
account: {
|
| 375 |
email: result.email,
|
| 376 |
password: result.password
|
| 377 |
-
}
|
|
|
|
| 378 |
}
|
| 379 |
});
|
| 380 |
} catch (error) {
|
| 381 |
-
console.error('
|
|
|
|
|
|
|
|
|
|
|
|
|
| 382 |
res.status(500).json({
|
| 383 |
author: 'Herza',
|
| 384 |
success: false,
|
| 385 |
-
msg: error.message || 'Terjadi kesalahan saat generate video.'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 386 |
});
|
| 387 |
}
|
| 388 |
}
|
| 389 |
|
| 390 |
module.exports = {
|
| 391 |
name: 'Sora2 Video Generator',
|
| 392 |
-
description: 'Generate videos using Sora2 AI model from Bylo.ai',
|
| 393 |
type: 'GET',
|
| 394 |
routes: ['api/AI/sora2'],
|
| 395 |
-
tags: ['AI', 'Sora', 'OpenAI'],
|
| 396 |
parameters: ['prompt', 'ratio', 'key'],
|
| 397 |
enabled: true,
|
| 398 |
main: ['AI'],
|
|
|
|
| 1 |
const axios = require('axios');
|
| 2 |
const dns = require('dns').promises;
|
| 3 |
|
| 4 |
+
const PROXY_URL = 'https://proxy-sigma-roan.vercel.app/api/proxy';
|
| 5 |
|
| 6 |
dns.setServers([
|
| 7 |
'1.1.1.1',
|
|
|
|
| 24 |
return password;
|
| 25 |
}
|
| 26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
async function proxyRequest(url, options = {}) {
|
| 28 |
const targetPath = url.startsWith('http') ? url : url;
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
const headers = {
|
| 31 |
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
|
|
|
|
| 34 |
};
|
| 35 |
|
| 36 |
const axiosConfig = {
|
|
|
|
| 37 |
method: options.method || 'GET',
|
| 38 |
headers: headers,
|
| 39 |
timeout: 30000,
|
| 40 |
+
params: {
|
| 41 |
+
url: targetPath
|
| 42 |
+
},
|
| 43 |
validateStatus: function (status) {
|
| 44 |
return status >= 200 && status < 600;
|
| 45 |
}
|
|
|
|
| 53 |
|
| 54 |
for (let attempt = 1; attempt <= 3; attempt++) {
|
| 55 |
try {
|
| 56 |
+
axiosConfig.url = PROXY_URL;
|
| 57 |
+
console.log(`Attempt ${attempt}: ${PROXY_URL}?url=${targetPath}`);
|
| 58 |
+
|
| 59 |
const response = await axios(axiosConfig);
|
| 60 |
+
|
| 61 |
+
if (response.status >= 200 && response.status < 300) {
|
| 62 |
+
return response;
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
console.log(`Attempt ${attempt} got status ${response.status}`);
|
| 66 |
+
|
| 67 |
+
if (attempt < 3) {
|
| 68 |
+
await new Promise(resolve => setTimeout(resolve, 1000 * attempt));
|
| 69 |
+
}
|
| 70 |
|
| 71 |
} catch (error) {
|
| 72 |
lastError = error;
|
| 73 |
console.error(`Attempt ${attempt} failed:`, error.code || error.message);
|
| 74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
if (attempt < 3) {
|
| 76 |
+
await new Promise(resolve => setTimeout(resolve, 2000 * attempt));
|
| 77 |
}
|
| 78 |
}
|
| 79 |
}
|
|
|
|
| 82 |
}
|
| 83 |
|
| 84 |
async function createTempEmail() {
|
| 85 |
+
console.log('Creating temporary email...');
|
| 86 |
const { data } = await axios.post('https://api.internal.temp-mail.io/api/v3/email/new', {
|
| 87 |
min_name_length: 10,
|
| 88 |
max_name_length: 10
|
|
|
|
| 96 |
timeout: 15000
|
| 97 |
});
|
| 98 |
|
| 99 |
+
console.log(`Email created: ${data.email}`);
|
| 100 |
return data;
|
| 101 |
}
|
| 102 |
|
| 103 |
async function getHcaptchaToken() {
|
| 104 |
+
console.log('Getting hCaptcha token...');
|
| 105 |
const { data } = await axios.get(
|
| 106 |
'https://anabot.my.id/api/tools/bypass?url=https%3A%2F%2Fapi.hcaptcha.com&siteKey=6f70c0f2-3ef6-4972-9fb6-c0b4bade3af8&type=hcaptcha-invisible&apikey=freeApikey',
|
| 107 |
{
|
|
|
|
| 113 |
throw new Error('Failed to get hCaptcha token');
|
| 114 |
}
|
| 115 |
|
| 116 |
+
console.log('hCaptcha token obtained');
|
| 117 |
return data.data.result.token;
|
| 118 |
}
|
| 119 |
|
| 120 |
async function sendVerificationEmail(email) {
|
| 121 |
+
console.log(`Sending verification email to ${email}...`);
|
| 122 |
const hcaptchaToken = await getHcaptchaToken();
|
| 123 |
const encodedEmail = encodeURIComponent(email);
|
| 124 |
|
|
|
|
| 138 |
throw new Error(`Failed to send verification email: ${data.msg || 'Unknown error'}`);
|
| 139 |
}
|
| 140 |
|
| 141 |
+
console.log('Verification email sent successfully');
|
| 142 |
await new Promise(resolve => setTimeout(resolve, 3000));
|
| 143 |
return true;
|
| 144 |
}
|
| 145 |
|
| 146 |
async function getVerificationCode(email) {
|
| 147 |
+
console.log('Waiting for verification code...');
|
| 148 |
let attempts = 0;
|
| 149 |
const maxAttempts = 30;
|
| 150 |
|
|
|
|
| 170 |
const codeMatch = bodyText.match(/Verification Code:\s*(\d{6})/);
|
| 171 |
|
| 172 |
if (codeMatch) {
|
| 173 |
+
console.log(`Verification code received: ${codeMatch[1]}`);
|
| 174 |
return codeMatch[1];
|
| 175 |
}
|
| 176 |
}
|
| 177 |
|
| 178 |
attempts++;
|
| 179 |
+
console.log(`Checking for verification code... attempt ${attempts}/${maxAttempts}`);
|
| 180 |
} catch (error) {
|
| 181 |
console.log(`Email check attempt ${attempts} failed:`, error.message);
|
| 182 |
attempts++;
|
|
|
|
| 187 |
}
|
| 188 |
|
| 189 |
async function registerAccount(email, password, verificationCode) {
|
| 190 |
+
console.log('Registering account...');
|
| 191 |
const { data } = await proxyRequest('/api/auth/register', {
|
| 192 |
method: 'POST',
|
| 193 |
headers: {
|
|
|
|
| 208 |
throw new Error(`Registration failed: ${data.msg || 'Unknown error'}`);
|
| 209 |
}
|
| 210 |
|
| 211 |
+
console.log('Account registered successfully');
|
| 212 |
return data.data.token;
|
| 213 |
}
|
| 214 |
|
| 215 |
async function createVideo(prompt, ratio, authToken, email) {
|
| 216 |
+
console.log('Creating video task...');
|
| 217 |
await new Promise(resolve => setTimeout(resolve, 2000));
|
| 218 |
|
| 219 |
const { data } = await proxyRequest('/aimodels/api/v1/ai/video/create', {
|
|
|
|
| 244 |
throw new Error(`Failed to create video: ${data.message || 'Unknown error'}`);
|
| 245 |
}
|
| 246 |
|
| 247 |
+
console.log(`Video task created with ID: ${data.data}`);
|
| 248 |
return data.data;
|
| 249 |
}
|
| 250 |
|
|
|
|
| 264 |
}
|
| 265 |
|
| 266 |
async function waitForVideoCompletion(taskId, authToken) {
|
| 267 |
+
console.log('Waiting for video generation...');
|
| 268 |
let attempts = 0;
|
| 269 |
const maxAttempts = 120;
|
| 270 |
|
|
|
|
| 273 |
|
| 274 |
const taskData = await getTaskStatus(taskId, authToken);
|
| 275 |
|
| 276 |
+
console.log(`Video status check ${attempts + 1}/${maxAttempts} - State: ${taskData.state}`);
|
| 277 |
+
|
| 278 |
if (taskData.state === 1 && taskData.completeData) {
|
| 279 |
const completeData = JSON.parse(taskData.completeData);
|
| 280 |
+
console.log('Video generation completed!');
|
| 281 |
return completeData.data.result_urls[0];
|
| 282 |
}
|
| 283 |
|
|
|
|
| 288 |
attempts++;
|
| 289 |
}
|
| 290 |
|
| 291 |
+
throw new Error('Video generation timeout after 10 minutes');
|
| 292 |
}
|
| 293 |
|
| 294 |
async function sora2(prompt, ratio = 'portrait') {
|
| 295 |
+
console.log('=== Starting Sora2 Video Generation ===');
|
| 296 |
+
console.log(`Prompt: ${prompt}`);
|
| 297 |
+
console.log(`Ratio: ${ratio}`);
|
| 298 |
|
| 299 |
const tempMail = await createTempEmail();
|
| 300 |
const email = tempMail.email;
|
| 301 |
const password = generatePassword();
|
| 302 |
|
|
|
|
|
|
|
| 303 |
await sendVerificationEmail(email);
|
|
|
|
|
|
|
| 304 |
const verificationCode = await getVerificationCode(email);
|
|
|
|
|
|
|
| 305 |
const authToken = await registerAccount(email, password, verificationCode);
|
|
|
|
|
|
|
| 306 |
const taskId = await createVideo(prompt, ratio, authToken, email);
|
|
|
|
|
|
|
| 307 |
const videoUrl = await waitForVideoCompletion(taskId, authToken);
|
| 308 |
+
|
| 309 |
+
console.log('=== Video Generation Completed ===');
|
| 310 |
+
console.log(`Video URL: ${videoUrl}`);
|
| 311 |
|
| 312 |
return {
|
| 313 |
success: true,
|
|
|
|
| 319 |
}
|
| 320 |
|
| 321 |
const handler = async (req, res) => {
|
| 322 |
+
const startTime = Date.now();
|
| 323 |
+
|
| 324 |
try {
|
| 325 |
const { prompt, key, ratio = 'portrait' } = req.query;
|
| 326 |
|
|
|
|
| 328 |
return res.status(400).json({
|
| 329 |
author: 'Herza',
|
| 330 |
success: false,
|
| 331 |
+
msg: 'Missing required parameter: prompt',
|
| 332 |
+
usage: '/api/AI/sora2?prompt=your_prompt&ratio=portrait&key=your_key'
|
| 333 |
});
|
| 334 |
}
|
| 335 |
|
|
|
|
| 349 |
});
|
| 350 |
}
|
| 351 |
|
| 352 |
+
console.log(`\n${'='.repeat(60)}`);
|
| 353 |
+
console.log('NEW REQUEST RECEIVED');
|
| 354 |
+
console.log(`Prompt: ${prompt}`);
|
| 355 |
+
console.log(`Ratio: ${ratio}`);
|
| 356 |
+
console.log(`${'='.repeat(60)}\n`);
|
| 357 |
+
|
| 358 |
const result = await sora2(prompt, ratio);
|
| 359 |
|
| 360 |
+
const duration = ((Date.now() - startTime) / 1000).toFixed(2);
|
| 361 |
+
|
| 362 |
+
console.log(`\n${'='.repeat(60)}`);
|
| 363 |
+
console.log('REQUEST COMPLETED');
|
| 364 |
+
console.log(`Duration: ${duration}s`);
|
| 365 |
+
console.log(`${'='.repeat(60)}\n`);
|
| 366 |
+
|
| 367 |
res.json({
|
| 368 |
author: 'Herza',
|
| 369 |
success: true,
|
|
|
|
| 376 |
account: {
|
| 377 |
email: result.email,
|
| 378 |
password: result.password
|
| 379 |
+
},
|
| 380 |
+
processingTime: `${duration}s`
|
| 381 |
}
|
| 382 |
});
|
| 383 |
} catch (error) {
|
| 384 |
+
console.error('\n❌ ERROR:', error.message);
|
| 385 |
+
console.error('Stack:', error.stack);
|
| 386 |
+
|
| 387 |
+
const duration = ((Date.now() - startTime) / 1000).toFixed(2);
|
| 388 |
+
|
| 389 |
res.status(500).json({
|
| 390 |
author: 'Herza',
|
| 391 |
success: false,
|
| 392 |
+
msg: error.message || 'Terjadi kesalahan saat generate video.',
|
| 393 |
+
processingTime: `${duration}s`,
|
| 394 |
+
error: {
|
| 395 |
+
code: error.code || 'UNKNOWN',
|
| 396 |
+
details: error.response?.data || null
|
| 397 |
+
}
|
| 398 |
});
|
| 399 |
}
|
| 400 |
}
|
| 401 |
|
| 402 |
module.exports = {
|
| 403 |
name: 'Sora2 Video Generator',
|
| 404 |
+
description: 'Generate videos using Sora2 AI model from Bylo.ai via Vercel Proxy',
|
| 405 |
type: 'GET',
|
| 406 |
routes: ['api/AI/sora2'],
|
| 407 |
+
tags: ['AI', 'Sora', 'OpenAI', 'Video'],
|
| 408 |
parameters: ['prompt', 'ratio', 'key'],
|
| 409 |
enabled: true,
|
| 410 |
main: ['AI'],
|