Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a253c5dd3a | ||
|
|
7ec9e9749d | ||
|
|
236c7916a7 | ||
|
|
593b6d9922 | ||
|
|
18ba089110 | ||
|
|
64b9959000 | ||
|
|
3af57500b2 |
No files matched your search
@@ -120,7 +120,7 @@ async def _resolve_industry(category: str, customer_name: str = "") -> str:
|
|||||||
"위 정보를 바탕으로 이 업체를 다음 업종 중 가장 적합한 하나로 분류하세요: "
|
"위 정보를 바탕으로 이 업체를 다음 업종 중 가장 적합한 하나로 분류하세요: "
|
||||||
"stay(숙박/펜션/호텔), restaurant(음식점), cafe(카페/디저트), "
|
"stay(숙박/펜션/호텔), restaurant(음식점), cafe(카페/디저트), "
|
||||||
"salon(미용실/네일/뷰티), clinic(병원/의원/치과), fitness(헬스/필라테스/요가), "
|
"salon(미용실/네일/뷰티), clinic(병원/의원/치과), fitness(헬스/필라테스/요가), "
|
||||||
"academy(학원/교습소), attraction(관광/체험/액티비티). "
|
"academy(학원/교습소), attraction(관광/체험/액티비티/축제/행사). "
|
||||||
"위 8개 중 어느 것에도 명확히 해당하지 않는 경우에만 general(기타/범용 업종)로 분류하세요. "
|
"위 8개 중 어느 것에도 명확히 해당하지 않는 경우에만 general(기타/범용 업종)로 분류하세요. "
|
||||||
"유사한 업종이 있으면 general 대신 그 업종을 우선 선택하세요."
|
"유사한 업종이 있으면 general 대신 그 업종을 우선 선택하세요."
|
||||||
)
|
)
|
||||||
@@ -304,11 +304,14 @@ async def _crawling_logic(
|
|||||||
extra_photo_urls = scraper.extra_photo_urls or []
|
extra_photo_urls = scraper.extra_photo_urls or []
|
||||||
|
|
||||||
if len(owner_images) >= NvMapScraper.SUPPLEMENT_THRESHOLD:
|
if len(owner_images) >= NvMapScraper.SUPPLEMENT_THRESHOLD:
|
||||||
scraper.image_link_list = owner_images[: NvMapScraper.MAX_IMAGES]
|
# 업체 제공 사진은 필터링 면제 대상이므로 MAX_IMAGES 상한 없이 수집분을 전부 사용한다
|
||||||
|
# (MAX_IMAGES 상한은 방문자 사진이 섞이는 보충 경로에만 적용.
|
||||||
|
# 수집 자체는 NvMapScraper.BIZ_MAX_PAGES가 상한이며 도달 시 scraper가 warning을 남긴다).
|
||||||
|
scraper.image_link_list = list(owner_images)
|
||||||
step3_elapsed = (time.perf_counter() - step3_start) * 1000
|
step3_elapsed = (time.perf_counter() - step3_start) * 1000
|
||||||
logger.info(
|
logger.info(
|
||||||
f"[crawling] Step 3 SKIP - 업체 사진 {len(owner_images)}장 "
|
f"[crawling] Step 3 SKIP - 업체 사진 {len(owner_images)}장 "
|
||||||
f"≥ {NvMapScraper.SUPPLEMENT_THRESHOLD}장 → 방문자 사진 필터링 생략"
|
f"≥ {NvMapScraper.SUPPLEMENT_THRESHOLD}장 → 방문자 사진 필터링 생략, 업체 사진만 사용"
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ from app.utils.prompts.schemas import SpaceType, Subject, Camera, MotionRecommen
|
|||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
async def autotag_image(image_url : str, industry: str = "") -> list[str]: #tag_list
|
async def autotag_image(image_url : str, industry: str = "") -> list[str]: #tag_list
|
||||||
chatgpt = ChatgptService(model_type="gemini")
|
chatgpt = ChatgptService(model_type="gpt")
|
||||||
image_input_data = {
|
image_input_data = {
|
||||||
"img_url" : image_url,
|
"img_url" : image_url,
|
||||||
"industry" : industry,
|
"industry" : industry,
|
||||||
@@ -21,7 +21,7 @@ async def autotag_image(image_url : str, industry: str = "") -> list[str]: #tag_
|
|||||||
return image_result
|
return image_result
|
||||||
|
|
||||||
async def autotag_images(image_url_list : list[str], industry: str = "") -> list[dict]: #tag_list
|
async def autotag_images(image_url_list : list[str], industry: str = "") -> list[dict]: #tag_list
|
||||||
chatgpt = ChatgptService(model_type="gemini")
|
chatgpt = ChatgptService(model_type="gpt")
|
||||||
image_input_data_list = [{
|
image_input_data_list = [{
|
||||||
"img_url" : image_url,
|
"img_url" : image_url,
|
||||||
"industry" : industry,
|
"industry" : industry,
|
||||||
|
|||||||
+74
-19
@@ -228,34 +228,66 @@ autotext_template_h_1 = {
|
|||||||
DVST0001 = "fe11aeab-ff29-4bc8-9f75-c695c7e243e6"
|
DVST0001 = "fe11aeab-ff29-4bc8-9f75-c695c7e243e6"
|
||||||
DVRT0001 = "3c4b74c4-82d7-4742-9b05-4b999fef4cbd"
|
DVRT0001 = "3c4b74c4-82d7-4742-9b05-4b999fef4cbd"
|
||||||
DVCF0001 = "ebb532ec-e49a-4a7e-b0e2-a8132f1bf1f7"
|
DVCF0001 = "ebb532ec-e49a-4a7e-b0e2-a8132f1bf1f7"
|
||||||
|
DVAT0001 = "14d4fa22-49b8-49ca-a233-ac0556436f60"
|
||||||
|
DVSL0001 = "20c526a7-b184-46f3-9138-9dfaff2fa342"
|
||||||
|
DVCL0001 = "b57dca80-167d-430a-8905-30f4674ff72b"
|
||||||
|
DVFT0001 = "03b6d521-4864-4e69-8e6c-1deab9f0ce6e"
|
||||||
|
DVAC0001 = "4db8f5a3-4fd1-42cf-86b3-d997f0713d99"
|
||||||
|
|
||||||
DHST0001 = "660be601-080a-43ea-bf0f-adcf4596fa98"
|
DHST0001 = "660be601-080a-43ea-bf0f-adcf4596fa98"
|
||||||
DHST0002 = "3f194cc7-464e-4581-9db2-179d42d3e40f"
|
|
||||||
DHST0003 = "f45df555-2956-4a13-9004-ead047070b3d"
|
HST_LIST = [DHST0001]
|
||||||
HST_LIST = [DHST0001,DHST0002,DHST0003]
|
VST_LIST = [DVST0001,DVRT0001,DVCF0001,DVAT0001,DVSL0001,DVCL0001,DVFT0001,DVAC0001]
|
||||||
VST_LIST = [DVST0001,DVRT0001,DVCF0001]
|
|
||||||
|
|
||||||
# industry → 세로형 템플릿 매핑 (신규 세로형 템플릿 추가 시 여기에만 등록)
|
# industry → 세로형 템플릿 매핑 (신규 세로형 템플릿 추가 시 여기에만 등록)
|
||||||
VERTICAL_INDUSTRY_TEMPLATE_MAP: dict[str, str] = {
|
VERTICAL_INDUSTRY_TEMPLATE_MAP: dict[str, str] = {
|
||||||
"stay": DVST0001,
|
"stay": DVST0001,
|
||||||
"restaurant": DVRT0001,
|
"restaurant": DVRT0001,
|
||||||
"cafe": DVCF0001,
|
"cafe": DVCF0001,
|
||||||
|
"attraction": DVAT0001,
|
||||||
|
"salon": DVSL0001,
|
||||||
|
"clinic": DVCL0001,
|
||||||
|
"fitness": DVFT0001,
|
||||||
|
"academy": DVAC0001,
|
||||||
}
|
}
|
||||||
|
|
||||||
# 매핑에 없는 업종(salon, clinic 등)의 폴백 템플릿
|
# 매핑에 없는 업종(general)의 폴백 템플릿
|
||||||
DEFAULT_VERTICAL_TEMPLATE = DVST0001
|
DEFAULT_VERTICAL_TEMPLATE = DVST0001
|
||||||
|
|
||||||
|
# 템플릿 슬롯명의 모션 동의어 → MotionRecommended 표준값 정규화 맵.
|
||||||
|
# 동의어를 enum에 추가하면 LLM 태그 후보가 갈라져 매칭 정확도가 떨어지므로,
|
||||||
|
# enum은 표준 어휘만 유지하고 슬롯명 파싱 경계에서 흡수한다.
|
||||||
|
MOTION_TOKEN_NORMALIZATION: dict[str, MotionRecommended] = {
|
||||||
|
"zoom_in": MotionRecommended.slow_zoom_in,
|
||||||
|
"zoom_out": MotionRecommended.slow_zoom_out,
|
||||||
|
"pan_left": MotionRecommended.slow_pan,
|
||||||
|
"pan_right": MotionRecommended.slow_pan,
|
||||||
|
"tilt_up": MotionRecommended.slow_pan,
|
||||||
|
"tilt_down": MotionRecommended.slow_pan,
|
||||||
|
"push_diag": MotionRecommended.dolly,
|
||||||
|
"montage": MotionRecommended.static,
|
||||||
|
}
|
||||||
|
|
||||||
SCENE_TRACK = 1
|
SCENE_TRACK = 1
|
||||||
AUDIO_TRACK = 2
|
AUDIO_TRACK = 2
|
||||||
SUBTITLE_TRACK = 3
|
SUBTITLE_TRACK = 3
|
||||||
KEYWORD_TRACK = 4
|
KEYWORD_TRACK = 4
|
||||||
|
|
||||||
def select_template(orientation: OrientationType, industry: str | None = None) -> str:
|
def select_template(
|
||||||
|
orientation: OrientationType,
|
||||||
|
industry: str | None = None,
|
||||||
|
project_id: int | None = None,
|
||||||
|
) -> str:
|
||||||
"""orientation과 industry에 따라 Creatomate 템플릿 ID를 선택합니다.
|
"""orientation과 industry에 따라 Creatomate 템플릿 ID를 선택합니다.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
orientation: 영상 방향 ("horizontal" 또는 "vertical")
|
orientation: 영상 방향 ("horizontal" 또는 "vertical")
|
||||||
industry: 업종 분류 (stay|restaurant|cafe 등).
|
industry: 업종 분류 (stay|restaurant|cafe|attraction 등).
|
||||||
세로형에서만 사용되며, 매핑에 없으면 기본 템플릿으로 폴백합니다.
|
세로형에서 매핑에 있으면 전용 템플릿을 반환합니다.
|
||||||
|
project_id: 미매핑 업종(general 등)의 세로형 분배용 키.
|
||||||
|
project_id % len(VST_LIST)로 결정적으로 선택하므로, 같은
|
||||||
|
프로젝트는 몇 번 호출해도 동일 템플릿을 받아 사전/렌더 단계가
|
||||||
|
일치한다. 없으면 DEFAULT_VERTICAL_TEMPLATE로 폴백한다.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
선택된 템플릿 ID
|
선택된 템플릿 ID
|
||||||
@@ -263,10 +295,17 @@ def select_template(orientation: OrientationType, industry: str | None = None) -
|
|||||||
if orientation == "horizontal":
|
if orientation == "horizontal":
|
||||||
template_id = DHST0001
|
template_id = DHST0001
|
||||||
elif orientation == "vertical":
|
elif orientation == "vertical":
|
||||||
template_id = VERTICAL_INDUSTRY_TEMPLATE_MAP.get(industry, DEFAULT_VERTICAL_TEMPLATE)
|
mapped = VERTICAL_INDUSTRY_TEMPLATE_MAP.get(industry)
|
||||||
|
if mapped is not None:
|
||||||
|
template_id = mapped
|
||||||
|
elif project_id is not None:
|
||||||
|
# 미매핑 업종: project_id 나머지로 VST_LIST 결정적 분배 (공유 상태 없음)
|
||||||
|
template_id = VST_LIST[project_id % len(VST_LIST)]
|
||||||
|
else:
|
||||||
|
template_id = DEFAULT_VERTICAL_TEMPLATE
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
logger.info(f"[select_template] orientation={orientation}, industry={industry}, template_id={template_id}")
|
logger.info(f"[select_template] orientation={orientation}, industry={industry}, project_id={project_id}, template_id={template_id}")
|
||||||
return template_id
|
return template_id
|
||||||
|
|
||||||
async def get_shared_client() -> httpx.AsyncClient:
|
async def get_shared_client() -> httpx.AsyncClient:
|
||||||
@@ -317,20 +356,23 @@ class CreatomateService:
|
|||||||
api_key: str | None = None,
|
api_key: str | None = None,
|
||||||
orientation: OrientationType = "vertical",
|
orientation: OrientationType = "vertical",
|
||||||
industry: str | None = None,
|
industry: str | None = None,
|
||||||
|
project_id: int | None = None,
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Args:
|
Args:
|
||||||
api_key: Creatomate API 키 (Bearer token으로 사용)
|
api_key: Creatomate API 키 (Bearer token으로 사용)
|
||||||
None일 경우 config에서 자동으로 가져옴
|
None일 경우 config에서 자동으로 가져옴
|
||||||
orientation: 영상 방향 ("horizontal" 또는 "vertical", 기본값: "vertical")
|
orientation: 영상 방향 ("horizontal" 또는 "vertical", 기본값: "vertical")
|
||||||
industry: 업종 분류 (stay|restaurant|cafe 등). 세로형 템플릿 선택에 사용되며,
|
industry: 업종 분류 (stay|restaurant|cafe|attraction 등). 세로형 템플릿 선택에 사용되며,
|
||||||
매핑에 없거나 None이면 기본 세로형 템플릿으로 폴백
|
매핑에 있으면 전용 템플릿을 사용
|
||||||
|
project_id: 미매핑 업종(general 등)의 세로형 분배용 키. 매핑에 없을 때
|
||||||
|
project_id % len(VST_LIST)로 결정적 선택
|
||||||
"""
|
"""
|
||||||
self.api_key = api_key or apikey_settings.CREATOMATE_API_KEY
|
self.api_key = api_key or apikey_settings.CREATOMATE_API_KEY
|
||||||
self.orientation = orientation
|
self.orientation = orientation
|
||||||
|
|
||||||
# orientation·industry에 따른 템플릿 설정 가져오기
|
# orientation·industry에 따른 템플릿 설정 가져오기
|
||||||
self.template_id = select_template(orientation, industry=industry)
|
self.template_id = select_template(orientation, industry=industry, project_id=project_id)
|
||||||
self.headers = {
|
self.headers = {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
"Authorization": f"Bearer {self.api_key}",
|
"Authorization": f"Bearer {self.api_key}",
|
||||||
@@ -609,14 +651,20 @@ class CreatomateService:
|
|||||||
_NARR_BONUS = 1.5 # narrative 독립 보너스: base=0이어도 narrative 신호가 점수에 남음
|
_NARR_BONUS = 1.5 # narrative 독립 보너스: base=0이어도 narrative 신호가 점수에 남음
|
||||||
_NARR_MIN = 0.0 # narrative_preference 값 clamp 하한 (무경계 스키마 방어)
|
_NARR_MIN = 0.0 # narrative_preference 값 clamp 하한 (무경계 스키마 방어)
|
||||||
_NARR_MAX = 100.0 # narrative_preference 값 clamp 상한. NarrativePreference 스키마(0.0~100.0)와 스케일 일치
|
_NARR_MAX = 100.0 # narrative_preference 값 clamp 상한. NarrativePreference 스키마(0.0~100.0)와 스케일 일치
|
||||||
|
_SPACE_TYPE_MISMATCH_PENALTY = 0.1 # 슬롯이 요구하는 space_type과 다른 이미지에 적용하는 페널티 배수 (하드 필터에 가깝게)
|
||||||
|
|
||||||
def calculate_image_slot_score_multi(self, taged_image_list : list[dict], slot_name : str):
|
def calculate_image_slot_score_multi(self, taged_image_list : list[dict], slot_name : str):
|
||||||
"""이미지 슬롯에 대한 각 이미지의 매칭 점수를 계산합니다.
|
"""이미지 슬롯에 대한 각 이미지의 매칭 점수를 계산합니다.
|
||||||
|
|
||||||
점수 = base * narr_mod + NARR_BONUS * narr
|
점수 = (base * narr_mod + NARR_BONUS * narr) * space_type_penalty
|
||||||
- base: 태그 카테고리 매칭 합산 (최대 5.5)
|
- base: 태그 카테고리 매칭 합산 (최대 5.5)
|
||||||
- narr_mod: [NARR_FLOOR, 1.0] 구간으로 완화된 narrative 계수
|
- narr_mod: [NARR_FLOOR, 1.0] 구간으로 완화된 narrative 계수
|
||||||
- NARR_BONUS * narr: narrative 독립 보너스 (base=0이어도 신호 유지)
|
- NARR_BONUS * narr: narrative 독립 보너스 (base=0이어도 신호 유지)
|
||||||
|
- space_type_penalty: 슬롯이 요구하는 space_type과 이미지가 불일치하면
|
||||||
|
SPACE_TYPE_MISMATCH_PENALTY(0.1)를 곱해 사실상 탈락시킴. narrative_preference
|
||||||
|
점수가 아무리 높아도(예: bathroom 이미지가 intro narr=100) 슬롯이 지정한
|
||||||
|
space_type(예: exterior_front)과 다르면 우선 배정되지 않도록 하기 위함 —
|
||||||
|
같은 space_type 이미지가 pool에 하나도 없을 때만 상대적으로 선택됨(fallback 유지).
|
||||||
이 구조로 "base=0, narrative가 높음"과 "완전히 틀린 이미지(0,0)"를 구별할 수 있음.
|
이 구조로 "base=0, narrative가 높음"과 "완전히 틀린 이미지(0,0)"를 구별할 수 있음.
|
||||||
"""
|
"""
|
||||||
image_tag_list = [taged_image["image_tag"] for taged_image in taged_image_list]
|
image_tag_list = [taged_image["image_tag"] for taged_image in taged_image_list]
|
||||||
@@ -627,6 +675,11 @@ class CreatomateService:
|
|||||||
|
|
||||||
base_score_list = [0.0] * len(image_tag_list)
|
base_score_list = [0.0] * len(image_tag_list)
|
||||||
# slot_tag_narrative = NarrativePhase.accent # 기본값 (narrative 토큰 없는 슬롯 대비)
|
# slot_tag_narrative = NarrativePhase.accent # 기본값 (narrative 토큰 없는 슬롯 대비)
|
||||||
|
slot_space_type = slot_tag_dict.get("space_type")
|
||||||
|
space_type_match_list = [
|
||||||
|
slot_space_type is not None and slot_space_type.value in image_tag.get("space_type", [])
|
||||||
|
for image_tag in image_tag_list
|
||||||
|
]
|
||||||
|
|
||||||
for slot_tag_cate, slot_tag_item in slot_tag_dict.items():
|
for slot_tag_cate, slot_tag_item in slot_tag_dict.items():
|
||||||
if slot_tag_cate == "narrative_preference":
|
if slot_tag_cate == "narrative_preference":
|
||||||
@@ -659,6 +712,8 @@ class CreatomateService:
|
|||||||
narr = clamped_narr / self._NARR_MAX # 0.0~1.0로 정규화
|
narr = clamped_narr / self._NARR_MAX # 0.0~1.0로 정규화
|
||||||
narr_mod = self._NARR_FLOOR + (1.0 - self._NARR_FLOOR) * narr
|
narr_mod = self._NARR_FLOOR + (1.0 - self._NARR_FLOOR) * narr
|
||||||
score = base_score_list[idx] * narr_mod + self._NARR_BONUS * narr
|
score = base_score_list[idx] * narr_mod + self._NARR_BONUS * narr
|
||||||
|
if not space_type_match_list[idx]:
|
||||||
|
score *= self._SPACE_TYPE_MISMATCH_PENALTY
|
||||||
image_score_list.append(score)
|
image_score_list.append(score)
|
||||||
|
|
||||||
return image_score_list
|
return image_score_list
|
||||||
@@ -677,7 +732,8 @@ class CreatomateService:
|
|||||||
space_type = SpaceType(tag_list[0])
|
space_type = SpaceType(tag_list[0])
|
||||||
subject = Subject(tag_list[1])
|
subject = Subject(tag_list[1])
|
||||||
camera = Camera(tag_list[2])
|
camera = Camera(tag_list[2])
|
||||||
motion = MotionRecommended(tag_list[3])
|
# 모션 동의어(zoom_in, pan_left 등)는 표준 enum 값으로 정규화 후 변환
|
||||||
|
motion = MOTION_TOKEN_NORMALIZATION.get(tag_list[3]) or MotionRecommended(tag_list[3])
|
||||||
narrative = NarrativePhase(tag_list[4])
|
narrative = NarrativePhase(tag_list[4])
|
||||||
tag_dict = {
|
tag_dict = {
|
||||||
"space_type": space_type,
|
"space_type": space_type,
|
||||||
@@ -1094,7 +1150,7 @@ class CreatomateService:
|
|||||||
return pitching_list
|
return pitching_list
|
||||||
|
|
||||||
|
|
||||||
def make_thumbnail_modification(self, brand_name : str, region : str, brand_concept : str, category_definition : str, target_keywords : list[str]):
|
def make_thumbnail_modification(self, brand_name : str, region : str, category_definition : str, target_keywords : list[str]):
|
||||||
|
|
||||||
len_keywords = len(target_keywords) if len(target_keywords) < 3 else 3
|
len_keywords = len(target_keywords) if len(target_keywords) < 3 else 3
|
||||||
|
|
||||||
@@ -1102,9 +1158,8 @@ class CreatomateService:
|
|||||||
|
|
||||||
mod_dict = {
|
mod_dict = {
|
||||||
"thumb-hashtag-primary" : ' '.join(hashtaged_target_keywords),
|
"thumb-hashtag-primary" : ' '.join(hashtaged_target_keywords),
|
||||||
"thumb-brand-wordmark" : brand_name,
|
"thumb-headline-brand_name-factual" : brand_name,
|
||||||
"thumb-subheadline-selling_point" : f"{brand_name} · {normalize_location(region)}",
|
"thumb-subheadline-local_info-factual" : normalize_location(region),
|
||||||
"thumb-headline-hook_claim-aspirational" : brand_concept,
|
|
||||||
"thumb-badge-category" : category_definition,
|
"thumb-badge-category" : category_definition,
|
||||||
}
|
}
|
||||||
return mod_dict
|
return mod_dict
|
||||||
@@ -21,7 +21,7 @@ from app.utils.prompts.schemas import MarketingFilterOutput
|
|||||||
logger = get_logger("image_filter")
|
logger = get_logger("image_filter")
|
||||||
|
|
||||||
# 크롤링 단계 필터링에 사용할 Gemini 모델. 시트(prompts.py)와 달리 코드에 고정한다.
|
# 크롤링 단계 필터링에 사용할 Gemini 모델. 시트(prompts.py)와 달리 코드에 고정한다.
|
||||||
MARKETING_FILTER_MODEL = "gemini-3.5-flash"
|
MARKETING_FILTER_MODEL = "gpt-5-mini"
|
||||||
|
|
||||||
MAX_RETRY = 2
|
MAX_RETRY = 2
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ async def filter_marketing_images(image_url_list: list[str], industry: str = "")
|
|||||||
if not image_url_list:
|
if not image_url_list:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
chatgpt = ChatgptService(model_type="gemini")
|
chatgpt = ChatgptService(model_type="gpt")
|
||||||
prompt_text = _build_prompt(industry)
|
prompt_text = _build_prompt(industry)
|
||||||
|
|
||||||
async def _call(url: str):
|
async def _call(url: str):
|
||||||
|
|||||||
+55
-47
@@ -48,6 +48,30 @@ class NvMapPwScraper():
|
|||||||
]
|
]
|
||||||
_current_profile = None
|
_current_profile = None
|
||||||
|
|
||||||
|
# 헤드리스 자동화 탐지 신호(navigator.webdriver, 빈 plugins/languages, window.chrome 부재,
|
||||||
|
# permissions.query 이상 동작)를 정상 브라우저처럼 위장하는 스텔스 패치.
|
||||||
|
# create_page()와 fetch_graphql() 양쪽에서 생성하는 모든 page에 반드시 적용해야 한다 —
|
||||||
|
# 한쪽이라도 빠지면 그 경로만 헤드리스로 노출되어 안티봇 캡차 트리거 확률이 올라간다.
|
||||||
|
_STEALTH_INIT_SCRIPT = '''
|
||||||
|
Object.defineProperty(Navigator.prototype, "webdriver", {
|
||||||
|
set: undefined,
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true,
|
||||||
|
get: () => false,
|
||||||
|
});
|
||||||
|
Object.defineProperty(navigator, "plugins", { get: () => [1, 2, 3, 4, 5] });
|
||||||
|
Object.defineProperty(navigator, "languages", { get: () => ["ko-KR", "ko"] });
|
||||||
|
window.chrome = window.chrome || { runtime: {} };
|
||||||
|
const originalQuery = window.navigator.permissions && window.navigator.permissions.query;
|
||||||
|
if (originalQuery) {
|
||||||
|
window.navigator.permissions.query = (parameters) => (
|
||||||
|
parameters.name === "notifications"
|
||||||
|
? Promise.resolve({ state: Notification.permission })
|
||||||
|
: originalQuery(parameters)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
'''
|
||||||
|
|
||||||
# instance var
|
# instance var
|
||||||
page = None
|
page = None
|
||||||
|
|
||||||
@@ -89,6 +113,17 @@ class NvMapPwScraper():
|
|||||||
if old_context:
|
if old_context:
|
||||||
await old_context.close()
|
await old_context.close()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
async def _new_stealth_page(cls):
|
||||||
|
"""스텔스 패치(webdriver 위장 등)와 sec-ch-ua 헤더가 적용된 새 page를 생성한다."""
|
||||||
|
page = await cls._context.new_page()
|
||||||
|
await page.add_init_script(cls._STEALTH_INIT_SCRIPT)
|
||||||
|
if cls._current_profile:
|
||||||
|
await page.set_extra_http_headers({
|
||||||
|
'sec-ch-ua': cls._current_profile['sec_ch_ua']
|
||||||
|
})
|
||||||
|
return page
|
||||||
|
|
||||||
GRAPHQL_URL = "https://pcmap-api.place.naver.com/graphql"
|
GRAPHQL_URL = "https://pcmap-api.place.naver.com/graphql"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -116,7 +151,7 @@ class NvMapPwScraper():
|
|||||||
logger.warning("[NvMapPwScraper] fetch_graphql: scraper가 초기화되지 않았습니다")
|
logger.warning("[NvMapPwScraper] fetch_graphql: scraper가 초기화되지 않았습니다")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
page = await cls._context.new_page()
|
page = await cls._new_stealth_page()
|
||||||
captured: dict = {}
|
captured: dict = {}
|
||||||
|
|
||||||
def on_request(req):
|
def on_request(req):
|
||||||
@@ -205,35 +240,7 @@ class NvMapPwScraper():
|
|||||||
await self.page.close()
|
await self.page.close()
|
||||||
|
|
||||||
async def create_page(self):
|
async def create_page(self):
|
||||||
self.page = await self._context.new_page()
|
self.page = await self._new_stealth_page()
|
||||||
await self.page.add_init_script(
|
|
||||||
'''const defaultGetter = Object.getOwnPropertyDescriptor(
|
|
||||||
Navigator.prototype,
|
|
||||||
"webdriver"
|
|
||||||
).get;
|
|
||||||
defaultGetter.apply(navigator);
|
|
||||||
defaultGetter.toString();
|
|
||||||
Object.defineProperty(Navigator.prototype, "webdriver", {
|
|
||||||
set: undefined,
|
|
||||||
enumerable: true,
|
|
||||||
configurable: true,
|
|
||||||
get: new Proxy(defaultGetter, {
|
|
||||||
apply: (target, thisArg, args) => {
|
|
||||||
Reflect.apply(target, thisArg, args);
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
const patchedGetter = Object.getOwnPropertyDescriptor(
|
|
||||||
Navigator.prototype,
|
|
||||||
"webdriver"
|
|
||||||
).get;
|
|
||||||
patchedGetter.apply(navigator);
|
|
||||||
patchedGetter.toString();''')
|
|
||||||
|
|
||||||
await self.page.set_extra_http_headers({
|
|
||||||
'sec-ch-ua': self._current_profile['sec_ch_ua']
|
|
||||||
})
|
|
||||||
await self.page.goto("http://google.com")
|
await self.page.goto("http://google.com")
|
||||||
|
|
||||||
async def goto_url(self, url, wait_until="domcontentloaded", timeout=20000):
|
async def goto_url(self, url, wait_until="domcontentloaded", timeout=20000):
|
||||||
@@ -415,23 +422,24 @@ patchedGetter.toString();''')
|
|||||||
return best['place_url']
|
return best['place_url']
|
||||||
|
|
||||||
# 2순위(안전망): allSearch 캡처 실패 시 기존 iframe HTML 파싱 방식으로 폴백
|
# 2순위(안전망): allSearch 캡처 실패 시 기존 iframe HTML 파싱 방식으로 폴백
|
||||||
logger.warning("[FALLBACK] allSearch 캡처 실패 → iframe 파싱 방식 시도")
|
# ── 잠시 비활성화 ──
|
||||||
iframe_candidates = []
|
# logger.warning("[FALLBACK] allSearch 캡처 실패 → iframe 파싱 방식 시도")
|
||||||
for _ in range(3): # 500ms × 3 = 최대 1.5초
|
# iframe_candidates = []
|
||||||
if "/place/" in self.page.url:
|
# for _ in range(3): # 500ms × 3 = 최대 1.5초
|
||||||
return self.page.url
|
# if "/place/" in self.page.url:
|
||||||
iframe_candidates = await self._extract_candidates_from_list_page()
|
# return self.page.url
|
||||||
if iframe_candidates:
|
# iframe_candidates = await self._extract_candidates_from_list_page()
|
||||||
break
|
# if iframe_candidates:
|
||||||
await self.page.wait_for_timeout(500)
|
# break
|
||||||
|
# await self.page.wait_for_timeout(500)
|
||||||
if iframe_candidates:
|
#
|
||||||
best = self._select_best_candidate(iframe_candidates, title, address)
|
# if iframe_candidates:
|
||||||
logger.info(
|
# best = self._select_best_candidate(iframe_candidates, title, address)
|
||||||
f"[AUTO-SELECT-IFRAME] '{title}' → '{best['title']}' "
|
# logger.info(
|
||||||
f"(name={best['_name_score']:.2f}, addr={best['_addr_score']:.2f}) {best['place_url']}"
|
# f"[AUTO-SELECT-IFRAME] '{title}' → '{best['title']}' "
|
||||||
)
|
# f"(name={best['_name_score']:.2f}, addr={best['_addr_score']:.2f}) {best['place_url']}"
|
||||||
return best['place_url']
|
# )
|
||||||
|
# return best['place_url']
|
||||||
|
|
||||||
# isCorrectAnswer=true 로 강제 단일결과 재시도 (원본 로직 유지)
|
# isCorrectAnswer=true 로 강제 단일결과 재시도 (원본 로직 유지)
|
||||||
correct_url = self.page.url.replace("?", "?isCorrectAnswer=true&")
|
correct_url = self.page.url.replace("?", "?isCorrectAnswer=true&")
|
||||||
|
|||||||
+86
-12
@@ -36,7 +36,12 @@ class NvMapScraper:
|
|||||||
REQUEST_TIMEOUT = 120 # 초
|
REQUEST_TIMEOUT = 120 # 초
|
||||||
data_source_identifier = "nv"
|
data_source_identifier = "nv"
|
||||||
SUPPLEMENT_THRESHOLD = 30 # 업체 사진이 이 수 미만일 때 방문자 사진으로 보충
|
SUPPLEMENT_THRESHOLD = 30 # 업체 사진이 이 수 미만일 때 방문자 사진으로 보충
|
||||||
MAX_IMAGES = 50 # 업체+방문자 사진 합산 최대 장수
|
# 방문자 사진 보충 시의 합산 상한 (필터링·정책상 제한).
|
||||||
|
# 업체 제공 사진은 필터링 면제 대상이므로 이 상한과 무관하게 수집분을 전부 사용한다
|
||||||
|
# (수집 자체는 BIZ_MAX_PAGES가 상한 — 초과 시 warning 로그 발생).
|
||||||
|
MAX_IMAGES = 50
|
||||||
|
BIZ_PAGE_SIZE = 20 # getPhotoViewerItems 'biz' 커서의 페이지당 사진 수
|
||||||
|
BIZ_MAX_PAGES = 5 # 업체 사진 수집 상한 (5×20=100장, 도달 시 warning)
|
||||||
OVERVIEW_QUERY: str = """
|
OVERVIEW_QUERY: str = """
|
||||||
query getAccommodation($id: String!, $deviceType: String) {
|
query getAccommodation($id: String!, $deviceType: String) {
|
||||||
business: placeDetail(input: {id: $id, isNx: true, deviceType: $deviceType}) {
|
business: placeDetail(input: {id: $id, isNx: true, deviceType: $deviceType}) {
|
||||||
@@ -151,6 +156,42 @@ query getVisitorReviewStats($id: String!) {
|
|||||||
if p.get("originalUrl") and not NvMapScraper._is_gif_url(p["originalUrl"])
|
if p.get("originalUrl") and not NvMapScraper._is_gif_url(p["originalUrl"])
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _build_biz_payload(cls, place_id: str, page: int) -> dict:
|
||||||
|
"""'biz' 커서(업체 등록 사진)의 page번째(0-base) 페이지 요청 payload를 만든다."""
|
||||||
|
start_index = page * cls.BIZ_PAGE_SIZE
|
||||||
|
cursor: dict = {"id": "biz"}
|
||||||
|
if start_index > 0:
|
||||||
|
cursor.update({
|
||||||
|
"startIndex": start_index,
|
||||||
|
"hasNext": True,
|
||||||
|
"lastCursor": str(start_index),
|
||||||
|
})
|
||||||
|
return {
|
||||||
|
"operationName": "getPhotoViewerItems",
|
||||||
|
"variables": {
|
||||||
|
"input": {
|
||||||
|
"businessId": place_id,
|
||||||
|
"cursors": [cursor],
|
||||||
|
"dateRange": "",
|
||||||
|
"excludeAuthorIds": [],
|
||||||
|
"excludeClipIds": [],
|
||||||
|
"excludeSection": [],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"query": cls.PHOTO_VIEWER_QUERY,
|
||||||
|
}
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _raw_photo_count(photo_viewer_raw: dict | None) -> int:
|
||||||
|
"""getPhotoViewerItems 응답의 사진 수(gif 필터링 전 원본 기준)를 반환한다.
|
||||||
|
|
||||||
|
페이지네이션 계속 여부 판단용 — gif가 걸러진 뒤의 수로 판단하면
|
||||||
|
마지막 페이지가 아닌데도 조기 종료할 수 있어 원본 개수를 사용한다.
|
||||||
|
"""
|
||||||
|
photos = ((photo_viewer_raw or {}).get("data") or {}).get("photoViewer") or {}
|
||||||
|
return len(photos.get("photos") or [])
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _dedup_by_original(images: list[dict]) -> list[dict]:
|
def _dedup_by_original(images: list[dict]) -> list[dict]:
|
||||||
"""{"preview","original"} dict 리스트를 original URL 기준으로 순서를 유지한 채 중복 제거한다."""
|
"""{"preview","original"} dict 리스트를 original URL 기준으로 순서를 유지한 채 중복 제거한다."""
|
||||||
@@ -215,7 +256,7 @@ query getVisitorReviewStats($id: String!) {
|
|||||||
# self.scrap_type = "GraphQL-Browser"
|
# self.scrap_type = "GraphQL-Browser"
|
||||||
|
|
||||||
# ── 실제 브라우저로 WTM 캡차 우회 ──
|
# ── 실제 브라우저로 WTM 캡차 우회 ──
|
||||||
data, stats_data, extra_photo_urls = await self._scrap_via_browser(place_id)
|
data, stats_data, extra_photo_urls, biz_photo_urls = await self._scrap_via_browser(place_id)
|
||||||
# 편의시설은 HTML 페이지 파싱이라 GraphQL(WTM) 차단과 별개로 직접 시도 (best-effort, 실패 시 None)
|
# 편의시설은 HTML 페이지 파싱이라 GraphQL(WTM) 차단과 별개로 직접 시도 (best-effort, 실패 시 None)
|
||||||
fac_data = await self._get_facility_string(place_id)
|
fac_data = await self._get_facility_string(place_id)
|
||||||
self.scrap_type = "GraphQL-Browser"
|
self.scrap_type = "GraphQL-Browser"
|
||||||
@@ -226,8 +267,11 @@ query getVisitorReviewStats($id: String!) {
|
|||||||
self.rawdata["facilities"] = fac_data
|
self.rawdata["facilities"] = fac_data
|
||||||
business = data["data"]["business"]
|
business = data["data"]["business"]
|
||||||
|
|
||||||
# 업체 등록 이미지 (마케팅 적합성 필터 제외 대상 — 자체 dedup)
|
# 업체 등록 이미지 (마케팅 적합성 필터 제외 대상 — 자체 dedup).
|
||||||
self.owner_images = self._dedup_by_original(self._extract_origins(business.get("images") or {}))
|
# placeDetail.images가 대표 사진 일부만 반환하는 경우가 있어 biz 커서 결과를 병합한다.
|
||||||
|
self.owner_images = self._dedup_by_original(
|
||||||
|
self._extract_origins(business.get("images") or {}) + biz_photo_urls
|
||||||
|
)
|
||||||
|
|
||||||
# 방문자/AI View 보충 사진 (마케팅 적합성 필터 대상). owner에 이미 있는 원본은 제외.
|
# 방문자/AI View 보충 사진 (마케팅 적합성 필터 대상). owner에 이미 있는 원본은 제외.
|
||||||
owner_originals = {img["original"] for img in self.owner_images}
|
owner_originals = {img["original"] for img in self.owner_images}
|
||||||
@@ -238,16 +282,17 @@ query getVisitorReviewStats($id: String!) {
|
|||||||
# 업체 사진이 임계값 미만이면 내부/외부/리뷰 사진으로 보충
|
# 업체 사진이 임계값 미만이면 내부/외부/리뷰 사진으로 보충
|
||||||
# (필터링 없는 기본 조립. 마케팅 적합성 필터를 적용하려면 호출측에서
|
# (필터링 없는 기본 조립. 마케팅 적합성 필터를 적용하려면 호출측에서
|
||||||
# owner_images / extra_photo_urls를 직접 사용해 image_filter.assemble_images로 재조립할 것.)
|
# owner_images / extra_photo_urls를 직접 사용해 image_filter.assemble_images로 재조립할 것.)
|
||||||
|
# MAX_IMAGES 상한은 방문자 사진이 섞이는 보충 경로에만 적용하며(필터링·정책상 제한),
|
||||||
|
# 업체 제공 사진만으로 구성되는 경우는 수집분(최대 BIZ_MAX_PAGES 페이지)을 전부 사용한다.
|
||||||
if len(self.owner_images) < self.SUPPLEMENT_THRESHOLD:
|
if len(self.owner_images) < self.SUPPLEMENT_THRESHOLD:
|
||||||
combined = self._dedup_by_original(self.owner_images + self.extra_photo_urls)
|
combined = self._dedup_by_original(self.owner_images + self.extra_photo_urls)
|
||||||
logger.info(
|
logger.info(
|
||||||
f"[NvMapScraper] 업체 사진 {len(self.owner_images)}장 < {self.SUPPLEMENT_THRESHOLD}장 "
|
f"[NvMapScraper] 업체 사진 {len(self.owner_images)}장 < {self.SUPPLEMENT_THRESHOLD}장 "
|
||||||
f"→ 보충 사진 {len(self.extra_photo_urls)}장 추가 (합산 {len(combined)}장, 상한 {self.MAX_IMAGES}장)"
|
f"→ 보충 사진 {len(self.extra_photo_urls)}장 추가 (합산 {len(combined)}장, 상한 {self.MAX_IMAGES}장)"
|
||||||
)
|
)
|
||||||
else:
|
|
||||||
combined = self.owner_images
|
|
||||||
|
|
||||||
self.image_link_list = combined[: self.MAX_IMAGES]
|
self.image_link_list = combined[: self.MAX_IMAGES]
|
||||||
|
else:
|
||||||
|
self.image_link_list = list(self.owner_images)
|
||||||
self.base_info = data["data"]["business"]["base"]
|
self.base_info = data["data"]["business"]["base"]
|
||||||
self.facility_info = fac_data
|
self.facility_info = fac_data
|
||||||
self.voted_keyword_stats = stats_data
|
self.voted_keyword_stats = stats_data
|
||||||
@@ -255,11 +300,11 @@ query getVisitorReviewStats($id: String!) {
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
async def _scrap_via_browser(self, place_id: str) -> tuple[dict, list[dict] | None, list[str]]:
|
async def _scrap_via_browser(self, place_id: str) -> tuple[dict, list[dict] | None, list[dict], list[dict]]:
|
||||||
"""직접 호출이 WTM 캡차에 막힌 경우, 실제 브라우저로 GraphQL을 호출한다.
|
"""직접 호출이 WTM 캡차에 막힌 경우, 실제 브라우저로 GraphQL을 호출한다.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
(overview_data, review_stats_details, extra_photo_urls)
|
(overview_data, review_stats_details, extra_photo_urls, biz_photo_urls)
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
GraphQLException: 브라우저 폴백마저 실패한 경우
|
GraphQLException: 브라우저 폴백마저 실패한 경우
|
||||||
@@ -322,8 +367,19 @@ query getVisitorReviewStats($id: String!) {
|
|||||||
},
|
},
|
||||||
"query": self.PHOTO_VIEWER_QUERY,
|
"query": self.PHOTO_VIEWER_QUERY,
|
||||||
}
|
}
|
||||||
|
# 업체 등록 사진. placeDetail.images는 대표 사진 일부(1~수 장)만 반환하는
|
||||||
|
# 경우가 있어, 사진 탭이 실제 사용하는 'biz' 커서로 별도 조회해 보강한다.
|
||||||
|
# biz 커서는 페이지당 BIZ_PAGE_SIZE(20)장이며 lastCursor가 단순 인덱스 문자열
|
||||||
|
# ("20", "40")이라 이전 응답 없이도 모든 페이지를 미리 만들 수 있고, 범위를
|
||||||
|
# 벗어난 페이지는 빈 목록을 반환하므로 블라인드 요청해도 안전하다.
|
||||||
|
# 따라서 상한(BIZ_MAX_PAGES)까지의 전 페이지를 첫 배치에 한꺼번에 실어 보낸다
|
||||||
|
# — 추가 왕복(페이지 재탐색 + WTM 토큰 재캡처)이 없고, 개별 페이지 실패가
|
||||||
|
# 이후 페이지 수집을 막지 못한다.
|
||||||
|
biz_payloads = [
|
||||||
|
self._build_biz_payload(place_id, page) for page in range(self.BIZ_MAX_PAGES)
|
||||||
|
]
|
||||||
|
|
||||||
payloads = [overview_payload, stats_payload, interior_payload, exterior_payload, review_payload]
|
payloads = [overview_payload, stats_payload, interior_payload, exterior_payload, review_payload, *biz_payloads]
|
||||||
MAX_RETRY = 3
|
MAX_RETRY = 3
|
||||||
results = None
|
results = None
|
||||||
last_error: Exception | None = None
|
last_error: Exception | None = None
|
||||||
@@ -360,13 +416,31 @@ query getVisitorReviewStats($id: String!) {
|
|||||||
interior_urls = self._extract_photo_viewer_urls(results[2] if len(results) > 2 else None)
|
interior_urls = self._extract_photo_viewer_urls(results[2] if len(results) > 2 else None)
|
||||||
exterior_urls = self._extract_photo_viewer_urls(results[3] if len(results) > 3 else None)
|
exterior_urls = self._extract_photo_viewer_urls(results[3] if len(results) > 3 else None)
|
||||||
review_urls = self._extract_photo_viewer_urls(results[4] if len(results) > 4 else None)
|
review_urls = self._extract_photo_viewer_urls(results[4] if len(results) > 4 else None)
|
||||||
|
|
||||||
|
biz_pages = results[5:]
|
||||||
|
biz_urls = [url for page_result in biz_pages for url in self._extract_photo_viewer_urls(page_result)]
|
||||||
|
# 개별 페이지 실패(None)는 해당 20장만 누락되고 나머지 페이지는 영향 없다 (best-effort).
|
||||||
|
failed_biz_pages = sum(1 for r in biz_pages if r is None)
|
||||||
|
if failed_biz_pages:
|
||||||
|
logger.warning(
|
||||||
|
f"[NvMapScraper] 업체 사진 {failed_biz_pages}개 페이지 응답 실패 "
|
||||||
|
f"— 페이지당 최대 {self.BIZ_PAGE_SIZE}장 누락 가능 (수집분으로 진행)"
|
||||||
|
)
|
||||||
|
# 마지막 페이지까지 가득 차 있으면 상한 밖에 사진이 더 있을 수 있다.
|
||||||
|
if biz_pages and self._raw_photo_count(biz_pages[-1]) >= self.BIZ_PAGE_SIZE:
|
||||||
|
logger.warning(
|
||||||
|
f"[NvMapScraper] 업체 사진이 수집 상한(BIZ_MAX_PAGES={self.BIZ_MAX_PAGES}, "
|
||||||
|
f"{self.BIZ_MAX_PAGES * self.BIZ_PAGE_SIZE}장)까지 가득 참 — 초과분은 수집되지 않음"
|
||||||
|
)
|
||||||
|
|
||||||
extra_photo_urls = self._interleave(interior_urls, exterior_urls) + review_urls
|
extra_photo_urls = self._interleave(interior_urls, exterior_urls) + review_urls
|
||||||
logger.info(
|
logger.info(
|
||||||
f"[NvMapScraper] 보충 이미지 - 내부:{len(interior_urls)} 외부:{len(exterior_urls)} 리뷰:{len(review_urls)}"
|
f"[NvMapScraper] 보충 이미지 - 내부:{len(interior_urls)} 외부:{len(exterior_urls)} "
|
||||||
|
f"리뷰:{len(review_urls)} / 업체(biz):{len(biz_urls)}"
|
||||||
)
|
)
|
||||||
|
|
||||||
logger.info(f"[NvMapScraper] 브라우저 폴백 SUCCESS - place_id: {place_id}")
|
logger.info(f"[NvMapScraper] 브라우저 폴백 SUCCESS - place_id: {place_id}")
|
||||||
return data, stats_data, extra_photo_urls
|
return data, stats_data, extra_photo_urls, biz_urls
|
||||||
|
|
||||||
async def _call_get_accommodation(self, place_id: str) -> dict:
|
async def _call_get_accommodation(self, place_id: str) -> dict:
|
||||||
"""GraphQL API를 호출하여 숙소 정보를 가져옵니다.
|
"""GraphQL API를 호출하여 숙소 정보를 가져옵니다.
|
||||||
|
|||||||
@@ -42,6 +42,61 @@ class SpaceType(StrEnum):
|
|||||||
detail_lighting = auto()
|
detail_lighting = auto()
|
||||||
detail_decor = auto()
|
detail_decor = auto()
|
||||||
detail_tableware = auto()
|
detail_tableware = auto()
|
||||||
|
# 레스토랑(DVRT0001) 템플릿 어휘
|
||||||
|
dining_hall = auto()
|
||||||
|
table_setting = auto()
|
||||||
|
private_room = auto()
|
||||||
|
detail_cooking = auto()
|
||||||
|
detail_plating = auto()
|
||||||
|
detail_menu = auto()
|
||||||
|
detail_dish_main = auto()
|
||||||
|
detail_dish_side = auto()
|
||||||
|
brand_summary = auto()
|
||||||
|
# 카페(DVCF0001) 템플릿 어휘
|
||||||
|
hall = auto()
|
||||||
|
counter_bar = auto()
|
||||||
|
seating_window = auto()
|
||||||
|
seating_lounge = auto()
|
||||||
|
signage = auto()
|
||||||
|
detail_dessert = auto()
|
||||||
|
detail_signature_drink = auto()
|
||||||
|
# 관광지(DVAT0001) 템플릿 어휘
|
||||||
|
entrance_gate = auto()
|
||||||
|
exhibition_hall = auto()
|
||||||
|
landmark_main = auto()
|
||||||
|
landmark_detail = auto()
|
||||||
|
night_view = auto()
|
||||||
|
panorama_view = auto()
|
||||||
|
photo_spot = auto()
|
||||||
|
seasonal_scene = auto()
|
||||||
|
walking_path = auto()
|
||||||
|
# 미용실(DVSL0001) 템플릿 어휘
|
||||||
|
mirror_detail = auto()
|
||||||
|
styling_zone = auto()
|
||||||
|
waiting_lounge = auto()
|
||||||
|
# 병원(DVCL0001) 템플릿 어휘
|
||||||
|
consultation_room = auto()
|
||||||
|
detail_amenity = auto()
|
||||||
|
equipment_zone = auto()
|
||||||
|
recovery_room = auto()
|
||||||
|
treatment_room = auto()
|
||||||
|
waiting_area = auto()
|
||||||
|
# 피트니스(DVFT0001) 템플릿 어휘
|
||||||
|
apparatus_zone = auto()
|
||||||
|
brand_sign = auto()
|
||||||
|
detail_equipment = auto()
|
||||||
|
locker_room = auto()
|
||||||
|
powder_room = auto()
|
||||||
|
pt_zone = auto()
|
||||||
|
reformer_zone = auto()
|
||||||
|
# 학원(DVAC0001) 템플릿 어휘
|
||||||
|
classroom = auto()
|
||||||
|
counseling_room = auto()
|
||||||
|
detail_facility = auto()
|
||||||
|
detail_interior_prop = auto()
|
||||||
|
detail_materials = auto()
|
||||||
|
library_corner = auto()
|
||||||
|
study_room = auto()
|
||||||
|
|
||||||
class Subject(StrEnum):
|
class Subject(StrEnum):
|
||||||
"""이미지 내 주요 피사체 유형. 화면에 무엇이 담겨 있는지를 분류하는 태그."""
|
"""이미지 내 주요 피사체 유형. 화면에 무엇이 담겨 있는지를 분류하는 태그."""
|
||||||
@@ -55,6 +110,28 @@ class Subject(StrEnum):
|
|||||||
signage = auto()
|
signage = auto()
|
||||||
amenity_item = auto()
|
amenity_item = auto()
|
||||||
person = auto()
|
person = auto()
|
||||||
|
# 레스토랑(DVRT0001) 템플릿 어휘
|
||||||
|
cooking_action = auto()
|
||||||
|
menu_board = auto()
|
||||||
|
triptych = auto()
|
||||||
|
# 카페(DVCF0001) 템플릿 어휘
|
||||||
|
beverage = auto()
|
||||||
|
brewing_action = auto()
|
||||||
|
dessert = auto()
|
||||||
|
# 관광지(DVAT0001) 템플릿 어휘
|
||||||
|
scenery = auto()
|
||||||
|
structure = auto()
|
||||||
|
# 병원(DVCL0001) 템플릿 어휘
|
||||||
|
interior_clean = auto()
|
||||||
|
medical_equipment = auto()
|
||||||
|
# 피트니스(DVFT0001) 템플릿 어휘
|
||||||
|
interior_scale = auto()
|
||||||
|
pilates_apparatus = auto()
|
||||||
|
training_action = auto()
|
||||||
|
# 학원(DVAC0001) 템플릿 어휘
|
||||||
|
facility_equipment = auto()
|
||||||
|
learning_material = auto()
|
||||||
|
study_scene = auto()
|
||||||
|
|
||||||
class Camera(StrEnum):
|
class Camera(StrEnum):
|
||||||
"""이미지의 촬영 기법·구도·조명 특성. 영상 편집 시 컷의 시각적 스타일을 구분하는 태그."""
|
"""이미지의 촬영 기법·구도·조명 특성. 영상 편집 시 컷의 시각적 스타일을 구분하는 태그."""
|
||||||
|
|||||||
@@ -221,11 +221,6 @@ async def generate_video(
|
|||||||
category_definition = marketing_intelligence.intel_result["market_positioning"]["category_definition"]
|
category_definition = marketing_intelligence.intel_result["market_positioning"]["category_definition"]
|
||||||
target_keywords = marketing_intelligence.intel_result["target_keywords"]
|
target_keywords = marketing_intelligence.intel_result["target_keywords"]
|
||||||
|
|
||||||
brand_concept = ""
|
|
||||||
for sp in marketing_intelligence.intel_result["selling_points"]:
|
|
||||||
if "concept" in sp["english_category"].lower():
|
|
||||||
brand_concept = sp["description"]
|
|
||||||
|
|
||||||
# Lyric 조회
|
# Lyric 조회
|
||||||
lyric_result = await session.execute(
|
lyric_result = await session.execute(
|
||||||
select(Lyric)
|
select(Lyric)
|
||||||
@@ -391,7 +386,6 @@ async def generate_video(
|
|||||||
thumbnail_modifications = creatomate_service.make_thumbnail_modification(
|
thumbnail_modifications = creatomate_service.make_thumbnail_modification(
|
||||||
brand_name =brand_name,
|
brand_name =brand_name,
|
||||||
region = region,
|
region = region,
|
||||||
brand_concept = brand_concept,
|
|
||||||
category_definition= category_definition,
|
category_definition= category_definition,
|
||||||
target_keywords=target_keywords)
|
target_keywords=target_keywords)
|
||||||
|
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ async def generate_creative_assets_background(
|
|||||||
)
|
)
|
||||||
marketing_intelligence = marketing_result.scalar_one_or_none()
|
marketing_intelligence = marketing_result.scalar_one_or_none()
|
||||||
|
|
||||||
creatomate_service = CreatomateService(orientation=orientation, industry=project.industry)
|
creatomate_service = CreatomateService(orientation=orientation, industry=project.industry, project_id=project.id)
|
||||||
template = await creatomate_service.get_one_template_data(creatomate_service.template_id)
|
template = await creatomate_service.get_one_template_data(creatomate_service.template_id)
|
||||||
|
|
||||||
store_address = project.detail_region_info
|
store_address = project.detail_region_info
|
||||||
|
|||||||
Reference in new issue
Block a user