37 lines
1023 B
Python
37 lines
1023 B
Python
"""SNS 업로드용 영상 메타데이터 비교/반영 헬퍼."""
|
|
|
|
from app.video.models import Video
|
|
|
|
|
|
def has_stored_sns_metadata(video: Video) -> bool:
|
|
"""video 행에 SNS 제목이 이미 저장되어 있는지 확인합니다."""
|
|
return bool(video.title)
|
|
|
|
|
|
def sns_metadata_changed(
|
|
video: Video,
|
|
title: str,
|
|
description: str | None,
|
|
tags: list[str] | None,
|
|
) -> bool:
|
|
"""게시 폼 값이 저장된 SNS 메타데이터와 다른지 비교합니다."""
|
|
stored_tags = list(video.hashtags or [])
|
|
incoming_tags = list(tags or [])
|
|
return (
|
|
(video.title or "") != title
|
|
or (video.description or "") != (description or "")
|
|
or stored_tags != incoming_tags
|
|
)
|
|
|
|
|
|
def apply_sns_metadata(
|
|
video: Video,
|
|
title: str,
|
|
description: str | None,
|
|
hashtags: list[str] | None,
|
|
) -> None:
|
|
"""video 행에 SNS 메타데이터를 반영합니다."""
|
|
video.title = title
|
|
video.description = description
|
|
video.hashtags = list(hashtags or [])
|