Merge branch 'main' into creatomate

This commit is contained in:
jaehwang committed 2026-02-02 07:58:19 +00:00
commit e1386b891e
31 files changed
+4917 -63

No files matched your search

+5 -1
View File
@@ -568,7 +568,7 @@ async def get_video_status(
# 백그라운드 태스크로 MP4 다운로드 → Blob 업로드 → DB 업데이트 → 임시 파일 삭제
logger.info(
f"[get_video_status] Background task args - task_id: {video.task_id}, video_url: {video_url}, store_name: {store_name}"
f"[get_video_status] Background task args - task_id: {video.task_id}, video_url: {video_url}, store_name: {store_name}, creatomate_render_id: {creatomate_render_id}"
)
background_tasks.add_task(
download_and_upload_video_to_blob,
@@ -576,6 +576,7 @@ async def get_video_status(
video_url=video_url,
store_name=store_name,
user_uuid=current_user.user_uuid,
creatomate_render_id=creatomate_render_id,
)
elif video and video.status == "completed":
logger.debug(
@@ -830,6 +831,7 @@ async def get_videos(
project = projects_map.get(video.project_id)
item = VideoListItem(
video_id=video.id,
store_name=project.store_name if project else None,
region=project.region if project else None,
task_id=video.task_id,
@@ -857,3 +859,5 @@ async def get_videos(
status_code=500,
detail=f"영상 목록 조회에 실패했습니다: {str(e)}",
)
+5 -1
View File
@@ -5,7 +5,7 @@ Video API Schemas
"""
from datetime import datetime
from typing import Any, Dict, Literal, Optional
from typing import Any, Dict, Optional
from pydantic import BaseModel, ConfigDict, Field
@@ -141,6 +141,7 @@ class VideoListItem(BaseModel):
Example:
{
"video_id": 1,
"store_name": "스테이 머뭄",
"region": "군산",
"task_id": "019123ab-cdef-7890-abcd-ef1234567890",
@@ -149,8 +150,11 @@ class VideoListItem(BaseModel):
}
"""
video_id: int = Field(..., description="영상 고유 ID")
store_name: Optional[str] = Field(None, description="업체명")
region: Optional[str] = Field(None, description="지역명")
task_id: str = Field(..., description="작업 고유 식별자")
result_movie_url: Optional[str] = Field(None, description="영상 결과 URL")
created_at: Optional[datetime] = Field(None, description="생성 일시")
+8 -6
View File
@@ -107,6 +107,7 @@ async def download_and_upload_video_to_blob(
video_url: str,
store_name: str,
user_uuid: str,
creatomate_render_id: str | None = None,
) -> None:
"""백그라운드에서 영상을 다운로드하고 Azure Blob Storage에 업로드한 뒤 Video 테이블을 업데이트합니다.
@@ -115,6 +116,7 @@ async def download_and_upload_video_to_blob(
video_url: 다운로드할 영상 URL
store_name: 저장할 파일명에 사용할 업체명
user_uuid: 사용자 UUID (Azure Blob Storage 경로에 사용)
creatomate_render_id: Creatomate 렌더 ID (특정 Video 식별용)
"""
logger.info(f"[download_and_upload_video_to_blob] START - task_id: {task_id}, store_name: {store_name}")
temp_file_path: Path | None = None
@@ -154,21 +156,21 @@ async def download_and_upload_video_to_blob(
blob_url = uploader.public_url
logger.info(f"[download_and_upload_video_to_blob] Uploaded to Blob - task_id: {task_id}, url: {blob_url}")
# Video 테이블 업데이트
await _update_video_status(task_id, "completed", blob_url)
logger.info(f"[download_and_upload_video_to_blob] SUCCESS - task_id: {task_id}")
# Video 테이블 업데이트 (creatomate_render_id로 특정 Video 식별)
await _update_video_status(task_id, "completed", blob_url, creatomate_render_id)
logger.info(f"[download_and_upload_video_to_blob] SUCCESS - task_id: {task_id}, creatomate_render_id: {creatomate_render_id}")
except httpx.HTTPError as e:
logger.error(f"[download_and_upload_video_to_blob] DOWNLOAD ERROR - task_id: {task_id}, error: {e}", exc_info=True)
await _update_video_status(task_id, "failed")
await _update_video_status(task_id, "failed", creatomate_render_id=creatomate_render_id)
except SQLAlchemyError as e:
logger.error(f"[download_and_upload_video_to_blob] DB ERROR - task_id: {task_id}, error: {e}", exc_info=True)
await _update_video_status(task_id, "failed")
await _update_video_status(task_id, "failed", creatomate_render_id=creatomate_render_id)
except Exception as e:
logger.error(f"[download_and_upload_video_to_blob] EXCEPTION - task_id: {task_id}, error: {e}", exc_info=True)
await _update_video_status(task_id, "failed")
await _update_video_status(task_id, "failed", creatomate_render_id=creatomate_render_id)
finally:
# 임시 파일 삭제