Files
f1-circuits/examples/grand-prix.html
T
jschoubben 09a83f6ad9 Guide Plex and Emby users step by step to the posters, at /guides/
People put the posters in their own libraries (one in an automated F1 library in Emby), and
the only help was the Kometa example page, written for developers. The guides are for people
who are not: numbered steps of one action each, the exact menus and buttons of Plex, Kometa and
Emby as their own documentation names them, boxes to copy, the pictures from the live API,
what to see after a step and what to do when it does not work. The technical details (routes,
options, the address version, a script and Emby's API) sit at the end of each.

guides/ holds the index, plex.html (a Plex TV library on the Personal Media Shows agent, Kometa
pointed at /kometa/formula-1-metadata.yml, its daily run) and emby.html (Kometa needs Plex, so:
Set Image from URL by hand, or picture files named as Emby's TV naming page reads them, and a
script that saves a whole season from the Kometa file). They use the example site's style
sheet; every example page's nav links them, and README.md lists them.

cdn-api.py serves guides/ at /guides/ beside /examples/, and the image copies it. A mount of a
directory the image lacks stops the service at its start, so tests/test_image.py holds that
every directory the app serves is copied by service/Dockerfile.
2026-11-30 12:46:36 +01:00

117 lines
5.0 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Grand prix lookup · F1 Circuits API examples</title>
<meta name="description" content="Look up the track of any F1 race by its name and season: the API finds the circuit and the layout raced that year.">
<link rel="icon" href="data:,">
<link rel="stylesheet" href="site.css">
</head>
<body>
<header class="site">
<a class="brand" href="index.html">F1 <span>Circuits</span> API</a>
<nav aria-label="Examples">
<a href="index.html">Overview</a>
<a href="circuits.html">Circuit browser</a>
<a href="tracks.html">Track images</a>
<a href="map.html">GPS traces</a>
<a href="grand-prix.html" aria-current="page">Grand prix lookup</a>
<a href="posters.html">Posters</a>
<a href="builder.html">Poster builder</a>
<a href="kometa.html">Kometa</a>
<a href="library.html">Library</a>
<a href="picker.html">Photo picker</a>
<a href="licences.html">Licences</a>
<a href="../guides/index.html">Guides</a>
</nav>
<div id="api-base"></div>
</header>
<main>
<h1>Grand prix lookup</h1>
<p class="lead">
Name a race and a season, and the API answers the track it was raced on: it reads that season’s schedule from
Jolpica, matches the race by its exact name, finds the circuit in its catalogue and picks the layout of that year.
</p>
<section class="card" id="races">
<h2>1. The season’s races</h2>
<p>
This page lists the races by calling Jolpica itself, from the browser (Jolpica allows any origin). If it cannot
be reached, type the name: the API needs it exactly as Jolpica’s <code>raceName</code>, such as
<code>British Grand Prix</code>.
</p>
<div class="controls" id="race-picker"></div>
<div class="request"></div>
<div class="status"></div>
</section>
<section class="card" id="lookup">
<h2>2. The race’s track</h2>
<p><code>/grand-prix/{race name}/{season}/{format}</code>, the race name percent-encoded (a space is <code>%20</code>).</p>
<div class="controls"><fieldset id="format"><legend>Format</legend></fieldset></div>
<div id="jolpica-says"></div>
<div class="request"></div>
<div class="status idle">Choose a race.</div>
<div class="result"></div>
</section>
<h2>When the lookup finds nothing</h2>
<p>
The API answers <code>404 {"detail": "Circuit not found"}</code> when the name is not in that season’s schedule,
when Jolpica cannot be reached from the server, or when the circuit or that year’s layout is not in the catalogue
yet (browse it in the <a href="circuits.html">circuit browser</a>).
</p>
</main>
<footer class="pager">
<a rel="prev" href="map.html">← GPS traces</a>
<a class="home" href="index.html">All examples</a>
<a rel="next" href="posters.html">Posters →</a>
</footer>
<footer class="disclaimer">
<p>This website is unofficial and is not associated in any way with the Formula 1 companies. F1, FORMULA ONE,
FORMULA 1, FIA FORMULA ONE WORLD CHAMPIONSHIP, GRAND PRIX and related marks are trade marks of Formula One
Licensing B.V.</p>
<p><a href="licences.html">Licences and credits</a>: every source the pictures are made from, the licence each
picture takes from its sources, and the licence of the track files and the GPS traces (MIT).</p>
</footer>
<script src="site.js"></script>
<script>
(function () {
const { h, api, path, call, showImage, showGeoJSON, racePicker } = F1;
const $ = (id) => document.getElementById(id);
const card = $('lookup');
const FORMATS = ['svg', 'png', 'geojson'];
const initial = FORMATS.includes(F1.params.get('format')) ? F1.params.get('format') : 'svg';
for (const f of FORMATS) {
const input = h('input', { type: 'radio', name: 'format', value: f, checked: f === initial });
input.addEventListener('change', lookup);
$('format').append(h('label', { class: 'inline' }, input, f));
}
let chosen = null;
async function lookup() {
if (!chosen || !chosen.name || !(chosen.season >= 1950)) return;
const f = $('format').querySelector('input:checked').value;
const r = chosen.race;
$('jolpica-says').replaceChildren(r
? h('p', {}, `Jolpica: round ${r.round} on ${r.date}, at ${r.Circuit.circuitName} in ${r.Circuit.Location.locality}, ${r.Circuit.Location.country}.`)
: h('p', {}, 'Jolpica’s entry for this name is not known on this page; the API looks it up itself.'));
const answer = await call(card, api(path`/grand-prix/${chosen.name}/${chosen.season}/${f}`), { waiting: 'Looking up the race…' });
const out = card.querySelector('.result');
if (!answer) { out.replaceChildren(); return; }
const status = card.querySelector('.status');
if (f === 'geojson') await showGeoJSON(out, answer, { status });
else await showImage(out, answer, f, { alt: `${chosen.name} ${chosen.season}`, status });
}
racePicker($('race-picker'), { card: $('races'), onChange: (c) => { chosen = c; lookup(); } });
})();
</script>
</body>
</html>