feat: 업로드 워커가 p2v_video 원본 URL 을 읽도록 분기 추가
This commit is contained in:
1 parent
951a1721b5
commit
81a554193c
1 file changed
+26
-16
@@ -20,6 +20,7 @@ from app.dashboard.tasks import insert_dashboard
|
|||||||
from app.database.session import BackgroundSessionLocal
|
from app.database.session import BackgroundSessionLocal
|
||||||
from app.social.constants import SocialPlatform, UploadStatus
|
from app.social.constants import SocialPlatform, UploadStatus
|
||||||
from app.social.exceptions import TokenExpiredError, UploadQuotaExceededError
|
from app.social.exceptions import TokenExpiredError, UploadQuotaExceededError
|
||||||
|
from app.p2v.models import PosterAliveTask
|
||||||
from app.social.models import SocialUpload
|
from app.social.models import SocialUpload
|
||||||
from app.social.services import social_account_service
|
from app.social.services import social_account_service
|
||||||
from app.social.uploader import get_uploader
|
from app.social.uploader import get_uploader
|
||||||
@@ -143,6 +144,28 @@ async def _increment_retry_count(upload_id: int) -> int:
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
async def _resolve_source_url(session, upload: SocialUpload) -> Optional[str]:
|
||||||
|
"""업로드가 가리키는 콘텐츠 종류의 영상 URL. 병합 스키마라 채워진 FK 가 곧 종류다."""
|
||||||
|
if upload.p2v_video_id is not None:
|
||||||
|
row = (
|
||||||
|
await session.execute(
|
||||||
|
select(PosterAliveTask).where(PosterAliveTask.id == upload.p2v_video_id)
|
||||||
|
)
|
||||||
|
).scalar_one_or_none()
|
||||||
|
return row.video_url if row else None
|
||||||
|
if upload.content_id is not None:
|
||||||
|
row = (
|
||||||
|
await session.execute(
|
||||||
|
select(SsulContent).where(SsulContent.id == upload.content_id)
|
||||||
|
)
|
||||||
|
).scalar_one_or_none()
|
||||||
|
return row.video_url if row else None
|
||||||
|
row = (
|
||||||
|
await session.execute(select(Video).where(Video.id == upload.video_id))
|
||||||
|
).scalar_one_or_none()
|
||||||
|
return row.result_movie_url if row else None
|
||||||
|
|
||||||
|
|
||||||
async def process_social_upload(upload_id: int) -> None:
|
async def process_social_upload(upload_id: int) -> None:
|
||||||
"""
|
"""
|
||||||
소셜 미디어 업로드 처리
|
소셜 미디어 업로드 처리
|
||||||
@@ -168,27 +191,14 @@ async def process_social_upload(upload_id: int) -> None:
|
|||||||
logger.error(f"[SOCIAL_UPLOAD] 업로드 레코드 없음 - upload_id: {upload_id}")
|
logger.error(f"[SOCIAL_UPLOAD] 업로드 레코드 없음 - upload_id: {upload_id}")
|
||||||
return
|
return
|
||||||
|
|
||||||
# 2. 대상 영상 조회.
|
# 2. 대상 영상 조회. video_id / content_id / p2v_video_id 중 정확히 하나만 채워져 있다(CHECK).
|
||||||
# 병합 스키마: video_id / content_id 중 정확히 하나만 채워져 있다(CHECK).
|
source_url = await _resolve_source_url(session, upload)
|
||||||
# 채워진 쪽이 곧 종류다 — 썰박스면 ssul_content.video_url 을 쓴다.
|
|
||||||
if upload.content_id is not None:
|
|
||||||
content_result = await session.execute(
|
|
||||||
select(SsulContent).where(SsulContent.id == upload.content_id)
|
|
||||||
)
|
|
||||||
content = content_result.scalar_one_or_none()
|
|
||||||
source_url = content.video_url if content else None
|
|
||||||
else:
|
|
||||||
video_result = await session.execute(
|
|
||||||
select(Video).where(Video.id == upload.video_id)
|
|
||||||
)
|
|
||||||
video = video_result.scalar_one_or_none()
|
|
||||||
source_url = video.result_movie_url if video else None
|
|
||||||
|
|
||||||
if not source_url:
|
if not source_url:
|
||||||
logger.error(
|
logger.error(
|
||||||
f"[SOCIAL_UPLOAD] 영상 없음 또는 URL 없음 - "
|
f"[SOCIAL_UPLOAD] 영상 없음 또는 URL 없음 - "
|
||||||
f"upload_id: {upload_id}, video_id: {upload.video_id}, "
|
f"upload_id: {upload_id}, video_id: {upload.video_id}, "
|
||||||
f"content_id: {upload.content_id}"
|
f"content_id: {upload.content_id}, p2v_video_id: {upload.p2v_video_id}"
|
||||||
)
|
)
|
||||||
await _update_upload_status(
|
await _update_upload_status(
|
||||||
upload_id=upload_id,
|
upload_id=upload_id,
|
||||||
|
|||||||
Reference in new issue
Block a user