youtube upload 기능 작성 .
This commit is contained in:
1 parent
ef203dc14d
commit
8c7893d989
8 files changed
+330
-27
No files matched your search
@@ -45,8 +45,14 @@ router = APIRouter(prefix="/upload", tags=["Social Upload"])
|
||||
- 해당 플랫폼에 계정이 연동되어 있어야 합니다
|
||||
- 영상이 completed 상태여야 합니다 (result_movie_url 필요)
|
||||
|
||||
## 지원 플랫폼
|
||||
- **youtube**: YouTube
|
||||
## 요청 필드
|
||||
- **video_id**: 업로드할 영상 ID
|
||||
- **social_account_id**: 업로드할 소셜 계정 ID (연동 계정 목록 조회 API에서 확인)
|
||||
- **title**: 영상 제목 (최대 100자)
|
||||
- **description**: 영상 설명 (최대 5000자)
|
||||
- **tags**: 태그 목록
|
||||
- **privacy_status**: 공개 상태 (public, unlisted, private)
|
||||
- **scheduled_at**: 예약 게시 시간 (선택사항)
|
||||
|
||||
## 업로드 상태
|
||||
업로드는 백그라운드에서 처리되며, 상태를 폴링하여 확인할 수 있습니다:
|
||||
@@ -72,7 +78,7 @@ async def upload_to_social(
|
||||
f"[UPLOAD_API] 업로드 요청 - "
|
||||
f"user_uuid: {current_user.user_uuid}, "
|
||||
f"video_id: {body.video_id}, "
|
||||
f"platform: {body.platform.value}"
|
||||
f"social_account_id: {body.social_account_id}"
|
||||
)
|
||||
|
||||
# 1. 영상 조회 및 검증
|
||||
@@ -92,19 +98,19 @@ async def upload_to_social(
|
||||
detail="영상이 아직 준비되지 않았습니다. 영상 생성이 완료된 후 시도해주세요.",
|
||||
)
|
||||
|
||||
# 2. 소셜 계정 조회
|
||||
account = await social_account_service.get_account_by_platform(
|
||||
# 2. 소셜 계정 조회 (social_account_id로 직접 조회, 소유권 검증 포함)
|
||||
account = await social_account_service.get_account_by_id(
|
||||
user_uuid=current_user.user_uuid,
|
||||
platform=body.platform,
|
||||
account_id=body.social_account_id,
|
||||
session=session,
|
||||
)
|
||||
|
||||
if not account:
|
||||
logger.warning(
|
||||
f"[UPLOAD_API] 연동 계정 없음 - "
|
||||
f"user_uuid: {current_user.user_uuid}, platform: {body.platform.value}"
|
||||
f"user_uuid: {current_user.user_uuid}, social_account_id: {body.social_account_id}"
|
||||
)
|
||||
raise SocialAccountNotFoundError(platform=body.platform.value)
|
||||
raise SocialAccountNotFoundError()
|
||||
|
||||
# 3. 기존 업로드 확인 (동일 video + account 조합)
|
||||
existing_result = await session.execute(
|
||||
@@ -125,7 +131,7 @@ async def upload_to_social(
|
||||
return SocialUploadResponse(
|
||||
success=True,
|
||||
upload_id=existing_upload.id,
|
||||
platform=body.platform.value,
|
||||
platform=account.platform,
|
||||
status=existing_upload.status,
|
||||
message="이미 업로드가 진행 중입니다.",
|
||||
)
|
||||
@@ -135,14 +141,17 @@ async def upload_to_social(
|
||||
user_uuid=current_user.user_uuid,
|
||||
video_id=body.video_id,
|
||||
social_account_id=account.id,
|
||||
platform=body.platform.value,
|
||||
platform=account.platform, # 계정의 플랫폼 정보 사용
|
||||
status=UploadStatus.PENDING.value,
|
||||
upload_progress=0,
|
||||
title=body.title,
|
||||
description=body.description,
|
||||
tags=body.tags,
|
||||
privacy_status=body.privacy_status.value,
|
||||
platform_options=body.platform_options,
|
||||
platform_options={
|
||||
**(body.platform_options or {}),
|
||||
"scheduled_at": body.scheduled_at.isoformat() if body.scheduled_at else None,
|
||||
},
|
||||
retry_count=0,
|
||||
)
|
||||
|
||||
@@ -152,7 +161,7 @@ async def upload_to_social(
|
||||
|
||||
logger.info(
|
||||
f"[UPLOAD_API] 업로드 레코드 생성 - "
|
||||
f"upload_id: {social_upload.id}, video_id: {body.video_id}"
|
||||
f"upload_id: {social_upload.id}, video_id: {body.video_id}, platform: {account.platform}"
|
||||
)
|
||||
|
||||
# 5. 백그라운드 태스크 등록
|
||||
@@ -161,7 +170,7 @@ async def upload_to_social(
|
||||
return SocialUploadResponse(
|
||||
success=True,
|
||||
upload_id=social_upload.id,
|
||||
platform=body.platform.value,
|
||||
platform=account.platform,
|
||||
status=social_upload.status,
|
||||
message="업로드 요청이 접수되었습니다.",
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user