guanghulab/video-ai-system/tools/query-qinshan.js
冰朔 e8cf2e78f3
Some checks failed
自动更新代码和重启 / update-and-restart (push) Has been cancelled
CI检查 + 自动部署 / check (push) Has been cancelled
CI检查 + 自动部署 / deploy (push) Has been cancelled
D133: 镜1主角+镜2牌匾尺寸双重修复 · ENV-002物理尺寸约束
2026-06-15 18:06:14 +08:00

50 lines
1.6 KiB
JavaScript

const fs = require('fs');
const path = require('path');
const https = require('http');
const http = require('http');
// Read .env manually
const envPath = path.resolve(__dirname, '../.env');
const envContent = fs.readFileSync(envPath, 'utf-8');
const env = {};
envContent.split('\n').forEach(line => {
const trimmed = line.trim();
if (trimmed && !trimmed.startsWith('#')) {
const [key, ...vals] = trimmed.split('=');
if (key && vals.length) env[key.trim()] = vals.join('=').trim();
}
});
const API_KEY = env.JIMENG_API_KEY;
const BASE_URL = env.JIMENG_BASE_URL || 'https://ark.cn-beijing.volces.com/api/v3';
const TASK_ID = 'cgt-20260612224249-bgmck';
const WS = '/Users/bingshuolingdianyuanhe/WorkBuddy/2026-06-12-21-21-10/outputs';
function httpGet(url) {
const urlObj = new URL(url);
const t = urlObj.protocol === 'https:' ? https : http;
return new Promise((resolve, reject) => {
t.request(url, {
method: 'GET',
headers: { 'Authorization': `Bearer ${API_KEY}`, 'Content-Type': 'application/json' },
timeout: 30000,
}, (res) => {
let data = '';
res.on('data', chunk => data += chunk);
res.on('end', () => {
try { resolve(JSON.parse(data)); }
catch(e) { resolve({ _raw: data }); }
});
}).on('error', reject).end();
});
}
async function main() {
const data = await httpGet(`${BASE_URL}/contents/generations/tasks/${TASK_ID}`);
const videoUrl = data.content?.video_url;
if (!videoUrl) { console.error('No video_url'); console.log(JSON.stringify(data,null,2)); return; }
console.log('VIDEO_URL=' + videoUrl);
console.log('TOKENS=' + (data.usage?.total_tokens || '?'));
}
main();