Remove the song endpoint and send the song URL when pulling if the status is SUCCESS.
This commit is contained in:
1 parent
b48d218a1d
commit
6d2961cee2
5 files changed
+93
-397
No files matched your search
+68
-122
@@ -79,9 +79,30 @@ class GenerateSongResponse(BaseModel):
|
||||
}
|
||||
"""
|
||||
|
||||
model_config = {
|
||||
"json_schema_extra": {
|
||||
"examples": [
|
||||
{
|
||||
"success": True,
|
||||
"task_id": "019123ab-cdef-7890-abcd-ef1234567890",
|
||||
"song_id": "abc123...",
|
||||
"message": "노래 생성 요청이 접수되었습니다. song_id로 상태를 조회하세요.",
|
||||
"error_message": None,
|
||||
},
|
||||
{
|
||||
"success": False,
|
||||
"task_id": "019123ab-cdef-7890-abcd-ef1234567890",
|
||||
"song_id": None,
|
||||
"message": "노래 생성 요청에 실패했습니다.",
|
||||
"error_message": "Suno API connection error",
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
success: bool = Field(..., description="요청 성공 여부")
|
||||
task_id: Optional[str] = Field(None, description="내부 작업 ID (Project/Lyric task_id)")
|
||||
song_id: Optional[str] = Field(None, description="Suno API 작업 ID")
|
||||
song_id: Optional[str] = Field(None, description="Suno API 작업 ID (상태 조회에 사용)")
|
||||
message: str = Field(..., description="응답 메시지")
|
||||
error_message: Optional[str] = Field(None, description="에러 메시지 (실패 시)")
|
||||
|
||||
@@ -124,6 +145,7 @@ class PollingSongResponse(BaseModel):
|
||||
상태 값 (Suno API 응답):
|
||||
- PENDING: Suno API 대기 중
|
||||
- processing: Suno API에서 노래 생성 중
|
||||
- uploading: MP3 다운로드 및 Azure Blob 업로드 중
|
||||
- SUCCESS: Suno API 노래 생성 완료 (백그라운드 Blob 업로드 시작)
|
||||
- TEXT_SUCCESS: Suno API 노래 생성 완료
|
||||
- failed: Suno API 노래 생성 실패
|
||||
@@ -133,13 +155,15 @@ class PollingSongResponse(BaseModel):
|
||||
- 백그라운드에서 MP3 파일 다운로드 및 Azure Blob 업로드 시작
|
||||
- Song 테이블의 status가 uploading으로 변경
|
||||
- 업로드 완료 시 status가 completed로 변경, song_result_url에 Blob URL 저장
|
||||
- completed 상태인 경우 song_result_url 반환
|
||||
|
||||
Example Response (Pending):
|
||||
{
|
||||
"success": true,
|
||||
"status": "PENDING",
|
||||
"message": "노래 생성 대기 중입니다.",
|
||||
"error_message": null
|
||||
"error_message": null,
|
||||
"song_result_url": null
|
||||
}
|
||||
|
||||
Example Response (Processing):
|
||||
@@ -147,15 +171,26 @@ class PollingSongResponse(BaseModel):
|
||||
"success": true,
|
||||
"status": "processing",
|
||||
"message": "노래를 생성하고 있습니다.",
|
||||
"error_message": null
|
||||
"error_message": null,
|
||||
"song_result_url": null
|
||||
}
|
||||
|
||||
Example Response (Success):
|
||||
Example Response (Uploading):
|
||||
{
|
||||
"success": true,
|
||||
"status": "uploading",
|
||||
"message": "노래 생성이 완료되었습니다.",
|
||||
"error_message": null,
|
||||
"song_result_url": null
|
||||
}
|
||||
|
||||
Example Response (Success - Completed):
|
||||
{
|
||||
"success": true,
|
||||
"status": "SUCCESS",
|
||||
"message": "노래 생성이 완료되었습니다.",
|
||||
"error_message": null
|
||||
"error_message": null,
|
||||
"song_result_url": "https://blob.azure.com/.../song.mp3"
|
||||
}
|
||||
|
||||
Example Response (Failure):
|
||||
@@ -163,131 +198,42 @@ class PollingSongResponse(BaseModel):
|
||||
"success": false,
|
||||
"status": "error",
|
||||
"message": "상태 조회에 실패했습니다.",
|
||||
"error_message": "ConnectionError: ..."
|
||||
"error_message": "ConnectionError: ...",
|
||||
"song_result_url": null
|
||||
}
|
||||
"""
|
||||
|
||||
model_config = {
|
||||
"json_schema_extra": {
|
||||
"examples": [
|
||||
{
|
||||
"success": True,
|
||||
"status": "processing",
|
||||
"message": "노래를 생성하고 있습니다.",
|
||||
"error_message": None,
|
||||
"song_result_url": None,
|
||||
},
|
||||
{
|
||||
"success": True,
|
||||
"status": "SUCCESS",
|
||||
"message": "노래 생성이 완료되었습니다.",
|
||||
"error_message": None,
|
||||
"song_result_url": "https://blob.azure.com/.../song.mp3",
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
success: bool = Field(..., description="조회 성공 여부")
|
||||
status: Optional[str] = Field(
|
||||
None, description="Suno API 작업 상태 (PENDING, processing, SUCCESS, TEXT_SUCCESS, failed, error)"
|
||||
None,
|
||||
description="작업 상태 (PENDING, processing, uploading, SUCCESS, TEXT_SUCCESS, failed, error)",
|
||||
)
|
||||
message: str = Field(..., description="상태 메시지")
|
||||
error_message: Optional[str] = Field(None, description="에러 메시지 (실패 시)")
|
||||
|
||||
|
||||
class SongListItem(BaseModel):
|
||||
"""노래 목록 아이템 스키마
|
||||
|
||||
Usage:
|
||||
GET /songs 응답의 개별 노래 정보
|
||||
|
||||
Example:
|
||||
{
|
||||
"store_name": "스테이 머뭄",
|
||||
"region": "군산",
|
||||
"task_id": "019123ab-cdef-7890-abcd-ef1234567890",
|
||||
"language": "Korean",
|
||||
"song_result_url": "http://localhost:8000/media/2025-01-15/스테이머뭄.mp3",
|
||||
"created_at": "2025-01-15T12:00:00"
|
||||
}
|
||||
"""
|
||||
|
||||
store_name: Optional[str] = Field(None, description="업체명")
|
||||
region: Optional[str] = Field(None, description="지역명")
|
||||
task_id: str = Field(..., description="작업 고유 식별자")
|
||||
language: Optional[str] = Field(None, description="언어")
|
||||
song_result_url: Optional[str] = Field(None, description="노래 결과 URL")
|
||||
created_at: Optional[datetime] = Field(None, description="생성 일시")
|
||||
|
||||
|
||||
class DownloadSongResponse(BaseModel):
|
||||
"""노래 다운로드 응답 스키마 (DB Polling)
|
||||
|
||||
Usage:
|
||||
GET /song/download/{task_id}
|
||||
DB의 Song 테이블 상태를 조회하고 완료 시 Project 정보와 노래 URL을 반환합니다.
|
||||
|
||||
Note:
|
||||
상태 값 (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: 조회 중 오류 발생
|
||||
|
||||
Example Response (Processing):
|
||||
{
|
||||
"success": true,
|
||||
"status": "processing",
|
||||
"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 (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,
|
||||
"status": "completed",
|
||||
"message": "노래 다운로드가 완료되었습니다.",
|
||||
"store_name": "스테이 머뭄",
|
||||
"region": "군산",
|
||||
"detail_region_info": "군산 신흥동 말랭이 마을",
|
||||
"task_id": "019123ab-cdef-7890-abcd-ef1234567890",
|
||||
"language": "Korean",
|
||||
"song_result_url": "https://blob.azure.com/.../song.mp3",
|
||||
"created_at": "2025-01-15T12:00:00",
|
||||
"error_message": null
|
||||
}
|
||||
|
||||
Example Response (Not Found):
|
||||
{
|
||||
"success": false,
|
||||
"status": "not_found",
|
||||
"message": "task_id 'xxx'에 해당하는 Song을 찾을 수 없습니다.",
|
||||
"store_name": null,
|
||||
"region": null,
|
||||
"detail_region_info": null,
|
||||
"task_id": null,
|
||||
"language": null,
|
||||
"song_result_url": null,
|
||||
"created_at": null,
|
||||
"error_message": "Song not found"
|
||||
}
|
||||
"""
|
||||
|
||||
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="지역명")
|
||||
detail_region_info: Optional[str] = Field(None, description="상세 지역 정보")
|
||||
task_id: Optional[str] = Field(None, description="작업 고유 식별자")
|
||||
language: Optional[str] = Field(None, description="언어")
|
||||
song_result_url: Optional[str] = Field(None, description="노래 결과 URL")
|
||||
created_at: Optional[datetime] = Field(None, description="생성 일시")
|
||||
error_message: Optional[str] = Field(None, description="에러 메시지 (실패 시)")
|
||||
song_result_url: Optional[str] = Field(
|
||||
None, description="노래 결과 URL (Song 테이블 status가 completed일 때 반환)"
|
||||
)
|
||||
|
||||
|
||||
# =============================================================================
|
||||
|
||||
Reference in new issue
Block a user