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.
223 lines
9.8 KiB
HTML
223 lines
9.8 KiB
HTML
<!doctype html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||
<title>Posters · F1 Circuits API examples</title>
|
||
<meta name="description" content="Render F1 race posters, season posters and session thumbnails for Plex from the F1 Circuits API.">
|
||
<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">Grand prix lookup</a>
|
||
<a href="posters.html" aria-current="page">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>Posters</h1>
|
||
<p class="lead">
|
||
The API renders artwork for a Formula 1 library in Plex: a 1000×1500 poster per race and per season, and a
|
||
1920×1080 thumbnail per session of a race weekend. The server draws each one on request, fetching map tiles for its
|
||
background, and keeps it on disk afterwards; so this page renders only the one you ask for, when you press its
|
||
button.
|
||
</p>
|
||
|
||
<section class="card" id="races">
|
||
<h2>1. Choose a race</h2>
|
||
<p>The race poster and the session thumbnails name the race as Jolpica’s <code>raceName</code>; this list comes from Jolpica.</p>
|
||
<div class="controls" id="race-picker"></div>
|
||
<div class="request"></div>
|
||
<div class="status"></div>
|
||
</section>
|
||
|
||
<div class="grid-2">
|
||
<section class="card" id="race-poster">
|
||
<h2>Race poster</h2>
|
||
<p><code>/posters/race/{race name}/{season}.png?bg={background}</code>, 1000×1500: the round, the race’s name, the track and its date over a map of the circuit. Every other option is on the <a href="builder.html">poster builder</a>.</p>
|
||
<div class="controls">
|
||
<label><span>Background (<code>bg</code>)</span>
|
||
<select id="bg">
|
||
<option value="satellite">satellite: the national aerial photo, else EOxCloudless 2025 (the default)</option>
|
||
<option value="photo">photo: the layout’s picked Commons photo, else what satellite draws</option>
|
||
<option value="osm">osm: OpenStreetMap street map</option>
|
||
<option value="dark">dark: OpenStreetMap, recoloured dark</option>
|
||
<option value="light">light: OpenStreetMap, recoloured light</option>
|
||
<option value="none">none: plain black, no tiles (fastest)</option>
|
||
</select>
|
||
</label>
|
||
<button type="button" class="primary" id="render-race">Render the race poster</button>
|
||
</div>
|
||
<div class="request compact"></div>
|
||
<div class="status idle">Not rendered yet.</div>
|
||
<div class="result preview"></div>
|
||
</section>
|
||
|
||
<section class="card" id="season-poster">
|
||
<h2>Season poster</h2>
|
||
<p><code>/posters/season/{season}.png</code>, 1000×1500: the year over a photo of that season’s cars, or over black when the server has no photo for it.</p>
|
||
<div class="controls">
|
||
<label>Season <input type="number" id="season" min="1950" max="2100"></label>
|
||
<button type="button" class="primary" id="render-season">Render the season poster</button>
|
||
</div>
|
||
<div class="request compact"></div>
|
||
<div class="status idle">Not rendered yet.</div>
|
||
<div class="result preview"></div>
|
||
</section>
|
||
</div>
|
||
|
||
<section class="card" id="session-thumb">
|
||
<h2>Session thumbnail</h2>
|
||
<p>
|
||
<code>/posters/session/{race name}/{season}/{session}.png</code>, 1920×1080: an aerial view of the circuit with
|
||
the race’s name and the session’s label. Kometa numbers a weekend’s episodes differently for a standard weekend
|
||
(10 episodes) and a sprint weekend (15); the list shows the chosen race’s format first, in episode order.
|
||
</p>
|
||
<div class="controls">
|
||
<label><span>Session (<code>session</code>)</span> <select id="session"></select></label>
|
||
<button type="button" class="primary" id="render-session">Render the thumbnail</button>
|
||
</div>
|
||
<div class="request"></div>
|
||
<div class="status idle">Not rendered yet.</div>
|
||
<div class="result preview"></div>
|
||
</section>
|
||
|
||
<h2>Every session slug</h2>
|
||
<table>
|
||
<thead><tr><th>Slug</th><th>Label on the thumbnail</th><th>Episode, standard weekend</th><th>Episode, sprint weekend</th></tr></thead>
|
||
<tbody id="slugs"></tbody>
|
||
</table>
|
||
</main>
|
||
|
||
<footer class="pager">
|
||
<a rel="prev" href="grand-prix.html">← Grand prix lookup</a>
|
||
<a class="home" href="index.html">All examples</a>
|
||
<a rel="next" href="builder.html">Poster builder →</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, setRequest, setStatus, showImage, racePicker } = F1;
|
||
const $ = (id) => document.getElementById(id);
|
||
|
||
const STANDARD = F1.SESSIONS.standard;
|
||
const SPRINT = F1.SESSIONS.sprint;
|
||
const LABEL = Object.fromEntries([...STANDARD, ...SPRINT]);
|
||
const ALL = Object.keys(LABEL);
|
||
|
||
$('slugs').replaceChildren(...ALL.map((slug) => {
|
||
const std = STANDARD.findIndex(([s]) => s === slug);
|
||
const spr = SPRINT.findIndex(([s]) => s === slug);
|
||
return h('tr', {}, h('td', {}, h('code', {}, slug)), h('td', {}, LABEL[slug]),
|
||
h('td', {}, std >= 0 ? String(std + 1) : '–'), h('td', {}, spr >= 0 ? String(spr + 1) : '–'));
|
||
}));
|
||
|
||
let chosen = null;
|
||
let seasonTouched = false;
|
||
|
||
/** Shows the URL a button will call, without calling it; a result of another URL is cleared. */
|
||
function preview(card, url) {
|
||
card._wanted = url;
|
||
if (card._shown === url) return;
|
||
setRequest(card.querySelector('.request'), url);
|
||
card.querySelector('.result').replaceChildren();
|
||
card._shown = null;
|
||
if (!card.querySelector('.status').classList.contains('pending')) {
|
||
setStatus(card.querySelector('.status'), 'idle', 'Not rendered yet: press the button.');
|
||
}
|
||
}
|
||
|
||
async function render(card, button, url, alt, portrait) {
|
||
button.disabled = true;
|
||
try {
|
||
const answer = await call(card, url, { waiting: 'Rendering on the server: it fetches map tiles first, a few seconds the first time…' });
|
||
const out = card.querySelector('.result');
|
||
if (card._wanted !== url) {
|
||
setRequest(card.querySelector('.request'), card._wanted);
|
||
setStatus(card.querySelector('.status'), 'idle', 'The choice changed while it rendered: press the button again.');
|
||
return;
|
||
}
|
||
if (!answer) { out.replaceChildren(); return; }
|
||
await showImage(out, answer, 'png', { alt, tile: false, className: portrait ? 'poster portrait' : 'poster', status: card.querySelector('.status') });
|
||
card._shown = url;
|
||
} finally {
|
||
button.disabled = false;
|
||
}
|
||
}
|
||
|
||
const raceURL = () => api(path`/posters/race/${chosen.name}/${chosen.season}.png`) + `?bg=${encodeURIComponent($('bg').value)}`;
|
||
const seasonURL = () => api(path`/posters/season/${$('season').value}.png`);
|
||
const sessionURL = () => api(path`/posters/session/${chosen.name}/${chosen.season}/${$('session').value}.png`);
|
||
|
||
function fillSessions() {
|
||
const keep = $('session').value || 'race';
|
||
const own = chosen && chosen.sprint ? SPRINT : STANDARD;
|
||
const ownSlugs = new Set(own.map(([s]) => s));
|
||
const rest = ALL.filter((s) => !ownSlugs.has(s));
|
||
const format = chosen && chosen.race ? (chosen.sprint ? 'a sprint weekend' : 'a standard weekend') : 'format unknown, standard order';
|
||
$('session').replaceChildren(
|
||
h('optgroup', { label: `This race (${format})` },
|
||
...own.map(([s, label], i) => h('option', { value: s }, `Episode ${i + 1} · ${label} (${s})`))),
|
||
h('optgroup', { label: 'The other format’s slugs' },
|
||
...rest.map((s) => h('option', { value: s }, `${LABEL[s]} (${s})`))));
|
||
$('session').value = ALL.includes(keep) ? keep : 'race';
|
||
}
|
||
|
||
function previews() {
|
||
if (chosen && chosen.name) {
|
||
preview($('race-poster'), raceURL());
|
||
preview($('session-thumb'), sessionURL());
|
||
}
|
||
if ($('season').value) preview($('season-poster'), seasonURL());
|
||
}
|
||
|
||
$('bg').addEventListener('change', previews);
|
||
$('session').addEventListener('change', previews);
|
||
$('season').addEventListener('input', () => { seasonTouched = true; previews(); });
|
||
|
||
$('render-race').addEventListener('click', () => {
|
||
if (chosen && chosen.name) render($('race-poster'), $('render-race'), raceURL(), `${chosen.name} ${chosen.season} poster`, true);
|
||
});
|
||
$('render-season').addEventListener('click', () => {
|
||
if ($('season').value) render($('season-poster'), $('render-season'), seasonURL(), `${$('season').value} season poster`, true);
|
||
});
|
||
$('render-session').addEventListener('click', () => {
|
||
if (chosen && chosen.name) render($('session-thumb'), $('render-session'), sessionURL(), `${chosen.name} ${chosen.season} ${$('session').value} thumbnail`, false);
|
||
});
|
||
|
||
racePicker($('race-picker'), {
|
||
card: $('races'),
|
||
onChange: (c) => {
|
||
chosen = c;
|
||
if (!seasonTouched) $('season').value = c.season;
|
||
fillSessions();
|
||
previews();
|
||
},
|
||
});
|
||
})();
|
||
</script>
|
||
</body>
|
||
</html>
|