feat(ssulbox): SNS 제목·설명·태그를 ssul_content에 저장
영상과 같이 업로드·SEO 결과를 행에 남기고, 다음 요청부터는 DB 값을 쓴다. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
fde48e8674
commit
e47a97476d
9 files changed
+108
-36
No files matched your search
@@ -1,36 +1,45 @@
|
||||
"""SNS 업로드용 영상 메타데이터 비교/반영 헬퍼."""
|
||||
"""SNS 업로드용 메타데이터 비교/반영 헬퍼.
|
||||
|
||||
from app.video.models import Video
|
||||
`video` 와 `ssul_content` 모두 `title` / `description` / `hashtags` 를 갖는다.
|
||||
"""
|
||||
|
||||
from typing import Protocol
|
||||
|
||||
|
||||
def has_stored_sns_metadata(video: Video) -> bool:
|
||||
"""video 행에 SNS 제목이 이미 저장되어 있는지 확인합니다."""
|
||||
return bool(video.title)
|
||||
class SnsMetadataTarget(Protocol):
|
||||
title: str | None
|
||||
description: str | None
|
||||
hashtags: list | None
|
||||
|
||||
|
||||
def has_stored_sns_metadata(row: SnsMetadataTarget) -> bool:
|
||||
"""행에 SNS 제목이 이미 저장되어 있는지 확인합니다."""
|
||||
return bool(row.title)
|
||||
|
||||
|
||||
def sns_metadata_changed(
|
||||
video: Video,
|
||||
row: SnsMetadataTarget,
|
||||
title: str,
|
||||
description: str | None,
|
||||
tags: list[str] | None,
|
||||
) -> bool:
|
||||
"""게시 폼 값이 저장된 SNS 메타데이터와 다른지 비교합니다."""
|
||||
stored_tags = list(video.hashtags or [])
|
||||
stored_tags = list(row.hashtags or [])
|
||||
incoming_tags = list(tags or [])
|
||||
return (
|
||||
(video.title or "") != title
|
||||
or (video.description or "") != (description or "")
|
||||
(row.title or "") != title
|
||||
or (row.description or "") != (description or "")
|
||||
or stored_tags != incoming_tags
|
||||
)
|
||||
|
||||
|
||||
def apply_sns_metadata(
|
||||
video: Video,
|
||||
row: SnsMetadataTarget,
|
||||
title: str,
|
||||
description: str | None,
|
||||
hashtags: list[str] | None,
|
||||
) -> None:
|
||||
"""video 행에 SNS 메타데이터를 반영합니다."""
|
||||
video.title = title
|
||||
video.description = description
|
||||
video.hashtags = list(hashtags or [])
|
||||
"""행에 SNS 메타데이터를 반영합니다."""
|
||||
row.title = title
|
||||
row.description = description
|
||||
row.hashtags = list(hashtags or [])
|
||||
Reference in new issue
Block a user