fix: 방문자 리뷰 본문 없을 때 블로그 리뷰로 보충

This commit is contained in:
skkim committed 2026-09-07 13:42:00 +09:00
1 parent b3385e7df2
commit 3cddd17eed
5 files changed
+159 -38

No files matched your search

+24 -17
View File
@@ -1,10 +1,10 @@
# -*- coding: utf-8 -*-
"""
키워드 → 병맛 오디세이 마케팅 쇼츠 (완전 자동, 원커맨드)
키워드 → 병맛 그리스 로마 신화 마케팅 쇼츠 (완전 자동, 원커맨드)
==========================================================
마케팅하고 싶은 대상을 '자유로운 키워드/문장'으로 주면:
1) 랜덤으로 오디세우스 귀향 모험 '썰' 매칭
1) 랜덤으로 그리스 로마 신화 신·영웅 '썰' 매칭
2) Gemini 로 병맛 마케팅 나레이션 생성
3) 장면 분할(스토리보드)
4) 장면별 이미지 + 음성 생성
@@ -12,17 +12,17 @@
6) 한 작업의 결과(나레이션·스토리보드·이미지·음성·mp4)는
모두 output/<작업폴더>/ 안에만 저장. 완성 후 중간 파일(assets)은 자동 삭제.
선행: scraper.py 로 만든 data/odyssey_keywords_*.csv 가 있어야 함.
선행: scraper.py 로 만든 data/greek_keywords_*.csv 가 있어야 함.
API 키: GEMINI_API_KEY 환경변수 (또는 --api-key). 이미지 생성은 결제 활성화 필요.
★ 실행 (shorts_all 폴더 안에서, 키워드는 자유롭게):
python animation_odyssey\\main.py 감성 펜션 왕의휴식 객실 노천탕 평창 숲속 1박 12만원
python animation_odyssey\\main.py "강원도 평창 '왕의휴식' 감성 펜션, 객실 노천탕, 1박 12만원"
python animation_odyssey\\main.py https://naver.me/xxxx
python animation_greekroman\\main.py 감성 펜션 왕의휴식 객실 노천탕 평창 숲속 1박 12만원
python animation_greekroman\\main.py "강원도 평창 '왕의휴식' 감성 펜션, 객실 노천탕, 1박 12만원"
python animation_greekroman\\main.py https://naver.me/xxxx
옵션:
--label 왕의휴식 결과 폴더 이름에 쓸 라벨 (기본: 키워드 앞부분 자동)
--king 오디세우스 특정 인물 고정 (기본: 랜덤)
--king 제우스 특정 신/영웅 고정 (기본: 랜덤)
--scenes 12 장면 수=이미지 수 (기본 12)
--seconds 45 목표 길이 초 (기본 45)
--voice Puck TTS 목소리
@@ -51,7 +51,7 @@ import render as MS # animation 영상합성 엔진(이전 make_sho
import naver as NV # 공유 네이버 크롤러/브리핑/사진 선별
HERE = Path(__file__).parent
OUT_DIR = HERE.parent / "output" / "animation_odyssey" # 통합 출력: shorts_all/output/animation_odyssey/
OUT_DIR = HERE.parent / "output" / "animation_greekroman" # 통합 출력: shorts_all/output/animation_greekroman/
TEXT_MODEL = "gemini-2.5-flash"
@@ -62,7 +62,7 @@ def safe_name(s: str) -> str:
def main():
ap = argparse.ArgumentParser(
description="키워드 또는 네이버 링크 → 병맛 오디세이 쇼츠 (완전 자동)",
description="키워드 또는 네이버 링크 → 병맛 그리스 로마 신화 쇼츠 (완전 자동)",
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog="예) python main.py 감성 펜션 왕의휴식 객실 노천탕 1박 12만원\n"
" python main.py https://naver.me/xxxx (링크만 — AI브리핑 자동 키워드화)",
@@ -73,7 +73,7 @@ def main():
# 결과 폴더 라벨
ap.add_argument("--label", help="결과 폴더 라벨 (기본: 키워드 앞부분 자동)")
# 생성 옵션
ap.add_argument("--king", help="특정 인물 고정 (예: 오디세우스, 기본: 랜덤)")
ap.add_argument("--king", help="특정 신/영웅 고정 (예: 제우스, 기본: 랜덤)")
ap.add_argument("--scenes", type=int, default=12, help="장면 수=이미지 수 (기본 12)")
ap.add_argument("--seconds", type=int, default=45, help="목표 길이(초) (기본 45)")
ap.add_argument("--voice", default=MS.TTS_VOICE, help=f"TTS 목소리 (기본 {MS.TTS_VOICE})")
@@ -145,14 +145,21 @@ def main():
try:
rstore, reviews = NV.fetch_reviews(args.link, max_reviews=30)
except Exception as e:
sys.exit(f"[!] 리뷰 수집 실패: {type(e).__name__}: {e}")
# 리뷰 수집 실패로 생성 전체를 죽이지 않는다 — 가게명만으로라도 계속 간다.
print(f"[!] 리뷰 수집 실패(수집된 정보만으로 계속): {type(e).__name__}: {e}")
rstore, reviews = None, []
if rstore and not brief_store:
brief_store = rstore
bullets = NV.summarize_reviews(genai.Client(api_key=_key), brief_store, reviews)
if not bullets:
sys.exit(f"[!] '{brief_store or '이 가게'}'는 AI 브리핑도 리뷰도 못 얻었어요. "
"키워드를 직접 주거나 다른 링크를 쓰세요.")
print(f"■ 리뷰 {len(reviews)}개 수집 → 요약 {len(bullets)}줄 (브리핑 대체)")
bullets = (NV.summarize_reviews(genai.Client(api_key=_key), brief_store, reviews)
if reviews else [])
if bullets:
print(f"■ 리뷰 {len(reviews)}개 수집 → 요약 {len(bullets)}줄 (브리핑 대체)")
elif brief_store:
# 브리핑·방문자 리뷰·블로그 리뷰 모두 부실 — 에러로 끝내지 않고
# 그때까지 수집된 정보(가게명)만으로 생성을 계속한다.
print(f"■ 소재 부족 → 수집된 정보(가게명 '{brief_store}')만으로 생성 진행")
bullets = [brief_store]
# 가게명조차 없으면 bullets 가 비어 아래 product 가드에서 종료된다.
product = " ".join(bullets)
print(f"■ 가게: {brief_store or '?'} / 소재 {len(bullets)}줄 → 키워드로 사용")
for b in bullets:
@@ -207,7 +214,7 @@ def main():
print(f"■ 마케팅 대상 : {product}")
print(f"■ 매칭된 썰 : {seed['king']} / \"{seed['keyword']}\"\n")
# 2) 병맛 나레이션 (+ SNS 업로드용 캡션)
# 2) 병맛 나레이션
print("[1/4] 나레이션 생성...")
store_name = brief_store or getattr(args, "store", None) or label
narr = gen.generate(client, TEXT_MODEL, seed, product, args.seconds, store=store_name)