// Fetches official Paris 2024 swimming finals from the World Aquatics results API and prints each winner's time. // Usage: node check-aquatics.js const fs = require('fs'); const d = JSON.parse(fs.readFileSync(process.argv[2], 'utf8')); const sw = d.Sports.find(s => s.Name === 'Swimming'); const ev = sw.DisciplineList.filter(x => /Freestyle|Backstroke/.test(x.DisciplineName) && !/Relay|Mixed/.test(x.DisciplineName)); (async () => { for (const e of ev) { const r = await fetch('https://api.worldaquatics.com/fina/events/' + e.Id, { headers: { 'User-Agent': 'Mozilla/5.0' } }); const j = await r.json(); const f = (j.Heats || []).find(h => h.Name === 'Final'); const w = f && f.Results.find(x => x.Rank === 1); console.log(e.DisciplineName.padEnd(26), w ? w.Time : 'no final', 'https://api.worldaquatics.com/fina/events/' + e.Id); } })();