Update plugins/sora2.js
Browse files- plugins/sora2.js +92 -74
plugins/sora2.js
CHANGED
|
@@ -1,52 +1,14 @@
|
|
| 1 |
const axios = require('axios');
|
| 2 |
-
const { HttpsProxyAgent } = require('https-proxy-agent');
|
| 3 |
const dns = require('dns').promises;
|
| 4 |
|
|
|
|
|
|
|
| 5 |
dns.setServers([
|
| 6 |
'1.1.1.1',
|
| 7 |
'8.8.8.8',
|
| 8 |
'8.8.4.4'
|
| 9 |
]);
|
| 10 |
|
| 11 |
-
async function fetchProxyList() {
|
| 12 |
-
try {
|
| 13 |
-
const response = await axios.get('https://cdn.jsdelivr.net/gh/proxifly/free-proxy-list@main/proxies/protocols/https/data.txt');
|
| 14 |
-
const proxies = response.data
|
| 15 |
-
.split('\n')
|
| 16 |
-
.map(line => line.trim())
|
| 17 |
-
.filter(line => line.startsWith('http'));
|
| 18 |
-
return proxies;
|
| 19 |
-
} catch (err) {
|
| 20 |
-
return [];
|
| 21 |
-
}
|
| 22 |
-
}
|
| 23 |
-
|
| 24 |
-
function getRandomProxy(proxyList) {
|
| 25 |
-
if (proxyList.length === 0) return null;
|
| 26 |
-
const randomIndex = Math.floor(Math.random() * proxyList.length);
|
| 27 |
-
return proxyList[randomIndex];
|
| 28 |
-
}
|
| 29 |
-
|
| 30 |
-
async function createAxiosWithProxy(proxyList, baseURL) {
|
| 31 |
-
const proxy = getRandomProxy(proxyList);
|
| 32 |
-
|
| 33 |
-
const config = {
|
| 34 |
-
baseURL,
|
| 35 |
-
timeout: 30000,
|
| 36 |
-
validateStatus: function (status) {
|
| 37 |
-
return status >= 200 && status < 600;
|
| 38 |
-
}
|
| 39 |
-
};
|
| 40 |
-
|
| 41 |
-
if (proxy) {
|
| 42 |
-
const httpsAgent = new HttpsProxyAgent(proxy);
|
| 43 |
-
config.httpsAgent = httpsAgent;
|
| 44 |
-
config.proxy = false;
|
| 45 |
-
}
|
| 46 |
-
|
| 47 |
-
return axios.create(config);
|
| 48 |
-
}
|
| 49 |
-
|
| 50 |
function generateUniqueId() {
|
| 51 |
return Array.from({ length: 32 }, () =>
|
| 52 |
Math.floor(Math.random() * 16).toString(16)
|
|
@@ -71,7 +33,9 @@ function generateRandomIP() {
|
|
| 71 |
return `${Math.floor(Math.random() * 255)}.${Math.floor(Math.random() * 255)}.${Math.floor(Math.random() * 255)}.${Math.floor(Math.random() * 255)}`;
|
| 72 |
}
|
| 73 |
|
| 74 |
-
async function proxyRequest(
|
|
|
|
|
|
|
| 75 |
const fakeIP = generateRandomIP();
|
| 76 |
|
| 77 |
const headers = {
|
|
@@ -85,30 +49,42 @@ async function proxyRequest(proxyList, url, options = {}) {
|
|
| 85 |
|
| 86 |
await randomDelay(500, 1500);
|
| 87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
let lastError = null;
|
| 89 |
|
| 90 |
for (let attempt = 1; attempt <= 3; attempt++) {
|
| 91 |
try {
|
| 92 |
-
|
|
|
|
| 93 |
|
| 94 |
-
const
|
| 95 |
-
method: options.method || 'GET',
|
| 96 |
-
url: url,
|
| 97 |
-
headers: headers,
|
| 98 |
-
};
|
| 99 |
-
|
| 100 |
-
if (options.data && (options.method === 'POST' || options.method === 'PUT')) {
|
| 101 |
-
axiosConfig.data = options.data;
|
| 102 |
-
}
|
| 103 |
|
| 104 |
-
|
|
|
|
| 105 |
|
| 106 |
if (response.status === 403) {
|
|
|
|
| 107 |
await randomDelay(3000, 5000);
|
| 108 |
throw new Error('API Bylo returned 403 Forbidden - possible rate limit or IP block');
|
| 109 |
}
|
| 110 |
|
| 111 |
if (response.status === 429) {
|
|
|
|
| 112 |
await randomDelay(5000, 10000);
|
| 113 |
if (attempt < 3) continue;
|
| 114 |
throw new Error('Rate limit exceeded');
|
|
@@ -132,9 +108,16 @@ async function proxyRequest(proxyList, url, options = {}) {
|
|
| 132 |
|
| 133 |
} catch (error) {
|
| 134 |
lastError = error;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
|
| 136 |
if (attempt < 3) {
|
| 137 |
const waitTime = 3000 * attempt;
|
|
|
|
| 138 |
await randomDelay(waitTime, waitTime + 2000);
|
| 139 |
}
|
| 140 |
}
|
|
@@ -144,6 +127,7 @@ async function proxyRequest(proxyList, url, options = {}) {
|
|
| 144 |
}
|
| 145 |
|
| 146 |
async function createTempEmail() {
|
|
|
|
| 147 |
const { data } = await axios.post('https://api.internal.temp-mail.io/api/v3/email/new', {
|
| 148 |
min_name_length: 10,
|
| 149 |
max_name_length: 10
|
|
@@ -157,14 +141,14 @@ async function createTempEmail() {
|
|
| 157 |
timeout: 15000
|
| 158 |
});
|
| 159 |
|
|
|
|
| 160 |
return data;
|
| 161 |
}
|
| 162 |
|
| 163 |
-
async function getHcaptchaToken(
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
'/api/tools/bypass?url=https%3A%2F%2Fapi.hcaptcha.com&siteKey=6f70c0f2-3ef6-4972-9fb6-c0b4bade3af8&type=hcaptcha-invisible&apikey=freeApikey',
|
| 168 |
{
|
| 169 |
timeout: 15000
|
| 170 |
}
|
|
@@ -174,19 +158,21 @@ async function getHcaptchaToken(proxyList) {
|
|
| 174 |
throw new Error('Failed to get hCaptcha token');
|
| 175 |
}
|
| 176 |
|
|
|
|
| 177 |
return data.data.result.token;
|
| 178 |
}
|
| 179 |
|
| 180 |
-
async function sendVerificationEmail(
|
|
|
|
|
|
|
| 181 |
await randomDelay(1000, 2000);
|
| 182 |
|
| 183 |
-
const hcaptchaToken = await getHcaptchaToken(
|
| 184 |
const encodedEmail = encodeURIComponent(email);
|
| 185 |
|
| 186 |
await randomDelay(500, 1000);
|
| 187 |
|
| 188 |
const { data } = await proxyRequest(
|
| 189 |
-
proxyList,
|
| 190 |
`/api/auth/send-captcha?email=${encodedEmail}&type=register`,
|
| 191 |
{
|
| 192 |
method: 'GET',
|
|
@@ -202,11 +188,13 @@ async function sendVerificationEmail(proxyList, email) {
|
|
| 202 |
throw new Error(`Failed to send verification email: ${data.msg || 'Unknown error'}`);
|
| 203 |
}
|
| 204 |
|
|
|
|
| 205 |
await randomDelay(3000, 5000);
|
| 206 |
return true;
|
| 207 |
}
|
| 208 |
|
| 209 |
async function getVerificationCode(email) {
|
|
|
|
| 210 |
let attempts = 0;
|
| 211 |
const maxAttempts = 30;
|
| 212 |
|
|
@@ -232,12 +220,15 @@ async function getVerificationCode(email) {
|
|
| 232 |
const codeMatch = bodyText.match(/Verification Code:\s*(\d{6})/);
|
| 233 |
|
| 234 |
if (codeMatch) {
|
|
|
|
| 235 |
return codeMatch[1];
|
| 236 |
}
|
| 237 |
}
|
| 238 |
|
| 239 |
attempts++;
|
|
|
|
| 240 |
} catch (error) {
|
|
|
|
| 241 |
attempts++;
|
| 242 |
}
|
| 243 |
}
|
|
@@ -245,8 +236,9 @@ async function getVerificationCode(email) {
|
|
| 245 |
throw new Error('Verification code not received after 30 attempts');
|
| 246 |
}
|
| 247 |
|
| 248 |
-
async function registerAccount(
|
| 249 |
-
|
|
|
|
| 250 |
method: 'POST',
|
| 251 |
headers: {
|
| 252 |
'Accept': 'application/json, text/plain, */*',
|
|
@@ -266,13 +258,15 @@ async function registerAccount(proxyList, email, password, verificationCode) {
|
|
| 266 |
throw new Error(`Registration failed: ${data.msg || 'Unknown error'}`);
|
| 267 |
}
|
| 268 |
|
|
|
|
| 269 |
return data.data.token;
|
| 270 |
}
|
| 271 |
|
| 272 |
-
async function createVideo(
|
|
|
|
| 273 |
await randomDelay(2000, 3000);
|
| 274 |
|
| 275 |
-
const { data } = await proxyRequest(
|
| 276 |
method: 'POST',
|
| 277 |
headers: {
|
| 278 |
'Content-Type': 'application/json',
|
|
@@ -300,13 +294,13 @@ async function createVideo(proxyList, prompt, ratio, authToken, email) {
|
|
| 300 |
throw new Error(`Failed to create video: ${data.message || 'Unknown error'}`);
|
| 301 |
}
|
| 302 |
|
|
|
|
| 303 |
return data.data;
|
| 304 |
}
|
| 305 |
|
| 306 |
-
async function getTaskStatus(
|
| 307 |
try {
|
| 308 |
const { data } = await proxyRequest(
|
| 309 |
-
proxyList,
|
| 310 |
`/aimodels/api/v1/ai/${taskId}?channel=SORA2`,
|
| 311 |
{
|
| 312 |
method: 'GET',
|
|
@@ -323,21 +317,26 @@ async function getTaskStatus(proxyList, taskId, authToken) {
|
|
| 323 |
|
| 324 |
return data.data;
|
| 325 |
} catch (error) {
|
|
|
|
| 326 |
throw error;
|
| 327 |
}
|
| 328 |
}
|
| 329 |
|
| 330 |
-
async function waitForVideoCompletion(
|
|
|
|
| 331 |
let attempts = 0;
|
| 332 |
const maxAttempts = 120;
|
| 333 |
|
| 334 |
while (attempts < maxAttempts) {
|
| 335 |
await randomDelay(5000, 7000);
|
| 336 |
|
| 337 |
-
const taskData = await getTaskStatus(
|
|
|
|
|
|
|
| 338 |
|
| 339 |
if (taskData.state === 1 && taskData.completeData) {
|
| 340 |
const completeData = JSON.parse(taskData.completeData);
|
|
|
|
| 341 |
return completeData.data.result_urls[0];
|
| 342 |
}
|
| 343 |
|
|
@@ -352,17 +351,22 @@ async function waitForVideoCompletion(proxyList, taskId, authToken) {
|
|
| 352 |
}
|
| 353 |
|
| 354 |
async function sora2(prompt, ratio = 'portrait') {
|
| 355 |
-
|
|
|
|
|
|
|
| 356 |
|
| 357 |
const tempMail = await createTempEmail();
|
| 358 |
const email = tempMail.email;
|
| 359 |
const password = generatePassword();
|
| 360 |
|
| 361 |
-
await sendVerificationEmail(
|
| 362 |
const verificationCode = await getVerificationCode(email);
|
| 363 |
-
const authToken = await registerAccount(
|
| 364 |
-
const taskId = await createVideo(
|
| 365 |
-
const videoUrl = await waitForVideoCompletion(
|
|
|
|
|
|
|
|
|
|
| 366 |
|
| 367 |
return {
|
| 368 |
success: true,
|
|
@@ -404,10 +408,21 @@ const handler = async (req, res) => {
|
|
| 404 |
});
|
| 405 |
}
|
| 406 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 407 |
const result = await sora2(prompt, ratio);
|
| 408 |
|
| 409 |
const duration = ((Date.now() - startTime) / 1000).toFixed(2);
|
| 410 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 411 |
res.json({
|
| 412 |
author: 'Herza',
|
| 413 |
success: true,
|
|
@@ -425,6 +440,9 @@ const handler = async (req, res) => {
|
|
| 425 |
}
|
| 426 |
});
|
| 427 |
} catch (error) {
|
|
|
|
|
|
|
|
|
|
| 428 |
const duration = ((Date.now() - startTime) / 1000).toFixed(2);
|
| 429 |
|
| 430 |
res.status(500).json({
|
|
@@ -442,7 +460,7 @@ const handler = async (req, res) => {
|
|
| 442 |
|
| 443 |
module.exports = {
|
| 444 |
name: 'Sora2 Video Generator',
|
| 445 |
-
description: 'Generate videos using Sora2 AI model from Bylo.ai
|
| 446 |
type: 'GET',
|
| 447 |
routes: ['api/AI/sora2'],
|
| 448 |
tags: ['AI', 'Sora', 'OpenAI', 'Video'],
|
|
|
|
| 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',
|
| 8 |
'8.8.8.8',
|
| 9 |
'8.8.4.4'
|
| 10 |
]);
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
function generateUniqueId() {
|
| 13 |
return Array.from({ length: 32 }, () =>
|
| 14 |
Math.floor(Math.random() * 16).toString(16)
|
|
|
|
| 33 |
return `${Math.floor(Math.random() * 255)}.${Math.floor(Math.random() * 255)}.${Math.floor(Math.random() * 255)}.${Math.floor(Math.random() * 255)}`;
|
| 34 |
}
|
| 35 |
|
| 36 |
+
async function proxyRequest(url, options = {}) {
|
| 37 |
+
const targetPath = url.startsWith('http') ? url : url;
|
| 38 |
+
|
| 39 |
const fakeIP = generateRandomIP();
|
| 40 |
|
| 41 |
const headers = {
|
|
|
|
| 49 |
|
| 50 |
await randomDelay(500, 1500);
|
| 51 |
|
| 52 |
+
const axiosConfig = {
|
| 53 |
+
method: options.method || 'GET',
|
| 54 |
+
headers: headers,
|
| 55 |
+
timeout: 30000,
|
| 56 |
+
params: {
|
| 57 |
+
url: targetPath
|
| 58 |
+
},
|
| 59 |
+
validateStatus: function (status) {
|
| 60 |
+
return status >= 200 && status < 600;
|
| 61 |
+
}
|
| 62 |
+
};
|
| 63 |
+
|
| 64 |
+
if (options.data && (options.method === 'POST' || options.method === 'PUT')) {
|
| 65 |
+
axiosConfig.data = options.data;
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
let lastError = null;
|
| 69 |
|
| 70 |
for (let attempt = 1; attempt <= 3; attempt++) {
|
| 71 |
try {
|
| 72 |
+
axiosConfig.url = PROXY_URL;
|
| 73 |
+
console.log(`Attempt ${attempt}: ${PROXY_URL}?url=${targetPath}`);
|
| 74 |
|
| 75 |
+
const response = await axios(axiosConfig);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
|
| 77 |
+
console.log(`Attempt ${attempt} got status ${response.status}`);
|
| 78 |
+
console.log(`Response data:`, JSON.stringify(response.data).substring(0, 200));
|
| 79 |
|
| 80 |
if (response.status === 403) {
|
| 81 |
+
console.log('Got 403, waiting longer before retry...');
|
| 82 |
await randomDelay(3000, 5000);
|
| 83 |
throw new Error('API Bylo returned 403 Forbidden - possible rate limit or IP block');
|
| 84 |
}
|
| 85 |
|
| 86 |
if (response.status === 429) {
|
| 87 |
+
console.log('Got 429 Too Many Requests, waiting...');
|
| 88 |
await randomDelay(5000, 10000);
|
| 89 |
if (attempt < 3) continue;
|
| 90 |
throw new Error('Rate limit exceeded');
|
|
|
|
| 108 |
|
| 109 |
} catch (error) {
|
| 110 |
lastError = error;
|
| 111 |
+
console.error(`Attempt ${attempt} failed:`, error.message);
|
| 112 |
+
|
| 113 |
+
if (error.response) {
|
| 114 |
+
console.error(`Response status: ${error.response.status}`);
|
| 115 |
+
console.error(`Response data:`, error.response.data);
|
| 116 |
+
}
|
| 117 |
|
| 118 |
if (attempt < 3) {
|
| 119 |
const waitTime = 3000 * attempt;
|
| 120 |
+
console.log(`Retrying in ${waitTime/1000} seconds...`);
|
| 121 |
await randomDelay(waitTime, waitTime + 2000);
|
| 122 |
}
|
| 123 |
}
|
|
|
|
| 127 |
}
|
| 128 |
|
| 129 |
async function createTempEmail() {
|
| 130 |
+
console.log('Creating temporary email...');
|
| 131 |
const { data } = await axios.post('https://api.internal.temp-mail.io/api/v3/email/new', {
|
| 132 |
min_name_length: 10,
|
| 133 |
max_name_length: 10
|
|
|
|
| 141 |
timeout: 15000
|
| 142 |
});
|
| 143 |
|
| 144 |
+
console.log(`Email created: ${data.email}`);
|
| 145 |
return data;
|
| 146 |
}
|
| 147 |
|
| 148 |
+
async function getHcaptchaToken() {
|
| 149 |
+
console.log('Getting hCaptcha token...');
|
| 150 |
+
const { data } = await axios.get(
|
| 151 |
+
'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',
|
|
|
|
| 152 |
{
|
| 153 |
timeout: 15000
|
| 154 |
}
|
|
|
|
| 158 |
throw new Error('Failed to get hCaptcha token');
|
| 159 |
}
|
| 160 |
|
| 161 |
+
console.log('hCaptcha token obtained');
|
| 162 |
return data.data.result.token;
|
| 163 |
}
|
| 164 |
|
| 165 |
+
async function sendVerificationEmail(email) {
|
| 166 |
+
console.log(`Sending verification email to ${email}...`);
|
| 167 |
+
|
| 168 |
await randomDelay(1000, 2000);
|
| 169 |
|
| 170 |
+
const hcaptchaToken = await getHcaptchaToken();
|
| 171 |
const encodedEmail = encodeURIComponent(email);
|
| 172 |
|
| 173 |
await randomDelay(500, 1000);
|
| 174 |
|
| 175 |
const { data } = await proxyRequest(
|
|
|
|
| 176 |
`/api/auth/send-captcha?email=${encodedEmail}&type=register`,
|
| 177 |
{
|
| 178 |
method: 'GET',
|
|
|
|
| 188 |
throw new Error(`Failed to send verification email: ${data.msg || 'Unknown error'}`);
|
| 189 |
}
|
| 190 |
|
| 191 |
+
console.log('Verification email sent successfully');
|
| 192 |
await randomDelay(3000, 5000);
|
| 193 |
return true;
|
| 194 |
}
|
| 195 |
|
| 196 |
async function getVerificationCode(email) {
|
| 197 |
+
console.log('Waiting for verification code...');
|
| 198 |
let attempts = 0;
|
| 199 |
const maxAttempts = 30;
|
| 200 |
|
|
|
|
| 220 |
const codeMatch = bodyText.match(/Verification Code:\s*(\d{6})/);
|
| 221 |
|
| 222 |
if (codeMatch) {
|
| 223 |
+
console.log(`Verification code received: ${codeMatch[1]}`);
|
| 224 |
return codeMatch[1];
|
| 225 |
}
|
| 226 |
}
|
| 227 |
|
| 228 |
attempts++;
|
| 229 |
+
console.log(`Checking for verification code... attempt ${attempts}/${maxAttempts}`);
|
| 230 |
} catch (error) {
|
| 231 |
+
console.log(`Email check attempt ${attempts} failed:`, error.message);
|
| 232 |
attempts++;
|
| 233 |
}
|
| 234 |
}
|
|
|
|
| 236 |
throw new Error('Verification code not received after 30 attempts');
|
| 237 |
}
|
| 238 |
|
| 239 |
+
async function registerAccount(email, password, verificationCode) {
|
| 240 |
+
console.log('Registering account...');
|
| 241 |
+
const { data } = await proxyRequest('/api/auth/register', {
|
| 242 |
method: 'POST',
|
| 243 |
headers: {
|
| 244 |
'Accept': 'application/json, text/plain, */*',
|
|
|
|
| 258 |
throw new Error(`Registration failed: ${data.msg || 'Unknown error'}`);
|
| 259 |
}
|
| 260 |
|
| 261 |
+
console.log('Account registered successfully');
|
| 262 |
return data.data.token;
|
| 263 |
}
|
| 264 |
|
| 265 |
+
async function createVideo(prompt, ratio, authToken, email) {
|
| 266 |
+
console.log('Creating video task...');
|
| 267 |
await randomDelay(2000, 3000);
|
| 268 |
|
| 269 |
+
const { data } = await proxyRequest('/aimodels/api/v1/ai/video/create', {
|
| 270 |
method: 'POST',
|
| 271 |
headers: {
|
| 272 |
'Content-Type': 'application/json',
|
|
|
|
| 294 |
throw new Error(`Failed to create video: ${data.message || 'Unknown error'}`);
|
| 295 |
}
|
| 296 |
|
| 297 |
+
console.log(`Video task created with ID: ${data.data}`);
|
| 298 |
return data.data;
|
| 299 |
}
|
| 300 |
|
| 301 |
+
async function getTaskStatus(taskId, authToken) {
|
| 302 |
try {
|
| 303 |
const { data } = await proxyRequest(
|
|
|
|
| 304 |
`/aimodels/api/v1/ai/${taskId}?channel=SORA2`,
|
| 305 |
{
|
| 306 |
method: 'GET',
|
|
|
|
| 317 |
|
| 318 |
return data.data;
|
| 319 |
} catch (error) {
|
| 320 |
+
console.error('Error getting task status:', error.message);
|
| 321 |
throw error;
|
| 322 |
}
|
| 323 |
}
|
| 324 |
|
| 325 |
+
async function waitForVideoCompletion(taskId, authToken) {
|
| 326 |
+
console.log('Waiting for video generation...');
|
| 327 |
let attempts = 0;
|
| 328 |
const maxAttempts = 120;
|
| 329 |
|
| 330 |
while (attempts < maxAttempts) {
|
| 331 |
await randomDelay(5000, 7000);
|
| 332 |
|
| 333 |
+
const taskData = await getTaskStatus(taskId, authToken);
|
| 334 |
+
|
| 335 |
+
console.log(`Video status check ${attempts + 1}/${maxAttempts} - State: ${taskData.state}`);
|
| 336 |
|
| 337 |
if (taskData.state === 1 && taskData.completeData) {
|
| 338 |
const completeData = JSON.parse(taskData.completeData);
|
| 339 |
+
console.log('Video generation completed!');
|
| 340 |
return completeData.data.result_urls[0];
|
| 341 |
}
|
| 342 |
|
|
|
|
| 351 |
}
|
| 352 |
|
| 353 |
async function sora2(prompt, ratio = 'portrait') {
|
| 354 |
+
console.log('=== Starting Sora2 Video Generation ===');
|
| 355 |
+
console.log(`Prompt: ${prompt}`);
|
| 356 |
+
console.log(`Ratio: ${ratio}`);
|
| 357 |
|
| 358 |
const tempMail = await createTempEmail();
|
| 359 |
const email = tempMail.email;
|
| 360 |
const password = generatePassword();
|
| 361 |
|
| 362 |
+
await sendVerificationEmail(email);
|
| 363 |
const verificationCode = await getVerificationCode(email);
|
| 364 |
+
const authToken = await registerAccount(email, password, verificationCode);
|
| 365 |
+
const taskId = await createVideo(prompt, ratio, authToken, email);
|
| 366 |
+
const videoUrl = await waitForVideoCompletion(taskId, authToken);
|
| 367 |
+
|
| 368 |
+
console.log('=== Video Generation Completed ===');
|
| 369 |
+
console.log(`Video URL: ${videoUrl}`);
|
| 370 |
|
| 371 |
return {
|
| 372 |
success: true,
|
|
|
|
| 408 |
});
|
| 409 |
}
|
| 410 |
|
| 411 |
+
console.log(`\n${'='.repeat(60)}`);
|
| 412 |
+
console.log('NEW REQUEST RECEIVED');
|
| 413 |
+
console.log(`Prompt: ${prompt}`);
|
| 414 |
+
console.log(`Ratio: ${ratio}`);
|
| 415 |
+
console.log(`${'='.repeat(60)}\n`);
|
| 416 |
+
|
| 417 |
const result = await sora2(prompt, ratio);
|
| 418 |
|
| 419 |
const duration = ((Date.now() - startTime) / 1000).toFixed(2);
|
| 420 |
|
| 421 |
+
console.log(`\n${'='.repeat(60)}`);
|
| 422 |
+
console.log('REQUEST COMPLETED');
|
| 423 |
+
console.log(`Duration: ${duration}s`);
|
| 424 |
+
console.log(`${'='.repeat(60)}\n`);
|
| 425 |
+
|
| 426 |
res.json({
|
| 427 |
author: 'Herza',
|
| 428 |
success: true,
|
|
|
|
| 440 |
}
|
| 441 |
});
|
| 442 |
} catch (error) {
|
| 443 |
+
console.error('\n❌ ERROR:', error.message);
|
| 444 |
+
console.error('Stack:', error.stack);
|
| 445 |
+
|
| 446 |
const duration = ((Date.now() - startTime) / 1000).toFixed(2);
|
| 447 |
|
| 448 |
res.status(500).json({
|
|
|
|
| 460 |
|
| 461 |
module.exports = {
|
| 462 |
name: 'Sora2 Video Generator',
|
| 463 |
+
description: 'Generate videos using Sora2 AI model from Bylo.ai via Vercel Proxy',
|
| 464 |
type: 'GET',
|
| 465 |
routes: ['api/AI/sora2'],
|
| 466 |
tags: ['AI', 'Sora', 'OpenAI', 'Video'],
|