카페, 식당 템플릿 적용
This commit is contained in:
1 parent
76485ebbcc
commit
e53084ed17
4 files changed
+45
-19
No files matched your search
+33
-13
@@ -225,29 +225,48 @@ autotext_template_h_1 = {
|
||||
"stroke_color": "#333333",
|
||||
"stroke_width": "0.2 vmin"
|
||||
}
|
||||
DVST0001 = "75161273-0422-4771-adeb-816bd7263fb0"
|
||||
DVST0002 = "c68cf750-bc40-485a-a2c5-3f9fe301e386"
|
||||
DVST0003 = "e1fb5b00-1f02-4f63-99fa-7524b433ba47"
|
||||
DVST0001 = "fe11aeab-ff29-4bc8-9f75-c695c7e243e6"
|
||||
DVRT0001 = "3c4b74c4-82d7-4742-9b05-4b999fef4cbd"
|
||||
DVCF0001 = "ebb532ec-e49a-4a7e-b0e2-a8132f1bf1f7"
|
||||
DHST0001 = "660be601-080a-43ea-bf0f-adcf4596fa98"
|
||||
DHST0002 = "3f194cc7-464e-4581-9db2-179d42d3e40f"
|
||||
DHST0003 = "f45df555-2956-4a13-9004-ead047070b3d"
|
||||
DVST0001T = "fe11aeab-ff29-4bc8-9f75-c695c7e243e6"
|
||||
HST_LIST = [DHST0001,DHST0002,DHST0003]
|
||||
VST_LIST = [DVST0001T]
|
||||
VST_LIST = [DVST0001,DVRT0001,DVCF0001]
|
||||
|
||||
# industry → 세로형 템플릿 매핑 (신규 세로형 템플릿 추가 시 여기에만 등록)
|
||||
VERTICAL_INDUSTRY_TEMPLATE_MAP: dict[str, str] = {
|
||||
"stay": DVST0001,
|
||||
"restaurant": DVRT0001,
|
||||
"cafe": DVCF0001,
|
||||
}
|
||||
|
||||
# 매핑에 없는 업종(salon, clinic 등)의 폴백 템플릿
|
||||
DEFAULT_VERTICAL_TEMPLATE = DVST0001
|
||||
|
||||
SCENE_TRACK = 1
|
||||
AUDIO_TRACK = 2
|
||||
SUBTITLE_TRACK = 3
|
||||
KEYWORD_TRACK = 4
|
||||
|
||||
def select_template(orientation:OrientationType):
|
||||
def select_template(orientation: OrientationType, industry: str | None = None) -> str:
|
||||
"""orientation과 industry에 따라 Creatomate 템플릿 ID를 선택합니다.
|
||||
|
||||
Args:
|
||||
orientation: 영상 방향 ("horizontal" 또는 "vertical")
|
||||
industry: 업종 분류 (stay|restaurant|cafe 등).
|
||||
세로형에서만 사용되며, 매핑에 없으면 기본 템플릿으로 폴백합니다.
|
||||
|
||||
Returns:
|
||||
선택된 템플릿 ID
|
||||
"""
|
||||
if orientation == "horizontal":
|
||||
template_id = DHST0001
|
||||
elif orientation == "vertical":
|
||||
template_id = random.choice(VST_LIST)
|
||||
template_id = VERTICAL_INDUSTRY_TEMPLATE_MAP.get(industry, DEFAULT_VERTICAL_TEMPLATE)
|
||||
else:
|
||||
raise
|
||||
logger.info(f"[select_template] orientation={orientation}, template_id={template_id}")
|
||||
logger.info(f"[select_template] orientation={orientation}, industry={industry}, template_id={template_id}")
|
||||
return template_id
|
||||
|
||||
async def get_shared_client() -> httpx.AsyncClient:
|
||||
@@ -296,21 +315,22 @@ class CreatomateService:
|
||||
def __init__(
|
||||
self,
|
||||
api_key: str | None = None,
|
||||
orientation: OrientationType = "vertical"
|
||||
orientation: OrientationType = "vertical",
|
||||
industry: str | None = None,
|
||||
):
|
||||
"""
|
||||
Args:
|
||||
api_key: Creatomate API 키 (Bearer token으로 사용)
|
||||
None일 경우 config에서 자동으로 가져옴
|
||||
orientation: 영상 방향 ("horizontal" 또는 "vertical", 기본값: "vertical")
|
||||
target_duration: 목표 영상 길이 (초)
|
||||
None일 경우 orientation에 해당하는 기본값 사용
|
||||
industry: 업종 분류 (stay|restaurant|cafe 등). 세로형 템플릿 선택에 사용되며,
|
||||
매핑에 없거나 None이면 기본 세로형 템플릿으로 폴백
|
||||
"""
|
||||
self.api_key = api_key or apikey_settings.CREATOMATE_API_KEY
|
||||
self.orientation = orientation
|
||||
|
||||
# orientation에 따른 템플릿 설정 가져오기
|
||||
self.template_id = select_template(orientation)
|
||||
# orientation·industry에 따른 템플릿 설정 가져오기
|
||||
self.template_id = select_template(orientation, industry=industry)
|
||||
self.headers = {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": f"Bearer {self.api_key}",
|
||||
|
||||
Reference in new issue
Block a user