Files
f1-circuits/examples/kometa.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

162 lines
7.5 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>
<a href="../guides/index.html">Guides</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>