Update plugins/sora2.js
Browse files- plugins/sora2.js +22 -17
plugins/sora2.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
| 1 |
const axios = require('axios');
|
| 2 |
const dns = require('dns').promises;
|
|
|
|
| 3 |
|
| 4 |
-
const
|
|
|
|
|
|
|
|
|
|
| 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 }, () =>
|
|
@@ -33,29 +33,33 @@ function generateRandomIP() {
|
|
| 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(
|
| 37 |
-
const
|
| 38 |
-
|
| 39 |
const fakeIP = generateRandomIP();
|
|
|
|
| 40 |
|
| 41 |
const headers = {
|
| 42 |
-
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
|
| 43 |
'Accept': 'application/json, text/plain, */*',
|
|
|
|
| 44 |
'X-Forwarded-For': fakeIP,
|
| 45 |
'X-Real-IP': fakeIP,
|
| 46 |
'X-Client-IP': fakeIP,
|
|
|
|
|
|
|
| 47 |
...(options.headers || {})
|
| 48 |
};
|
| 49 |
|
| 50 |
await randomDelay(500, 1500);
|
| 51 |
|
| 52 |
const axiosConfig = {
|
|
|
|
| 53 |
method: options.method || 'GET',
|
| 54 |
headers: headers,
|
| 55 |
-
timeout:
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
validateStatus: function (status) {
|
| 60 |
return status >= 200 && status < 600;
|
| 61 |
}
|
|
@@ -69,8 +73,7 @@ async function proxyRequest(url, options = {}) {
|
|
| 69 |
|
| 70 |
for (let attempt = 1; attempt <= 3; attempt++) {
|
| 71 |
try {
|
| 72 |
-
|
| 73 |
-
console.log(`Attempt ${attempt}: ${PROXY_URL}?url=${targetPath}`);
|
| 74 |
|
| 75 |
const response = await axios(axiosConfig);
|
| 76 |
|
|
@@ -361,6 +364,7 @@ async function sora2(prompt, ratio = 'portrait') {
|
|
| 361 |
console.log('=== Starting Sora2 Video Generation ===');
|
| 362 |
console.log(`Prompt: ${prompt}`);
|
| 363 |
console.log(`Ratio: ${ratio}`);
|
|
|
|
| 364 |
|
| 365 |
const tempMail = await createTempEmail();
|
| 366 |
const email = tempMail.email;
|
|
@@ -421,6 +425,7 @@ const handler = async (req, res) => {
|
|
| 421 |
console.log('NEW REQUEST RECEIVED');
|
| 422 |
console.log(`Prompt: ${prompt}`);
|
| 423 |
console.log(`Ratio: ${ratio}`);
|
|
|
|
| 424 |
console.log(`${'='.repeat(60)}\n`);
|
| 425 |
|
| 426 |
const result = await sora2(prompt, ratio);
|
|
@@ -469,7 +474,7 @@ const handler = async (req, res) => {
|
|
| 469 |
|
| 470 |
module.exports = {
|
| 471 |
name: 'Sora2 Video Generator',
|
| 472 |
-
description: 'Generate videos using Sora2 AI model from Bylo.ai via
|
| 473 |
type: 'GET',
|
| 474 |
routes: ['api/AI/sora2'],
|
| 475 |
tags: ['AI', 'Sora', 'OpenAI', 'Video'],
|
|
|
|
| 1 |
const axios = require('axios');
|
| 2 |
const dns = require('dns').promises;
|
| 3 |
+
const { HttpsProxyAgent } = require('https-proxy-agent');
|
| 4 |
|
| 5 |
+
const PROXY_HOST = 'de19.spaceify.eu';
|
| 6 |
+
const PROXY_PORT = 25815;
|
| 7 |
+
const PROXY_URL = `http://${PROXY_HOST}:${PROXY_PORT}`;
|
| 8 |
+
const API_BASE_URL = 'https://api.bylo.ai';
|
| 9 |
|
| 10 |
+
dns.setServers(['1.1.1.1', '8.8.8.8', '8.8.4.4']);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
function generateUniqueId() {
|
| 13 |
return Array.from({ length: 32 }, () =>
|
|
|
|
| 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(path, options = {}) {
|
| 37 |
+
const fullUrl = path.startsWith('http') ? path : `${API_BASE_URL}${path}`;
|
|
|
|
| 38 |
const fakeIP = generateRandomIP();
|
| 39 |
+
const proxyAgent = new HttpsProxyAgent(PROXY_URL);
|
| 40 |
|
| 41 |
const headers = {
|
| 42 |
+
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
|
| 43 |
'Accept': 'application/json, text/plain, */*',
|
| 44 |
+
'Accept-Language': 'en-US,en;q=0.9',
|
| 45 |
'X-Forwarded-For': fakeIP,
|
| 46 |
'X-Real-IP': fakeIP,
|
| 47 |
'X-Client-IP': fakeIP,
|
| 48 |
+
'Origin': 'https://bylo.ai',
|
| 49 |
+
'Referer': 'https://bylo.ai/',
|
| 50 |
...(options.headers || {})
|
| 51 |
};
|
| 52 |
|
| 53 |
await randomDelay(500, 1500);
|
| 54 |
|
| 55 |
const axiosConfig = {
|
| 56 |
+
url: fullUrl,
|
| 57 |
method: options.method || 'GET',
|
| 58 |
headers: headers,
|
| 59 |
+
timeout: 25000,
|
| 60 |
+
httpAgent: proxyAgent,
|
| 61 |
+
httpsAgent: proxyAgent,
|
| 62 |
+
proxy: false,
|
| 63 |
validateStatus: function (status) {
|
| 64 |
return status >= 200 && status < 600;
|
| 65 |
}
|
|
|
|
| 73 |
|
| 74 |
for (let attempt = 1; attempt <= 3; attempt++) {
|
| 75 |
try {
|
| 76 |
+
console.log(`Attempt ${attempt}: ${fullUrl}`);
|
|
|
|
| 77 |
|
| 78 |
const response = await axios(axiosConfig);
|
| 79 |
|
|
|
|
| 364 |
console.log('=== Starting Sora2 Video Generation ===');
|
| 365 |
console.log(`Prompt: ${prompt}`);
|
| 366 |
console.log(`Ratio: ${ratio}`);
|
| 367 |
+
console.log(`Proxy: ${PROXY_URL}`);
|
| 368 |
|
| 369 |
const tempMail = await createTempEmail();
|
| 370 |
const email = tempMail.email;
|
|
|
|
| 425 |
console.log('NEW REQUEST RECEIVED');
|
| 426 |
console.log(`Prompt: ${prompt}`);
|
| 427 |
console.log(`Ratio: ${ratio}`);
|
| 428 |
+
console.log(`Proxy: ${PROXY_URL}`);
|
| 429 |
console.log(`${'='.repeat(60)}\n`);
|
| 430 |
|
| 431 |
const result = await sora2(prompt, ratio);
|
|
|
|
| 474 |
|
| 475 |
module.exports = {
|
| 476 |
name: 'Sora2 Video Generator',
|
| 477 |
+
description: 'Generate videos using Sora2 AI model from Bylo.ai via Spaceify Proxy',
|
| 478 |
type: 'GET',
|
| 479 |
routes: ['api/AI/sora2'],
|
| 480 |
tags: ['AI', 'Sora', 'OpenAI', 'Video'],
|