Files
CloudSearch/source_clean/src/video/video.service.ts
admin 83cbfaf03f v0.2.7: 修复Redis连接 + 启动管理后台
- 修复Redis认证 (配置密码)
- 启动Python管理后台 (端口9531, 15个功能开关)
- 统一版本号 0.2.7
- 更新docker-compose.yml (镜像版本/Redis URL/Admin服务)
2026-05-17 02:22:18 +08:00

38 lines
973 B
TypeScript
Executable File

// Native fetch available in Node 20+
import config from '../config';
export interface VideoInfo {
title: string;
coverUrl: string;
videoUrl: string;
author: string;
platform: string;
duration?: string;
}
export async function parseVideo(url: string): Promise<VideoInfo> {
const apiUrl = `${config.videoParserUrl}/parse`;
const response = await fetch(apiUrl, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ url }),
signal: AbortSignal.timeout(30000),
});
if (!response.ok) {
throw new Error(`Video parser API error: ${response.status} ${response.statusText}`);
}
const data = await response.json() as any;
return {
title: data.title || '',
coverUrl: data.coverUrl || data.cover || '',
videoUrl: data.videoUrl || data.url || data.video || '',
author: data.author || data.nickname || '',
platform: data.platform || '',
duration: data.duration || '',
};
}