feat: update song model and related routers, schemas, worker

This commit is contained in:
Dohyun Lim committed 2026-01-20 14:40:58 +09:00
1 parent ece201f92b
commit ee6069e5d5
7 files changed
+222 -148

No files matched your search

+44 -19
View File
@@ -114,24 +114,33 @@ class SongClipData(BaseModel):
class PollingSongResponse(BaseModel):
"""노래 생성 상태 조회 응답 스키마
"""노래 생성 상태 조회 응답 스키마 (Suno API)
Usage:
GET /song/status/{song_id}
Suno API 작업 상태를 조회합니다.
Note:
상태 값:
- PENDING: 대기 중
- processing: 생성 중
- SUCCESS / TEXT_SUCCESS / complete: 생성 완료
- failed: 생성 실패
상태 값 (Suno API 응답):
- PENDING: Suno API 대기 중
- processing: Suno API에서 노래 생성 중
- SUCCESS: Suno API 노래 생성 완료 (백그라운드 Blob 업로드 시작)
- TEXT_SUCCESS: Suno API 노래 생성 완료
- failed: Suno API 노래 생성 실패
- error: API 조회 오류
SUCCESS 상태 시:
- 백그라운드에서 MP3 파일 다운로드 시작
- Song 테이블의 status를 completed로 업데이트
- song_result_url에 로컬 파일 경로 저장
- 백그라운드에서 MP3 파일 다운로드 및 Azure Blob 업로드 시작
- Song 테이블의 status가 uploading으로 변경
- 업로드 완료 시 status가 completed로 변경, song_result_url에 Blob URL 저장
Example Response (Pending):
{
"success": true,
"status": "PENDING",
"message": "노래 생성 대기 중입니다.",
"error_message": null
}
Example Response (Processing):
{
@@ -160,7 +169,7 @@ class PollingSongResponse(BaseModel):
success: bool = Field(..., description="조회 성공 여부")
status: Optional[str] = Field(
None, description="작업 상태 (PENDING, processing, SUCCESS, failed)"
None, description="Suno API 작업 상태 (PENDING, processing, SUCCESS, TEXT_SUCCESS, failed, error)"
)
message: str = Field(..., description="상태 메시지")
error_message: Optional[str] = Field(None, description="에러 메시지 (실패 시)")
@@ -192,17 +201,18 @@ class SongListItem(BaseModel):
class DownloadSongResponse(BaseModel):
"""노래 다운로드 응답 스키마
"""노래 다운로드 응답 스키마 (DB Polling)
Usage:
GET /song/download/{task_id}
Polls for song completion and returns project info with song URL.
DB의 Song 테이블 상태를 조회하고 완료 시 Project 정보와 노래 URL을 반환합니다.
Note:
상태 값:
- processing: 노래 생성 진행 중 (song_result_url은 null)
- completed: 노래 생성 완료 (song_result_url 포함)
- failed: 노래 생성 실패
상태 값 (DB 상태):
- processing: Suno API에서 노래 생성 중 (song_result_url은 null)
- uploading: MP3 다운로드 및 Azure Blob 업로드 중 (song_result_url은 null)
- completed: 모든 작업 완료 (song_result_url에 Azure Blob URL 포함)
- failed: 노래 생성 또는 업로드 실패
- not_found: task_id에 해당하는 Song 없음
- error: 조회 중 오류 발생
@@ -221,6 +231,21 @@ class DownloadSongResponse(BaseModel):
"error_message": null
}
Example Response (Uploading):
{
"success": true,
"status": "uploading",
"message": "노래 파일을 업로드 중입니다.",
"store_name": null,
"region": null,
"detail_region_info": null,
"task_id": "019123ab-cdef-7890-abcd-ef1234567890",
"language": null,
"song_result_url": null,
"created_at": null,
"error_message": null
}
Example Response (Completed):
{
"success": true,
@@ -231,7 +256,7 @@ class DownloadSongResponse(BaseModel):
"detail_region_info": "군산 신흥동 말랭이 마을",
"task_id": "019123ab-cdef-7890-abcd-ef1234567890",
"language": "Korean",
"song_result_url": "http://localhost:8000/media/2025-01-15/스테이머뭄.mp3",
"song_result_url": "https://blob.azure.com/.../song.mp3",
"created_at": "2025-01-15T12:00:00",
"error_message": null
}
@@ -252,8 +277,8 @@ class DownloadSongResponse(BaseModel):
}
"""
success: bool = Field(..., description="다운로드 성공 여부")
status: str = Field(..., description="처리 상태 (processing, completed, failed, not_found, error)")
success: bool = Field(..., description="조회 성공 여부")
status: str = Field(..., description="DB 처리 상태 (processing, uploading, completed, failed, not_found, error)")
message: str = Field(..., description="응답 메시지")
store_name: Optional[str] = Field(None, description="업체명")
region: Optional[str] = Field(None, description="지역명")