Files
f1-circuits/examples/kometa.html
T
jschoubben 49a2ebcf15 Add the photo picker, poster builder and licences pages
A pick is a repository edit, so the picker shows the Commons candidates cropped to the poster's
frame, natural or bw as the service treats them, beside the picks of the circuit's other
layouts, and gives the entry to copy (the picks file's "$comment" kept first). The builder sends
every option of docs/posters.md as a query parameter, renders only on request and shows the
answer's X-Credits and X-License. The licences page shows /licences: each source, its credit and
the licence a picture made from it gets.

Every page now carries the Formula 1 disclaimer at its foot, as F1's guidelines ask of an
unofficial site, and the posters page lists the backgrounds the design keeps (no Esri).

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
2026-11-27 15:04:38 +01:00

161 lines
7.4 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>Kometa metadata · F1 Circuits API examples</title>
<meta name="description" content="The Kometa metadata file the F1 Circuits API generates for a Formula 1 library in Plex, and what it is for.">
<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">Posters</a>
<a href="builder.html">Poster builder</a>
<a href="kometa.html" aria-current="page">Kometa</a>
<a href="library.html">Library</a>
<a href="picker.html">Photo picker</a>
<a href="licences.html">Licences</a>
</nav>
<div id="api-base"></div>
</header>
<main>
<h1>Kometa metadata</h1>
<p class="lead">
<a href="https://kometa.wiki/">Kometa</a> (formerly Plex Meta Manager) sets titles and artwork in a Plex library
from YAML files. This route generates the file for a Formula 1 library: it gives every season, every round and every
session of a weekend its artwork, all of it rendered by this API.
</p>
<h2>What it is for</h2>
<div class="card">
<p>In a Formula 1 library as Kometa’s Formula 1 builder shapes it:</p>
<ul>
<li>each F1 season is one <strong>show</strong>, titled like the file’s keys (<code>Season 2024</code>);</li>
<li>each round of that season is a Plex <strong>season</strong> of the show;</li>
<li>each session of the race weekend is an <strong>episode</strong>.</li>
</ul>
<p>
<code>f1_season</code> lets Kometa name the rounds and episodes from that year’s schedule. The file adds the
artwork: the show gets the <a href="posters.html">season poster</a>, each round its race poster, and each episode
its session thumbnail. It covers every season from 1950 to next year; Kometa skips a show or a round the library
does not hold.
</p>
<table class="kv">
<tr><th><code>f1_season</code></th><td>The year the show holds; Kometa’s Formula 1 builder reads its schedule.</td></tr>
<tr><th><code>round_prefix: true</code></th><td>Puts the round number in front of each round’s name.</td></tr>
<tr><th><code>shorten_gp: true</code></th><td>Shortens “Grand Prix” to “GP” in the names.</td></tr>
<tr><th><code>url_poster</code> (show)</th><td><code>/posters/season/{season}.png</code></td></tr>
<tr><th><code>seasons.{round}.url_poster</code></th><td><code>/posters/race/{race name}/{season}.png</code></td></tr>
<tr><th><code>episodes.{n}.url_poster</code></th><td><code>/posters/session/{race name}/{season}/{session}.png</code>, numbered as on the <a href="posters.html">posters page</a>: 10 episodes for a standard weekend, 15 for a sprint weekend.</td></tr>
</table>
<h3>Using it in Kometa</h3>
<p>Point the library at the file’s URL in Kometa’s <code>config.yml</code>; Kometa fetches it on every run:</p>
<pre class="code" id="config"></pre>
<p>
The poster addresses inside the file use the public name the service is served under, so Plex can fetch them.
The answer is <code>text/yaml</code> and may be cached for an hour (<code>Cache-Control: public, max-age=3600</code>).
</p>
</div>
<h2>The file</h2>
<section class="card" id="yaml">
<p>
<code>/kometa/formula-1-metadata.yml</code>. The server builds it from the Jolpica schedule of every season; the
first call after a restart takes several seconds.
</p>
<div class="request"></div>
<div class="status"></div>
<div id="summary"></div>
<div class="controls">
<label>Show <select id="season-filter"><option value="">All seasons</option></select></label>
</div>
<div class="result"></div>
</section>
</main>
<footer class="pager">
<a rel="prev" href="builder.html">← Poster builder</a>
<a class="home" href="index.html">All examples</a>
<a rel="next" href="library.html">Library →</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, call, showText, notice } = F1;
const $ = (id) => document.getElementById(id);
const fileURL = F1.absolute(api('/kometa/formula-1-metadata.yml'));
$('config').textContent = [
'libraries:',
' Formula 1: # the library’s name in Plex',
' metadata_files:',
` - url: ${fileURL}`,
].join('\n');
/** Splits the file into one block per show, counting its rounds and episodes. */
function parse(text) {
const lines = text.split('\n');
const head = [];
const seasons = [];
let cur = null;
for (const line of lines) {
const m = /^ {2}"Season (\d+)":/.exec(line);
if (m) { cur = { season: m[1], lines: [line], rounds: 0, episodes: 0 }; seasons.push(cur); continue; }
if (!cur) { head.push(line); continue; }
cur.lines.push(line);
if (/^ {6}\d+:\s*$/.test(line)) cur.rounds++;
else if (/^ {10}\d+:\s*$/.test(line)) cur.episodes++;
}
return { head, seasons };
}
async function load() {
const card = $('yaml');
const answer = await call(card, api('/kometa/formula-1-metadata.yml'), { waiting: 'The server is building the file from every season’s schedule…' });
if (!answer) return;
const text = await answer.blob.text();
const { head, seasons } = parse(text);
const rounds = seasons.reduce((n, s) => n + s.rounds, 0);
const episodes = seasons.reduce((n, s) => n + s.episodes, 0);
const empty = seasons.filter((s) => s.rounds === 0).map((s) => s.season);
const parts = [h('p', {}, `${seasons.length} shows (seasons ${seasons[0] ? seasons[0].season : '?'} to ${seasons.length ? seasons[seasons.length - 1].season : '?'}), ${rounds} rounds with a race poster, ${episodes} episodes with a session thumbnail.`)];
if (empty.length) {
parts.push(notice(empty.length > 2 ? 'error' : 'info',
`${empty.length} of ${seasons.length} shows list no rounds: `, h('code', {}, empty.join(', ')),
'. A show lists no rounds when the server had no schedule for that season from Jolpica (a season still to be published, or Jolpica not answering the server). Kometa then sets only that show’s poster.'));
}
$('summary').replaceChildren(...parts);
const filter = $('season-filter');
filter.append(...seasons.map((s) => h('option', { value: s.season }, `Season ${s.season} (${s.rounds} rounds)`)));
const show = () => {
const s = seasons.find((x) => x.season === filter.value);
showText(card.querySelector('.result'), s ? [...head, ...s.lines].join('\n') : text, { tall: true });
};
filter.addEventListener('change', show);
show();
}
load();
})();
</script>
</body>
</html>