feat(mls): MLS 리그 추가 — ESPN 비공식 API 연동

- 일정·결과·컨퍼런스 순위·프리뷰(폼/시즌전적/맞대결/머니라인) 수집
- 라이브 카드: 스코어·경기시간·득점/카드·선발 라인업(피치 뷰)·교체 현황
- 문자중계: ESPN commentary 규칙 기반 한글 변환 (미지원 템플릿은 팀명만 한글화)
- MLS 레코드는 야구와 키 구조가 같아 sync_baseball_schedule/settle 재사용
- AI 예측 데이터 블록에 MLS 전용 컨텍스트 추가

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
JinwooKimandClaude Opus 5 committed 2026-08-14 13:47:13 +09:00
1 parent ad5bbec82e
commit 74de57fc1c
22 files changed
+1723 -83

No files matched your search

+87 -8
View File
@@ -1,7 +1,8 @@
import type { Match } from "@/lib/types";
import type { Match, TeamStanding } from "@/lib/types";
import { kickoffDisplay } from "@/lib/format";
import { type Lang, dict, teamShort, roundLabel as tRound } from "@/lib/i18n";
import BallIcon from "./BallIcon";
import { FormBadges } from "./ScheduleBoard";
import TeamFlag from "./TeamFlag";
import WaveStrip from "./WaveStrip";
@@ -17,13 +18,36 @@ function standingLine(
return `${rank} · ${rec}${st.wra ? ` (${st.wra})` : ""}`;
}
// MLS 순위 캐시 → "동부 3위 · 8승2무4패 (승점 26)" 한 줄
function mlsStandingLine(st: TeamStanding & { div?: string | null } | null | undefined, lang: Lang): string | null {
if (!st?.rank) return null;
const conf =
st.div === "EAST"
? lang === "en" ? "East" : "동부"
: st.div === "WEST"
? lang === "en" ? "West" : "서부"
: "";
const rank = lang === "en" ? `#${st.rank}` : `${st.rank}위`;
const rec =
st.w != null && st.l != null
? lang === "en"
? ` · ${st.w}W-${st.d ?? 0}D-${st.l}L`
: ` · ${st.w}승${st.d ?? 0}무${st.l}패`
: "";
const pts = st.pts != null ? (lang === "en" ? ` (${st.pts}pts)` : ` (승점 ${st.pts})`) : "";
return `${conf} ${rank}${rec}${pts}`.trim();
}
export default function MatchupHUD({ match, lang = "ko" }: { match: Match; lang?: Lang }) {
const t = dict(lang);
const { group } = match;
const finished = !!match.result;
const isBaseball = match.league === "kbo" || match.league === "mlb";
// 축구: 한국을 항상 왼쪽에. 야구: A=원정(좌), B=홈(우) 고정.
const flip = !isBaseball && match.teamB.code === "KOR" && match.teamA.code !== "KOR";
const isMls = match.league === "mls";
const isClub = isBaseball || isMls; // 클럽 리그 공통 분기 (로고·venue 등)
// 월드컵: 한국을 항상 왼쪽에. 야구: 원정-홈. MLS: 홈-원정 (축구 관례 — 화면만 교체).
const flip =
isMls || (!isClub && match.teamB.code === "KOR" && match.teamA.code !== "KOR");
const left = flip ? match.teamB : match.teamA;
const right = flip ? match.teamA : match.teamB;
const leftScore = flip ? match.result?.scoreB : match.result?.scoreA;
@@ -36,7 +60,11 @@ export default function MatchupHUD({ match, lang = "ko" }: { match: Match; lang?
const stR = standingLine(ex?.standings?.b, lang);
const vs = ex?.seasonVs;
const hasVs = !!vs && vs.aWin != null && vs.bWin != null;
const flagCls = isBaseball ? "mx-auto h-[72px] w-[72px]" : "mx-auto h-[68px] w-[104px]";
// MLS 프리뷰 (폼·시즌 전적·순위·맞대결) — 왼쪽=홈(teamB) 기준으로 교체
const mlsStL = mlsStandingLine(ex?.standings?.b, lang);
const mlsStR = mlsStandingLine(ex?.standings?.a, lang);
const h2h = ex?.h2h ?? [];
const flagCls = isClub ? "mx-auto h-[72px] w-[72px]" : "mx-auto h-[68px] w-[104px]";
return (
<section className="mt-6">
@@ -45,8 +73,8 @@ export default function MatchupHUD({ match, lang = "ko" }: { match: Match; lang?
className="relative rounded-3xl border-2 border-[var(--green)] bg-[#171b21] p-5"
style={{ boxShadow: "0 0 28px rgba(74,255,160,0.35), inset 0 0 24px rgba(74,255,160,0.06)" }}
>
{/* 파도타기 마스코트 — 축구 전용 (야구는 미노출) */}
{!isBaseball && (
{/* 파도타기 마스코트 — 월드컵 전용 (야구·MLS 미노출) */}
{!isClub && (
<div className="absolute right-2 top-2 z-10">
<WaveStrip />
</div>
@@ -66,9 +94,9 @@ export default function MatchupHUD({ match, lang = "ko" }: { match: Match; lang?
</div>
<div className="mt-0.5 text-[12px] text-white/65">
{match.venue}
{isBaseball && (
{isClub && (
<span className="text-white/40">
{" "}· {lang === "en" ? "Home: " : "홈 "}{teamShort(right, lang)}
{" "}· {lang === "en" ? "Home: " : "홈 "}{teamShort(match.teamB, lang)}
</span>
)}
</div>
@@ -167,6 +195,57 @@ export default function MatchupHUD({ match, lang = "ko" }: { match: Match; lang?
</div>
)}
{/* MLS 정보 패널: 최근 5경기 폼 · 컨퍼런스 순위 · 최근 맞대결 (캐시 있을 때만) */}
{isMls && (ex?.formA || ex?.formB || mlsStL || mlsStR || h2h.length > 0) && (
<div className="mt-4 rounded-2xl bg-white/[0.04] p-3.5 text-[12px]">
{(ex?.formA || ex?.formB) && (
<div className="grid grid-cols-[1fr_auto_1fr] items-center gap-2">
<div className="min-w-0">
<FormBadges form={ex?.formB} />
{ex?.recordB && (
<span className="ml-1.5 text-white/45">{ex.recordB}</span>
)}
</div>
<span className="text-[11px] font-bold text-[var(--green)]">
{lang === "en" ? "Last 5 · W-L-D" : "최근 5경기 · 시즌"}
</span>
<div className="min-w-0 text-right">
{ex?.recordA && (
<span className="mr-1.5 text-white/45">{ex.recordA}</span>
)}
<FormBadges form={ex?.formA} />
</div>
</div>
)}
{(mlsStL || mlsStR) && (
<div className="mt-2.5 flex items-center justify-between border-t border-white/10 pt-2.5 text-white/55">
<span className="truncate">{mlsStL ?? "—"}</span>
<span className="px-2 text-[10px] text-white/30">{lang === "en" ? "STANDINGS" : "순위"}</span>
<span className="truncate text-right">{mlsStR ?? "—"}</span>
</div>
)}
{h2h.length > 0 && (
<div className="mt-2.5 border-t border-white/10 pt-2.5">
<div className="mb-1 text-center text-[10px] text-white/35">
{lang === "en" ? "RECENT H2H" : "최근 맞대결"}
</div>
<ul className="space-y-0.5 text-center font-mono text-[11px] text-white/60">
{h2h.slice(0, 3).map((g, i) => (
<li key={i}>
<span className="text-white/35">{g.date.slice(5).replace("-", ".")}</span>{" "}
{g.home} {g.scoreH}
<span className="px-1 text-white/30">:</span>
{g.scoreA} {g.away}
</li>
))}
</ul>
</div>
)}
</div>
)}
{finished && (
<div className="mt-3 text-center text-[12px] font-bold text-[var(--green)]">
{t.matchEnded}