fix: 서울문화포털 축제 이름 앞 [주최 기관] 떼기

This commit is contained in:
minaChoi committed 2026-10-08 13:08:09 +09:00
1 parent b4fcb313c7
commit f1a46ea4a2
2 files changed
+5 -1

No files matched your search

+4 -1
View File
@@ -1,5 +1,6 @@
import asyncio
import html
import re
from datetime import date, timedelta
from typing import Optional
@@ -16,6 +17,8 @@ SOURCE_PREFIX = "seoul:"
SEOUL = "11"
REQUEST_GAP_SEC = 0.3
_MAX_PAGES = 30
# 이름 앞 주최 기관 "[서울시청] ", "[마포문화재단] " 은 카드 제목에서 뗀다
_HOST_PREFIX = re.compile(r"^(\s*\[[^\]]*\]\s*)+")
async def fetch_seoul_festivals(client: httpx.AsyncClient, since: date, days: int) -> list[dict]:
@@ -51,7 +54,7 @@ def parse_seoul_festivals(items: list[dict]) -> list[dict]:
rows = []
for it in items:
start, end = _date(it.get("strtdate")), _date(it.get("endDate"))
name = html.unescape(it.get("title") or "").strip()
name = _HOST_PREFIX.sub("", html.unescape(it.get("title") or "")).strip()
if start is None or end is None or not name or it.get("cultcode") is None:
continue
rows.append({