Match-rich API: oriented shots/xG, momentum, POTM, officials, weather
GET /api/match-rich/:num projects the captured provider data for the match center: every shot with pitch coords and xG oriented to home/away (FotMob payloads now carry team ids, v2 + settle-versioned refetch), team xG sums, the momentum curve, player of the match with rating, FIFA's official attendance/stadium/referee, and kickoff-hour weather. Verified on real data: South Korea 2.31-0.83 Czechia on 22 oriented shots, POTM Hwang 8.9, referee Amin Mohamed Omar. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -54,10 +54,12 @@ export async function fetchFotmobMatches(dateYYYYMMDD: string): Promise<FotmobMa
|
||||
/** Trimmed matchDetails: everything analytic, minus the bulky redundant tabs
|
||||
* (liveticker/buzz/h2h/table/seo) we already cover via other sources. */
|
||||
export interface FotmobDetails {
|
||||
v: 1;
|
||||
v: 2;
|
||||
fetchedAt: number;
|
||||
matchId: string;
|
||||
finished: boolean;
|
||||
homeTeamId: number | null;
|
||||
awayTeamId: number | null;
|
||||
shots: unknown[];
|
||||
stats: unknown;
|
||||
matchFacts: unknown;
|
||||
@@ -68,7 +70,12 @@ export interface FotmobDetails {
|
||||
}
|
||||
|
||||
interface RawDetails {
|
||||
general?: { matchId?: string; finished?: boolean };
|
||||
general?: {
|
||||
matchId?: string;
|
||||
finished?: boolean;
|
||||
homeTeam?: { id?: number };
|
||||
awayTeam?: { id?: number };
|
||||
};
|
||||
content?: {
|
||||
shotmap?: { shots?: unknown[] };
|
||||
stats?: unknown;
|
||||
@@ -92,10 +99,12 @@ export async function fetchFotmobDetails(matchId: string, live = false): Promise
|
||||
delete mf.preReview;
|
||||
delete mf.poll;
|
||||
return {
|
||||
v: 1,
|
||||
v: 2,
|
||||
fetchedAt: Date.now(),
|
||||
matchId: raw.general?.matchId ?? matchId,
|
||||
finished: raw.general?.finished ?? false,
|
||||
homeTeamId: raw.general?.homeTeam?.id ?? null,
|
||||
awayTeamId: raw.general?.awayTeam?.id ?? null,
|
||||
shots: c.shotmap?.shots ?? [],
|
||||
stats: c.stats ?? null,
|
||||
matchFacts: mf,
|
||||
|
||||
@@ -223,8 +223,8 @@ export function startScheduler(
|
||||
const live = f.status === 'live';
|
||||
if (!live && f.status !== 'finished') continue;
|
||||
if (f.status === 'finished') {
|
||||
const row = getMatchProvider(f.num, 'fotmob');
|
||||
const settled = row && row.updatedAt > new Date(f.kickoff).getTime() + FOTMOB_SETTLE_MS;
|
||||
const row = getMatchProvider<{ v?: number }>(f.num, 'fotmob');
|
||||
const settled = row && row.data.v === 2 && row.updatedAt > new Date(f.kickoff).getTime() + FOTMOB_SETTLE_MS;
|
||||
if (settled) continue;
|
||||
}
|
||||
const t0 = Date.now();
|
||||
|
||||
Reference in New Issue
Block a user