fix: 팝가 축제 중 극장·홀 공연과 연극·뮤지컬은 공연으로

This commit is contained in:
minaChoi committed 2026-10-08 13:25:47 +09:00
1 parent f1a46ea4a2
commit 78aad46946
2 files changed
+19 -2

No files matched your search

+14 -2
View File
@@ -17,6 +17,15 @@ SOURCE_PREFIX = "popga:"
_KINDS = {"STORE": EventKind.POPUP, "FESTIVAL": EventKind.FESTIVAL}
REQUEST_GAP_SEC = 0.3
# 팝가 '축제' 중 연극제·음악제의 공연 한 편. 극장·홀에서 하거나 이름이 공연이면 공연으로 넣는다
_SHOW_PLACE = ("극장", "홀", "아트센터", "예술의전당", "씨어터", "시어터", "문화회관", "공연장")
_SHOW_NAME = ("연극", "뮤지컬", "오페라", "독주회", "리사이틀", "콘서트")
def is_show(name: str, place: str) -> bool:
return any(w in place for w in _SHOW_PLACE) or any(w in name for w in _SHOW_NAME)
_LOC = re.compile(r"<loc>\s*([^<\s]+)\s*</loc>")
_URL = re.compile(r"<url>(.*?)</url>", re.S)
_LASTMOD = re.compile(r"<lastmod>\s*([^<\s]+)\s*</lastmod>")
@@ -101,9 +110,12 @@ def parse_popup(page: str, popup_id: int, since: date) -> Optional[dict]:
if sido is None:
return None
geo = loc.get("geo") or {}
name, place = html.unescape(ld.get("name") or ""), html.unescape(loc.get("name") or "")
if kind is EventKind.FESTIVAL and is_show(name, place):
kind = EventKind.CONCERT
return {
"source_id": f"{SOURCE_PREFIX}{popup_id}", "sido_code": sido, "name": html.unescape(ld.get("name") or "")[:60],
"place_name": html.unescape(loc.get("name") or "")[:60], "start_date": start, "end_date": end, "is_confirmed": True,
"source_id": f"{SOURCE_PREFIX}{popup_id}", "sido_code": sido, "name": name[:60],
"place_name": place[:60], "start_date": start, "end_date": end, "is_confirmed": True,
"source_url": POPUP_URL.format(id=popup_id), "image_url": None,
"lat": _coord(geo.get("latitude")), "lon": _coord(geo.get("longitude")), "kind": kind, "icon": EVENT_ICON[kind],
}
+5
View File
@@ -33,6 +33,11 @@ def test_parse_popup_maps_festival():
assert (row["kind"], row["icon"], row["sido_code"]) == (EventKind.FESTIVAL, "fireworks", "41")
def test_parse_popup_moves_festival_shows_in_theaters_to_concert():
page = _page(505, "FESTIVAL", "2026-10-02", "2026-10-11").replace("테스트 빌딩 1F", "대학로예술극장 소극장")
assert parse_popup(page, 505, date(2026, 10, 1))["kind"] is EventKind.CONCERT
@pytest.mark.parametrize("kind,end,address", [
("PERFORMANCE", "2026-10-11", "서울 성동구 테스트로 1"),
("STORE", "2026-09-30", "서울 성동구 테스트로 1"),