배경음악 재시도 오류 수정 및 subtitle 확인을 위한 엔드포인트 추가
This commit is contained in:
1 parent
9910d0146c
commit
f3195628d2
6 files changed
+87
-13
No files matched your search
@@ -8,6 +8,7 @@ import {
|
||||
SongGenerateResponse,
|
||||
SongStatusResponse,
|
||||
SongDownloadResponse,
|
||||
SubtitleStatusResponse,
|
||||
VideoGenerateResponse,
|
||||
VideoStatusResponse,
|
||||
VideoDownloadResponse,
|
||||
@@ -245,6 +246,52 @@ export async function waitForSongComplete(
|
||||
return poll();
|
||||
}
|
||||
|
||||
// 자막 상태 확인 API
|
||||
export async function getSubtitleStatus(taskId: string): Promise<SubtitleStatusResponse> {
|
||||
const response = await authenticatedFetch(`${API_URL}/lyric/subtitle/status/${taskId}`, {
|
||||
method: 'GET',
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! status: ${response.status}`);
|
||||
}
|
||||
|
||||
return response.json();
|
||||
}
|
||||
|
||||
// 자막 완료까지 폴링 (5초 간격, 10분 타임아웃)
|
||||
const SUBTITLE_POLL_INTERVAL = 5000;
|
||||
const SUBTITLE_POLL_TIMEOUT = 5 * 60 * 1000;
|
||||
|
||||
export async function waitForSubtitleComplete(
|
||||
taskId: string,
|
||||
onStatusChange?: (status: string) => void
|
||||
): Promise<SubtitleStatusResponse> {
|
||||
const startTime = Date.now();
|
||||
|
||||
const poll = async (): Promise<SubtitleStatusResponse> => {
|
||||
if (Date.now() - startTime > SUBTITLE_POLL_TIMEOUT) {
|
||||
throw new Error('TIMEOUT');
|
||||
}
|
||||
|
||||
const response = await getSubtitleStatus(taskId);
|
||||
onStatusChange?.(response.status);
|
||||
|
||||
if (response.status === 'completed') {
|
||||
return response;
|
||||
}
|
||||
|
||||
if (response.status === 'failed' || response.status === 'error') {
|
||||
throw new Error(response.message || '자막 생성에 실패했습니다.');
|
||||
}
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve, SUBTITLE_POLL_INTERVAL));
|
||||
return poll();
|
||||
};
|
||||
|
||||
return poll();
|
||||
}
|
||||
|
||||
// 영상 생성 API
|
||||
export async function generateVideo(taskId: string, orientation: 'vertical' | 'horizontal' = 'vertical'): Promise<VideoGenerateResponse> {
|
||||
const response = await authenticatedFetch(`${API_URL}/video/generate/${taskId}?orientation=${orientation}`, {
|
||||
|
||||
Reference in new issue
Block a user