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.
+31
View File
@@ -0,0 +1,31 @@
from dataclasses import dataclass
from PIL import Image
from pydantic import BaseModel
from app.p2v.schemas.motion import MotionPlan
class MotionChoice(BaseModel):
"""검수 화면의 토글 하나. on이 꺼진 것은 VLM이 확신하지 못해 탈락시킨 요소다."""
key: str
label: str
what: str
on: bool
class FixedLayer(BaseModel):
key: str
label: str
on: bool = True
@dataclass
class PosterAnalysis:
grid: Image.Image # 사람이 요소를 지목하는 격자
movable: list[MotionChoice]
fixed: list[FixedLayer]
model: str
ip_risk: bool
has_qr: bool
plan: MotionPlan # 사람이 고르기 전의 VLM 제안 원본
+9
View File
@@ -0,0 +1,9 @@
from dataclasses import dataclass
@dataclass
class BgmAudio:
mp3: bytes
seconds: int # 요청한 목표 길이
duration: float # Suno가 돌려준 실제 길이
task_id: str
+12
View File
@@ -0,0 +1,12 @@
from typing import Literal
from pydantic import BaseModel
class CastExtraction(BaseModel):
"""NOL meta에는 출연진 필드가 없어 상세페이지에서 읽는다.
실패해도 잡을 멈추지 않고 source로 남겨 검수 게이트에서 사람이 판단하게 한다.
"""
names: list[str] = []
source: Literal["vlm", "failed", "none"] = "none"
+26
View File
@@ -0,0 +1,26 @@
from dataclasses import dataclass
from PIL import Image
UNTAGGED = "untagged"
@dataclass
class DetailSection:
source: str # 잘라낸 원본 이름 (detail_01 …)
index: int # 그 원본 안에서의 순번
y0: int
y1: int
# compose는 좌표만 쓴다 — 조각 그림 없이 만들어도 된다
image: Image.Image | None = None
tag: str = UNTAGGED
@property
def name(self) -> str:
return f"{self.source}_s{self.index:02d}"
@dataclass
class DetailSplitResult:
sections: list[DetailSection]
sheet: Image.Image # 육안 검수용 컨택트 시트
+38
View File
@@ -0,0 +1,38 @@
from dataclasses import dataclass
from PIL import Image
from pydantic import BaseModel
class Box(BaseModel):
"""포스터 기준 정규화 박스(0~1)."""
x0: float
y0: float
x1: float
y1: float
cx: float
cy: float
text: str | None = None
class Focal(BaseModel):
name: str
cx: float
cy: float
class Regions(BaseModel):
festival_name: str | None
title_style: str | None
recommended_mode: str
poster_size: tuple[int, int]
regions: dict[str, Box]
focal_points: list[Focal]
vlm_raw: dict
@dataclass
class DetectResult:
data: Regions
grid: Image.Image
check: Image.Image
+48
View File
@@ -0,0 +1,48 @@
from dataclasses import dataclass
from PIL import Image
from pydantic import BaseModel, ConfigDict, Field
Rect = tuple[float, float, float, float]
class MaskSpec(BaseModel):
"""rect — 사각 전체 고정(밝은 배경 포스터. 베벨·그림자까지 덮는다).
glyph — 사각 안 글자 픽셀만. 검정 포스터용이며 register와 함께 써야 한다."""
mode: str = "rect"
ink_min: int = 55
thin_dilate: int = 9
thick_dilate: int = 25
thick_from_y: float = 0.85
class HybridSpec(BaseModel):
# register는 BaseModel 속성과 겹쳐 이름을 바꾸고 alias로 원본 키를 받음
model_config = ConfigDict(populate_by_name=True)
clip: str | None = None
clip_crop: str | None = None # "x0,y0,w,h" — 9:16 캔버스에 얹힌 클립용
register_frames: bool = Field(False, alias="register")
class LayerConfig(BaseModel):
"""작품별 좌표. 아직 사람이 손으로 쓴다 — 신규 공연은 여기서 멈추는 게 정상이다."""
mask: MaskSpec = MaskSpec()
fixed_rects: list[Rect] = []
sil_box: Rect = (0.0, 0.0, 0.0, 0.0)
sil_poly: list[tuple[float, float]] = []
glyphs: dict[str, Rect] = {}
sweep_at: dict[str, float] = {}
punches: list[tuple[Rect, float, float]] = [] # (사각, 시작초, 피크배율)
glows: list[tuple[Rect, float]] = []
protect: list[Rect] = []
glyph_dark_ink: bool = True
hybrid: HybridSpec = Field(default_factory=HybridSpec)
@dataclass
class HybridResult:
video: bytes
frames: int
duration: float
proof: Image.Image | None = None # 8시점 컨택트 시트
+28
View File
@@ -0,0 +1,28 @@
from dataclasses import dataclass
from pydantic import BaseModel
class FrameVerdict(BaseModel):
index: int
time: float
legible: bool
broken: str
class TitleGateVerdict(BaseModel):
passed: bool
reason: str = ""
skip: str = "" # 판단 근거가 없어 통과시킨 사유
pixel_score: float | None = None # 글리프 휘도차 A
pixel_hard: bool = False # 하드컷 초과 — VLM 2단으로 넘어감
samples: list[float] = []
frames: list[FrameVerdict] = []
@dataclass
class I2vResult:
clip: bytes
credits: float # generate create 응답에 크레딧이 없어 cost 조회값을 쓴다
model: str
title_gate: TitleGateVerdict
+39
View File
@@ -0,0 +1,39 @@
from dataclasses import dataclass
from typing import Literal
from PIL import Image
from pydantic import BaseModel
SceneKind = Literal["clip", "stills", "scroll", "poster"]
class Scene(BaseModel):
"""나레이션 큐 하나에 대응하는 화면."""
cue: int
kind: SceneKind
section: str | None = None # scroll 시작점이 된 섹션 이름
tag: str | None = None # 그 섹션의 태그. 왜 골랐는지 남긴다
# scroll은 조각이 아니라 롱이미지 위에서 일어난다. 아래 셋이 그 좌표다
source: str | None = None # 훑을 롱이미지 (detail_01 …)
y0: float | None = None # 시작 위치. 롱이미지 높이 대비 0~1
y1: float | None = None # 끝 위치
class LongcutPlan(BaseModel):
scenes: list[Scene]
class EndBandInfo(BaseModel):
"""엔드밴드 두 줄. 위가 공연명, 아래가 일시·장소."""
title: str
detail: str
@dataclass
class LongcutResult:
video: bytes
thumbnail: bytes # 첫 프레임. 0초가 포스터 원본이라 그대로 정지컷이 된다
duration: float
frames: int
plan: LongcutPlan
proof: Image.Image | None = None
+19
View File
@@ -0,0 +1,19 @@
from pydantic import BaseModel
class MotionItem(BaseModel):
motion: str
what: str
class DroppedMotion(BaseModel):
motion: str
what: str
why: str
class MotionPlan(BaseModel):
prompt: str
has_qr: bool
kept: list[MotionItem]
dropped: list[DroppedMotion]
+17
View File
@@ -0,0 +1,17 @@
from pydantic import BaseModel
NARRATION_SLOTS = ("훅1", "훅2", "수상", "넘버", "캐스팅스케줄", "일시", "CTA")
class NarrationLine(BaseModel):
slot: str
text: str
class SlotNarration(BaseModel):
"""롱컷 나레이션 7문장. 게이트 ③에서 사람이 고치면 그것이 읽히는 문장이 된다."""
lines: list[NarrationLine]
@property
def texts(self) -> list[str]:
return [line.text for line in self.lines]
+40
View File
@@ -0,0 +1,40 @@
from dataclasses import dataclass, field
from pydantic import BaseModel, ConfigDict, Field
class NolMeta(BaseModel):
"""상품 페이지 SSR HTML에서 긁어낸 공연 정보."""
model_config = ConfigDict(populate_by_name=True)
goods_id: str
url: str
goods_name: str | None = Field(None, alias="goodsName")
place_name: str | None = Field(None, alias="placeName")
play_start_date: str | None = Field(None, alias="playStartDate")
play_end_date: str | None = Field(None, alias="playEndDate")
running_time: str | None = Field(None, alias="runningTime")
inter_mission_time: str | None = Field(None, alias="interMissionTime")
view_rate_name: str | None = Field(None, alias="viewRateName")
genre_name: str | None = Field(None, alias="genreName")
sub_genre_name: str | None = Field(None, alias="subGenreName")
corporation_name: str | None = Field(None, alias="corporationName")
poster_image_url: str | None = Field(None, alias="posterImageUrl")
booking_open_time: str | None = Field(None, alias="bookingOpenTime")
min_price: int | None = None
detail_image_urls: list[str] = []
@dataclass
class FetchedImage:
url: str
data: bytes
extension: str # 확장자가 .gif여도 실제 바이트로 판별한 값
@dataclass
class NolProduct:
meta: NolMeta
poster: FetchedImage | None
details: list[FetchedImage]
failed_urls: list[str] = field(default_factory=list)
+47
View File
@@ -0,0 +1,47 @@
"""DB 잡 레코드의 진행도로 쓰이는 파이프라인 단계 상태
실행 순서대로 선언됨
마지막 COMPLETED는 종료 표시
"""
from enum import StrEnum
def stage_keys(state_type) -> list[str]:
"""실행 순서대로 나열된 단계 이름
COMPLETED는 종료 표시라 빠짐
"""
return [member.value for member in state_type if member.name != "COMPLETED"]
def initial_timings(state_type) -> dict:
"""스테퍼가 그리는 단계별 시각의 초기값
키 순서가 곧 화면에 찍히는 순서라 생성 시점에 다 채워 둔다
"""
return {key: {"status": "idle", "started": None, "ended": None}
for key in stage_keys(state_type)}
class PosterAliveState(StrEnum):
DETECT = "detect"
NARRATION_TEXT = "narration_text"
MOTION = "motion"
TTS = "tts"
BGM = "bgm"
I2V = "i2v"
RENDER = "render"
COMPLETED = "completed"
class PlayreelState(StrEnum):
FETCH = "fetch"
SPLIT = "split"
UPSCALE = "upscale"
ANALYZE = "analyze"
MOTION = "motion"
NARRATION = "narration"
TTS = "tts"
BGM = "bgm"
I2V = "i2v"
HYBRID = "hybrid"
COMPOSE = "compose"
REVIEW = "review"
COMPLETED = "completed"
+22
View File
@@ -0,0 +1,22 @@
"""P2V 공개 상세 응답 — 공유 링크로 들어온 비로그인 사용자도 본다."""
from datetime import datetime
from typing import Literal
from pydantic import BaseModel, Field
class P2vDetailResponse(BaseModel):
"""`GET /p2v/f1/{id}` · `GET /p2v/playreel/{id}` 응답.
썰박스 공개 상세와 같은 필드 구성이다. `is_liked_by_me` 는 비로그인이면 항상 False.
댓글은 `GET /comment/video/{id}?type=...` 로 따로 조회한다.
"""
type: Literal["p2v_video", "p2v_playreel"] = Field(..., description="콘텐츠 종류")
content_id: int = Field(..., description="콘텐츠 고유 ID (type 안에서만 유일)")
video_url: str = Field(..., description="완성 영상 재생 URL")
poster_url: str | None = Field(None, description="썸네일 이미지 URL")
title: str | None = Field(None, description="콘텐츠 이름")
created_at: datetime = Field(..., description="생성 일시")
like_count: int = Field(..., description="좋아요 수")
is_liked_by_me: bool = Field(..., description="현재 로그인 사용자가 좋아요를 눌렀는지")
+11
View File
@@ -0,0 +1,11 @@
from dataclasses import dataclass
@dataclass
class RenderResult:
video: bytes
thumbnail: bytes # 첫 프레임. 정지 광고판 컷이 곧 썸네일이다
duration: float
frames: int
width: int
height: int
+60
View File
@@ -0,0 +1,60 @@
"""포스터 스타일링 — 화풍 레퍼런스로 포스터를 다시 그린다"""
from dataclasses import dataclass
from enum import StrEnum
from pydantic import BaseModel
class TemplateLicense(StrEnum):
"""끄는 조건이 달라 등급을 나눈다
PUBLIC은 보호기간이 끝나 외부 공개가 되고
INTERNAL은 번들 레퍼런스의 권리가 남아 배포 시 감추며
USER는 올린 사람 책임이라 막지 않고 고지만 한다
"""
PUBLIC = "public-domain"
INTERNAL = "internal-only"
USER = "user-uploaded"
class TemplateCategory(StrEnum):
FINE_ART = "fine_art"
ORIENTAL = "oriental"
FILM = "film"
USER = "user"
class StyleTemplate(BaseModel):
"""번들과 사용자 레퍼런스가 같은 모양을 쓴다"""
id: str
name_ko: str
category: TemplateCategory
license: TemplateLicense
style_prompt: str
reference_url: str # 전이에 넣는 고해상본
thumbnail_url: str
attribution: str = ""
license_note: str = ""
small_reference: bool = False # 레퍼런스가 작아 결과가 나빠질 수 있음
class OutputFormat(BaseModel):
"""gpt-image가 내는 크기로 만든 뒤 필요하면 센터 크롭한다"""
id: str
label: str
generated_size: str
crop: tuple[int, int] | None = None
@dataclass
class ReferenceVariants:
reference: bytes # 긴 변 REFERENCE_LONG_EDGE
thumbnail: bytes
size: tuple[int, int]
@dataclass
class TransferResult:
image: bytes
format_id: str
style_prompt: str
has_info_band: bool # 날짜·장소를 밴드로 얹었는가
+40
View File
@@ -0,0 +1,40 @@
from dataclasses import dataclass
from pydantic import BaseModel
# Typecast 카탈로그 id. 롱컷 나레이션 보이스 정본이다.
TYPECAST_YENA = "tc_61e748d0fd9fb2d2cacbb04d"
class TypecastVoice(BaseModel):
"""Typecast(ssfm-v30) 설정. 주면 엔진이 typecast가 된다."""
voice_id: str = TYPECAST_YENA
emotion: str = "normal"
emotion_intensity: float = 1.0
tempo: float = 1.0 # OpenAI의 speed에 대응
class NarrationCue(BaseModel):
index: int
text: str
start: float
duration: float
end: float
pause_after: float
class NarrationTimeline(BaseModel):
"""씬·카메라 비트를 여기 큐에 맞춘다."""
engine: str
voice: str
lead_in: float
tail: float
total: float
cues: list[NarrationCue]
@dataclass
class NarrationAudio:
timeline: NarrationTimeline
mp3: bytes # 큐 위치에 얹어 합친 한 트랙
+8
View File
@@ -0,0 +1,8 @@
from dataclasses import dataclass
@dataclass
class UpscaleResult:
image: bytes
credits: int
variant: str