feat: P2V 파이프라인 연동 및 좋아요·댓글·공유 지원

- 무빙 포스터(p2v_video)·롱컷(p2v_playreel) 파이프라인과 워커, 갤러리·내 콘텐츠 노출
- 좋아요·댓글: comment/video_reaction에 p2v_playreel_id 추가, 종류별 CHECK 확장
- P2V 소프트 삭제(is_deleted), queued/running 삭제 차단
- 공개 상세·공유 OG 페이지 추가
- 삭제된 부모 댓글이 목록에서 사라지던 has_live_reply 서브쿼리 버그 수정
- 마이그레이션: migration_2026-10-15_p2v_reactions.sql
This commit is contained in:
skkim committed 2026-10-15 10:42:30 +09:00
1 parent bb1ea12958
commit b16d4a8f1b
126 files changed
+6921 -62

No files matched your search

View File
Whitespace-only changes.
+6
View File
@@ -0,0 +1,6 @@
"""출연진 이름 수집 응답 스키마."""
from pydantic import BaseModel
class CastAnswer(BaseModel):
cast: list[str]
@@ -0,0 +1,16 @@
"""② split 단계 — 상세페이지 섹션 분류 응답 스키마.
호출 실패 시 쓰는 'untagged'는 어휘에 넣지 않는다 — 모델이 고를 값이 아니라 우리가 채우는 값이다.
"""
from typing import Literal
from pydantic import BaseModel
DetailSectionTag = Literal[
"notice", "event", "keyvisual", "still", "synopsis", "cast",
"creative", "schedule", "discount", "crossbanner", "info", "fragment",
]
class DetailSectionTagAnswer(BaseModel):
tag: DetailSectionTag
+32
View File
@@ -0,0 +1,32 @@
"""detect 단계 VLM 응답 스키마.
strict structured output 제약: 전 필드 required, 없을 수 있는 값은 `| None`.
좌표 단위는 격자 눈금 퍼센트(0~100)다 — 정규화 좌표는 후처리에서 만든다.
"""
from typing import Literal
from pydantic import BaseModel
class GridBox(BaseModel):
x0: int
y0: int
x1: int
y1: int
text: str | None
class FocalAnswer(BaseModel):
name: str
x: int
y: int
class DetectAnswer(BaseModel):
festival_name: str
title: GridBox | None
datetime: GridBox | None
place: GridBox | None
logo: GridBox | None
title_style: Literal["calligraphy", "typeset"]
focal_points: list[FocalAnswer]
+23
View File
@@ -0,0 +1,23 @@
"""③ motion 단계 VLM 응답 스키마.
모션 키는 Literal로 고정한다 — 어휘 밖의 값이 나올 수 없다.
키 목록은 raw_prompt/motion_phrase.json과 일치해야 하며, motion.py가 기동 시 대조한다.
"""
from typing import Literal
from pydantic import BaseModel
MotionKey = Literal[
"firework", "water", "wave", "cloud", "smoke", "moon", "sun", "star", "light",
"flag", "foliage", "wheel", "vessel", "crowd", "ray", "snow", "fog", "glow",
]
class MotionElement(BaseModel):
motion: MotionKey
what: str
confident: bool
class MotionAnswer(BaseModel):
elements: list[MotionElement]
+80
View File
@@ -0,0 +1,80 @@
"""② narration_text 단계 LLM 응답 스키마.
검증 실패는 재생성 피드백으로 그대로 쓰이므로, 에러 메시지에 사유를 적는다.
"""
import re
from typing import Literal
from pydantic import BaseModel, field_validator
MAX_NARRATION_CHARS = 40
# TTS가 소리로 읽어버리는 문자 — 있으면 "물결", "점", "괄호"로 발음된다
SPEAK_BAN = re.compile(r"[~()\[\]/:]|\d\s*\.")
BGM_PROMPT_PREFIX = "starts hard on beat one"
class BgmStyle(BaseModel):
style: str
prompt: str
@field_validator("style")
@classmethod
def must_pin_down_sound(cls, style: str) -> str:
if not re.search(r"\d{2,3}\s*bpm", style, re.I):
raise ValueError(f"style에 숫자 bpm이 없음 (스톡 사운드 방지): {style!r}")
if "instrumental" not in style.lower():
raise ValueError(f"style에 instrumental이 없음 (보컬이 나레이션과 겹친다): {style!r}")
return style
@field_validator("prompt")
@classmethod
def must_start_on_beat_one(cls, prompt: str) -> str:
if not prompt.lower().startswith(BGM_PROMPT_PREFIX):
raise ValueError("prompt는 'Starts hard on beat one - no intro ramp.'로 시작해야 함 "
f"(Suno 무음 인트로 방지): {prompt!r}")
return prompt
class NarrationMetadata(BaseModel):
event_name: str
date_text: str
place: str
category: Literal["축제", "공연", "전시", "마켓", "기타"]
keywords: list[str]
region_guess: str
@field_validator("event_name", "place")
@classmethod
def must_not_be_blank(cls, value: str) -> str:
if not value.strip():
raise ValueError("metadata의 event_name·place는 비울 수 없음")
return value
@field_validator("keywords")
@classmethod
def must_have_keywords(cls, keywords: list[str]) -> list[str]:
if not keywords:
raise ValueError("metadata.keywords가 비어 있음")
return keywords
class NarrationAnswer(BaseModel):
narration: list[str]
voice: Literal["nova", "ash"]
bgm_style: BgmStyle
metadata: NarrationMetadata
@field_validator("narration")
@classmethod
def must_be_three_short_speakable_lines(cls, sentences: list[str]) -> list[str]:
if len(sentences) != 3:
raise ValueError(f"narration은 정확히 3문장이어야 함 (받은 문장 수: {len(sentences)})")
for sentence in sentences:
if not sentence.strip():
raise ValueError("빈 나레이션 문장이 있음")
if len(sentence) > MAX_NARRATION_CHARS:
raise ValueError(f"나레이션 문장이 {MAX_NARRATION_CHARS}자를 넘음: {sentence!r}")
if SPEAK_BAN.search(sentence):
raise ValueError("나레이션에 TTS가 소리내어 읽는 문자가 있음 "
f"(~ ( ) [ ] / : 숫자뒤 마침표): {sentence!r}")
return sentences
+8
View File
@@ -0,0 +1,8 @@
"""⑩ hybrid config 생성 — 인물 영역 응답 스키마."""
from pydantic import BaseModel
from app.p2v.answers.detect_answer import GridBox
class PersonBoxAnswer(BaseModel):
person: GridBox | None
+17
View File
@@ -0,0 +1,17 @@
"""스타일링 ① — 포스터에 인쇄된 글자 판독 응답 스키마
이미지 생성 모델이 한글을 다시 그리며 자모를 바꾸므로(맥주축제 → 백주축제)
읽기 잘하는 모델에 먼저 읽히고 그 문자열을 생성 프롬프트에 못 박는다.
"""
from pydantic import BaseModel
MAX_EXTRA_LINES = 3
class PosterTextAnswer(BaseModel):
title: str
slogan: str
date: str
time: str
place: str
extra: list[str]
+21
View File
@@ -0,0 +1,21 @@
"""스타일링 ② — 레퍼런스 화풍 분석 응답 스키마
무드 형용사는 픽셀로 번역되지 않아 팔레트·조명·질감·타이포·구도 다섯을 요구한다.
짧게 나오면 다섯 중 빠진 것이 있다는 뜻이라 통과시키지 않는다.
"""
from pydantic import BaseModel, field_validator
MIN_STYLE_PROMPT_CHARS = 200
class StylePromptAnswer(BaseModel):
style_prompt: str
@field_validator("style_prompt")
@classmethod
def must_cover_five_elements(cls, style_prompt: str) -> str:
text = style_prompt.strip()
if len(text) < MIN_STYLE_PROMPT_CHARS:
raise ValueError(f"style_prompt가 {len(text)}자로 너무 짧음 "
f"({MIN_STYLE_PROMPT_CHARS}자 이상) — 5요소가 다 안 나옴")
return text
+12
View File
@@ -0,0 +1,12 @@
"""⑥ 제목 훼손 게이트 2단(VLM 가독성) 응답 스키마."""
from pydantic import BaseModel
class FrameLegibility(BaseModel):
index: int
legible: bool
broken: str
class TitleGateAnswer(BaseModel):
frames: list[FrameLegibility]