Skip to content

Commit ec4842c

Browse files
feat(marketing): zipscope 월요일 동적 시장데이터 포스트 (라이브 전세가율 TOP3)
고정 콘텐츠 풀과 달리 매주 신선한 데이터로 무한 콘텐츠 생성. market-rank API 티저(공개 3행)를 재사용 — 실패 시 기존 풀로 폴백. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 13db8d6 commit ec4842c

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

marketing/shared/multi_site_orchestrator.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,36 @@ def pick_site_for_today(force: str | None = None) -> Site:
188188
DISABLED_CHANNELS = {"lemmy"}
189189

190190

191+
def _zipscope_weekly_data_post() -> dict | None:
192+
"""월요일 전용: ZipScope 라이브 API에서 신선한 시장 데이터 포스트 생성.
193+
고정 풀과 달리 데이터가 매주 갱신되므로 반복 없이 무한 콘텐츠."""
194+
import urllib.request
195+
try:
196+
base = "https://tarofortune.pythonanywhere.com/analyze"
197+
mr = json.loads(urllib.request.urlopen(f"{base}/api/market-rank?metric=jeonse&n=3", timeout=20).read())
198+
top = mr.get("top") or []
199+
if len(top) < 3:
200+
return None
201+
rows = " · ".join(f"{t['sigungu']} {t['value']}%" for t in top[:3])
202+
body = (f"📊 이번 주 전국 전세가율 TOP3\n{rows}\n\n"
203+
f"전세가율 100% 초과는 전세가가 매매가보다 높은 '역전세' 위험 신호입니다. "
204+
f"전국 {mr.get('total', 200)}개 시군구 랭킹·단지별 전세가율은 지도에서 확인:\n"
205+
f"{base}/?ref=mastodon&utm_source=mastodon&utm_medium=social&utm_campaign=weekly-data")
206+
return {"lang": "kr", "title": "이번 주 전국 전세가율 TOP3", "body": body,
207+
"tags": ["부동산", "전세가율", "역전세", "아파트"]}
208+
except Exception as e:
209+
print("[weekly-data] 생성 실패:", repr(e)[:60])
210+
return None
211+
212+
191213
def pick_post(site: Site, channel: str) -> dict | None:
192214
"""사이트 + 채널에 맞는 콘텐츠 선택. state 파일로 중복 방지."""
215+
# 월요일 × zipscope × Mastodon → 고정 풀 대신 라이브 시장 데이터 포스트
216+
if site.key == "zipscope" and channel == "mastodon" and datetime.now().weekday() == 0:
217+
dyn = _zipscope_weekly_data_post()
218+
if dyn:
219+
print("[mastodon · zipscope] 주간 데이터 포스트(동적) 사용")
220+
return dyn
193221
pool = _load_post_pool(site.key)
194222
state_path = Path(__file__).parent / "state" / f"{site.key}_{channel}.json"
195223
state_path.parent.mkdir(parents=True, exist_ok=True)

0 commit comments

Comments
 (0)