chore: initial commit - CloudSearch v0.0.2

This commit is contained in:
2026-05-15 05:50:50 +08:00
commit d83225d736
102 changed files with 37926 additions and 0 deletions

View 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 || '',
};
}