v0.2.7: 修复Redis连接 + 启动管理后台
- 修复Redis认证 (配置密码) - 启动Python管理后台 (端口9531, 15个功能开关) - 统一版本号 0.2.7 - 更新docker-compose.yml (镜像版本/Redis URL/Admin服务)
This commit is contained in:
37
source_clean/src/video/video.service.ts
Executable file
37
source_clean/src/video/video.service.ts
Executable file
@@ -0,0 +1,37 @@
|
||||
// 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 || '',
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user