diff --git a/README.md b/README.md
index 5023c42..f1cca50 100644
--- a/README.md
+++ b/README.md
@@ -50,6 +50,13 @@ A race is named as [Jolpica](https://github.com/jolpica/jolpica-f1) (the Ergast
its schedule, and its circuit is found by Jolpica's circuit id (`ergastId` in `circuits.json`), never by the
circuit's name: Jolpica renames circuits (Losail became Lusail), the id stays.
+## Guides
+
+Step-by-step guides for putting the posters in a media server, on the site at https://f1-circuits.zurag.be/guides/:
+
+* [Plex](guides/plex.html), with Kometa: https://f1-circuits.zurag.be/guides/plex.html
+* [Emby](guides/emby.html), by hand or as picture files: https://f1-circuits.zurag.be/guides/emby.html
+
## The data
`circuits/circuits.json` holds country → locality → circuit → layout. A circuit has its `name`, its Jolpica
@@ -168,8 +175,9 @@ are fetched only when a picture asks for them, at most two at once; Wikimedia Co
`merge-check.sh` runs before a change merges: every Python file the service ships must parse, and the tests in
`tests/` must pass (every circuit has one unique `ergastId`, a race resolves by it, a failed Jolpica fetch is never
-kept, every link in this README leads to a file, an unknown circuit or layout is named; a poster's satellite source,
-credits and licence, its options, keys and cache headers, the picture store's cap, and the picks `/picks/…` answers).
+kept, every link in this README leads to a file, every directory the service serves is copied into its image, an
+unknown circuit or layout is named; a poster's satellite source, credits and licence, its options, keys and cache
+headers, the picture store's cap, and the picks `/picks/…` answers).
## Acknowledgment
diff --git a/cdn-api.py b/cdn-api.py
index 3ea1e60..e0a6982 100644
--- a/cdn-api.py
+++ b/cdn-api.py
@@ -98,6 +98,7 @@ async def root():
*poster_sources.PICKS_ROUTES,
],
"examples": "/examples/",
+ "guides": "/guides/",
"disclaimer": DISCLAIMER,
}
@@ -139,6 +140,14 @@ app.mount(
name="examples",
)
+# The guides: step by step, putting the posters in a Plex or Emby library (guides/index.html), in the style of the
+# example site.
+app.mount(
+ "/guides",
+ StaticFiles(directory=Path(__file__).resolve().parent / "guides", html=True),
+ name="guides",
+)
+
# The poster routes are plain defs, not async: a render fetches map tiles and a schedule and draws for
# seconds, so it runs in the threadpool instead of holding up every other request on the event loop.
diff --git a/examples/builder.html b/examples/builder.html
index 27e99ff..8424e35 100644
--- a/examples/builder.html
+++ b/examples/builder.html
@@ -23,6 +23,7 @@
LibraryPhoto pickerLicences
+ Guides
+ Emby can show your Formula 1 library with a poster for every season, a poster for every race weekend and a picture
+ for every session. This guide shows two ways to put them in: by hand in Emby's own screens, or as picture files
+ next to your videos.
+
+
+ Kometa, the helper the Plex guide uses, works only with Plex: it
+ cannot run without a Plex Media Server. In Emby you put the
+ pictures in yourself.
+
+
+
What you will get
+
+
+
+ The show “Season 2025” gets the season poster.
+
+
+
+ Each race weekend gets its race poster: here round 23, Qatar.
+
+
+
+ Each session gets its thumbnail: here the race.
+
+
+
+
What you need
+
+
Emby Server, and Emby's web app open in your browser, signed in as an administrator.
+
Your Formula 1 videos in a library of the type TV shows, in folders as step 1 shows.
+
For the second way: access to the folders your videos are in.
+
+
+
+
1. How the library is laid out
+
Emby calls the levels of a TV library show, season and episode. The pictures fit this layout, the one the
+ Library page shows:
+
+
Every Formula 1 season is a show, such as Season 2025.
+
Every race weekend is a season of that show, numbered by its round: the Qatar Grand Prix,
+ round 23, is season 23.
+
Every session is an episode of that season: the race of a sprint weekend is episode 12.
+
+
Emby reads the numbers from the names of your folders and files, as its
+ TV naming page shows. For example:
+
Formula 1 ← the library's folder
+└── Season 2025 ← a show: the 2025 season
+ ├── Season 1 ← a season of the show: round 1, Australia
+ │ └── Season 2025 S01E08 Race.mkv ← episode 8: the race
+ └── Season 23 ← round 23, Qatar, a sprint weekend
+ ├── Season 2025 S23E06 Sprint.mkv
+ └── Season 2025 S23E12 Race.mkv
+
+ Which episode number is which session
+
This is how the Library page and the Plex guide number them. A sprint weekend has more sessions, so its numbers
+ differ:
+
+
Episode
Standard weekend
Sprint weekend
+
+
1
Free Practice 1
Free Practice 1
+
2
Free Practice 2
Pre-Sprint-Qualifying Buildup
+
3
Free Practice 3
Sprint Qualifying
+
4
Pre-Qualifying Buildup
Post-Sprint-Qualifying
+
5
Qualifying
Pre-Sprint Buildup
+
6
Post-Qualifying
Sprint
+
7
Pre-Race Buildup
Post-Sprint
+
8
Race
Pre-Qualifying Buildup
+
9
Post-Race
Qualifying
+
10
Highlights
Post-Qualifying
+
11
Pre-Race Buildup
+
12
Race
+
13
Post-Race
+
14
Highlights
+
15
Bonus Content
+
+
+
+
+
+
+
2. Find a picture's address
+
Every picture has its own web address. The Library page lists them all:
+
+
Open the Library page. When the site has just started, it can take a
+ few minutes to load.
+
Click a season, such as 2025. You see its season poster and one poster per race weekend.
+
Click a race weekend. You see its race poster and one thumbnail per session.
+
Under each picture is its address, with a Copy button and an Open button.
Nothing to install, nothing to save. Do this for the show, then for each race weekend, then for each session you
+ want a picture on.
+
+
Copy the picture's address from the Library page (step 2).
+
In Emby's web app, open your Formula 1 library and find the show, race weekend or session.
+
On its picture, click ⋯ and choose Edit Images.
+
On the picture marked Primary, click ⋯ and choose
+ Set Image from URL.
+
Paste the address and confirm.
+
+
You should see: the Formula 1 picture on the item, in place of the old one.
+
A season has over 20 race weekends and over 200 sessions. By hand suits the show and the race
+ weekends; for every session, the second way with the script at the end of this page is faster.
+
+
+
+
3b. The second way: picture files next to your videos
+
Emby reads pictures that sit in your folders under these names (its
+ TV naming page, “Series & Season Images” and
+ “Episode Images”):
+
+
For
Save the picture as
In the folder
+
+
The show
folder.png
of the show: Season 2025
+
A race weekend
folder.png
of the race weekend: Season 23
+
A session
the video's name, with -thumb.png in place of its ending:
+ Season 2025 S23E12 Race-thumb.png
next to the video
+
+
+
+
On the Library page (step 2), click Open under the picture. It opens on its own.
+
Right-click the picture and choose Save Image As (the words differ a little per browser).
+
Save it in the folder, under the name, that the table gives.
+
When the folder has its pictures: in Emby, on the show's picture, click ⋯ and choose
+ Refresh Metadata.
+
Set Refresh mode to Search for missing metadata, leave
+ Replace existing images off, and click Refresh.
+
+
You should see: the show, its race weekends and its sessions with the pictures you saved.
+
Emby also reads poster.png for a show or race weekend, and
+ season23-poster.png for round 23 when it sits in the show's folder. It looks for
+ folder first.
+
+
+
+
4. When the pictures get a new look
+
Emby keeps the picture it was given. When the pictures get a new look, they get new addresses (the Library page
+ always shows the current ones). Put the new ones in the same way: by hand (step 3a), or by saving the files again
+ and refreshing (step 3b).
+
Never switch on Replace existing images in Refresh Metadata for this library.
+ Emby then deletes the item's pictures, your own included, and downloads new ones from the online databases it
+ uses (Emby's metadata manager page).
+
+
+
If it doesn't work
+
+
A picture you saved does not show. Check its name and folder against the table in step 3b,
+ and that it ends in .png or .jpg. Then, on the library itself, click ⋯
+ and choose Scan Library Files.
+
A race poster sits on the wrong race weekend. Emby's season number must be the round: check
+ the folder's name (Season 23) or the S23 in the file names.
+
A thumbnail sits on the wrong session. Check the episode numbers against the table in step 1:
+ a sprint weekend is numbered differently from a standard one.
+
Your pictures were replaced. A refresh with Replace existing images on does
+ that. Put them in again (step 3a or 3b).
+
Set Image from URL does nothing. Emby fetches the picture from this site itself, so the
+ computer Emby runs on must reach https://f1-circuits.zurag.be. Open
+ a poster in a browser on that computer to
+ check.
+
+
+
For the technically minded
+
+
The pictures
+
+
Three routes, each a plain GET, no key: /posters/season/{season}.png (1000×1500),
+ /posters/race/{race name}/{season}.png (1000×1500) and
+ /posters/session/{race name}/{season}/{session}.png (1920×1080). The sessions are fp1,
+ fp2, fp3, pre-qualifying, qualifying,
+ post-qualifying, pre-race, race, post-race,
+ highlights, pre-sprint-qualifying, sprint-qualifying,
+ post-sprint-qualifying, pre-sprint, sprint, post-sprint and
+ bonus.
+
A race name is Jolpica's, its spaces and other characters encoded: Qatar%20Grand%20Prix,
+ S%C3%A3o%20Paulo%20Grand%20Prix.
+
Options as query parameters, such as format=jpg (smaller files; the address keeps its
+ .png), width=600, style=minimal and bg=photo. Try every option
+ in the poster builder; the API
+ reference lists them.
+
?v=a1 is the address version. An address that carries it is kept by clients for good; it is raised
+ when the look changes. The Kometa file
+ always carries the current one, and lists every picture's address per season, round and episode number.
+
+
+
A whole season as files, with a script
+
For Linux, macOS or a NAS with a shell. It reads the season's addresses from the Kometa file and saves, as JPEG,
+ folder.jpg in the show's folder, seasonNN-poster.jpg per round next to it, and
+ <video>-thumb.jpg next to every video whose name carries its round and episode
+ (S23E12 or 23x12). Keep one picture per item: delete a .png you saved by hand
+ for the same item. Then refresh as in step 3b.
+
#!/bin/sh
+# Usage: f1-emby-art.sh 2025 "/media/Formula 1/Season 2025"
+season=$1 show=$2 api=https://f1-circuits.zurag.be opts=format=jpg
+
+# Every address of the season: "round episode address", 0 for the show's or a round's own picture.
+list=$(curl -fsS "$api/kometa/formula-1-metadata.yml" | awk -v season="$season" '
+ /^ "Season [0-9]+":/ { on = index($0, "\"Season " season "\":") > 0; round = ep = 0; next }
+ !on { next }
+ /^ [0-9]+:$/ { round = $1 + 0; ep = 0; next }
+ /^ [0-9]+:$/ { ep = $1 + 0; next }
+ /url_poster:/ { print round, ep, $2 }')
+address() { printf '%s\n' "$list" | awk -v r="$1" -v e="$2" -v o="$opts" '$1 == r && $2 == e { print $3 "&" o }'; }
+
+curl -fsSo "$show/folder.jpg" "$(address 0 0)"
+for round in $(printf '%s\n' "$list" | awk '$1 > 0 && $2 == 0 { print $1 }'); do
+ curl -fsSo "$show/$(printf 'season%02d-poster.jpg' "$round")" "$(address "$round" 0)"
+done
+find "$show" -type f | grep -Ei '\.(mkv|mp4|m4v|ts|avi|mov|webm)$' | while IFS= read -r file; do
+ set -- $(printf '%s\n' "${file##*/}" | sed -nE -e 's/.*[Ss]([0-9]+)[Ee]([0-9]+).*/\1 \2/p' -e t \
+ -e 's/^(.*[^0-9])?([0-9]+)x([0-9]+)([^0-9].*)?$/\2 \3/p')
+ [ $# = 2 ] && url=$(address "$1" "$2") && [ -n "$url" ] && curl -fsSo "${file%.*}-thumb.jpg" "$url"
+done
+
+
Through Emby's API
+
Emby downloads a picture from an address onto an item with
+ POST
+ /Items/{Id}/RemoteImages/Download, with Type (Primary for the show's, a
+ season's and an episode's picture) and ImageUrl in the query. It needs an administrator: make an
+ API key in the server dashboard
+ (Advanced, Security, Add) and send it in the X-Emby-Token header.
+
EMBY=http://localhost:8096/emby
+KEY=your-api-key
+
+# The show's Id: search the library for it
+curl -fsS -H "X-Emby-Token: $KEY" "$EMBY/Items?IncludeItemTypes=Series&Recursive=true&SearchTerm=Season%202025"
+# Its seasons (IndexNumber is the round) and one season's episodes (IndexNumber is the episode)
+curl -fsS -H "X-Emby-Token: $KEY" "$EMBY/Shows/$SHOW/Seasons"
+curl -fsS -H "X-Emby-Token: $KEY" "$EMBY/Shows/$SHOW/Episodes?SeasonId=$SEASON"
+
+# Round 23's poster onto its season
+curl -fsS -X POST -H "X-Emby-Token: $KEY" -G "$EMBY/Items/$SEASON/RemoteImages/Download" \
+ --data-urlencode Type=Primary \
+ --data-urlencode "ImageUrl=https://f1-circuits.zurag.be/posters/race/Qatar%20Grand%20Prix/2025.png?v=a1&format=jpg"
+
Emby keeps the copy it downloaded. When the address version is raised, call it again with the new address.
+
+
+
+
+
+
+
diff --git a/guides/guides.js b/guides/guides.js
new file mode 100644
index 0000000..e2ee7d7
--- /dev/null
+++ b/guides/guides.js
@@ -0,0 +1,35 @@
+/*
+ * The guides' one behaviour: a Copy button on every box of text to copy (`.copy`), copying the text of its
+ * `code` element. Without the script the text stays selectable by hand.
+ */
+(function () {
+ 'use strict';
+
+ async function copy(text, button) {
+ let done = false;
+ try {
+ await navigator.clipboard.writeText(text);
+ done = true;
+ } catch {
+ const area = document.createElement('textarea');
+ area.value = text;
+ area.style.cssText = 'position:fixed;opacity:0';
+ document.body.append(area);
+ area.select();
+ try { done = document.execCommand('copy'); } catch { done = false; }
+ area.remove();
+ }
+ button.textContent = done ? 'Copied' : 'Select it and copy';
+ setTimeout(() => { button.textContent = 'Copy'; }, 1500);
+ }
+
+ for (const box of document.querySelectorAll('.copy')) {
+ const code = box.querySelector('code');
+ if (!code) continue;
+ const button = document.createElement('button');
+ button.type = 'button';
+ button.textContent = 'Copy';
+ button.addEventListener('click', () => copy(code.textContent, button));
+ box.append(button);
+ }
+})();
diff --git a/guides/index.html b/guides/index.html
new file mode 100644
index 0000000..4159ec5
--- /dev/null
+++ b/guides/index.html
@@ -0,0 +1,78 @@
+
+
+
+
+
+ Guides · F1 Circuits
+
+
+
+
+
+
+ F1 Circuits API
+
+
+
+
+
Guides
+
+ Give your Formula 1 library a poster for every season, a poster for every race weekend and a picture for every
+ session. These guides take you through it one step at a time. Pick the media server you use.
+
+
+
+
+
+ A season: the year over a photo of that season's cars.
+
+
+
+ A race weekend: its round, name, date and track over its circuit.
+
+
+
+ A session: the race, a qualifying or a practice, over the circuit.
+
+
+ Every picture carries, at its bottom, the credit of the photo or map it is made from, and takes its licence from
+ them; the licences page lists every source and its licence.
+
+
+
+
+
+
+
diff --git a/guides/plex.html b/guides/plex.html
new file mode 100644
index 0000000..30d9484
--- /dev/null
+++ b/guides/plex.html
@@ -0,0 +1,260 @@
+
+
+
+
+
+ Using the posters in Plex · Guides · F1 Circuits
+
+
+
+
+
+
+ F1 Circuits API
+
+
+
+
+
Using the posters in Plex
+
+ Plex can show your Formula 1 library with a poster for every season, a poster for every race weekend and a picture
+ for every session. A free helper called Kometa puts them there for you, and
+ keeps them up to date. This guide takes you through it one step at a time.
+
+
+
What you will get
+
+
+
+ The show “Season 2025” gets the season poster.
+
+
+
+ Each race weekend gets its race poster: here round 23, Qatar.
+
+
+
+ Each session gets its thumbnail: here the race.
+
+
+
The Library page shows a whole library this way, season by season.
+
+
What you need
+
+
Plex Media Server, and the Plex Web App open in your browser.
+
Your Formula 1 videos, in folders as step 1 shows.
+
A computer to run Kometa on. It can be the computer Plex runs on. Kometa has no window of its own: you set it
+ up by filling in one text file and starting it with one command.
+
A free account at The Movie Database (TMDb). Kometa always asks for
+ its key, even though this guide does not use it.
+
+
+
+
1. Put your videos in folders
+
Kometa's Formula 1 guide shapes the library
+ like this. Plex calls the levels show, season and episode:
+
+
Every Formula 1 season is a show, in a folder named Season 2025. Keep that name:
+ the pictures are matched to the show by it.
+
Every race weekend is a season of that show, in a folder that starts with its round:
+ 23 - Qatar GP. Plex numbers it by the round.
+
Every session is an episode: one file, named with the round, the episode number and the
+ session, such as 23x12 - Qatar GP - Race Session.mkv.
+
+
Formula 1 ← the library's folder
+└── Season 2025 ← a show: the 2025 season
+ ├── 01 - Australian GP ← a season of the show: round 1
+ │ ├── 01x01 - Australian GP - Free Practice 1.mkv
+ │ ├── 01x05 - Australian GP - Qualifying Session.mkv
+ │ └── 01x08 - Australian GP - Race Session.mkv
+ └── 23 - Qatar GP ← round 23, a sprint weekend
+ ├── 23x06 - Qatar GP - Sprint Race Session.mkv
+ └── 23x12 - Qatar GP - Race Session.mkv
+
+ Which episode number is which session
+
The pictures go to the episodes by their number. A sprint weekend has more sessions, so its numbers differ:
+
+
Episode
Standard weekend
Sprint weekend
+
+
1
Free Practice 1
Free Practice 1
+
2
Free Practice 2
Pre-Sprint-Qualifying Buildup
+
3
Free Practice 3
Sprint Qualifying
+
4
Pre-Qualifying Buildup
Post-Sprint-Qualifying
+
5
Qualifying
Pre-Sprint Buildup
+
6
Post-Qualifying
Sprint
+
7
Pre-Race Buildup
Post-Sprint
+
8
Race
Pre-Qualifying Buildup
+
9
Post-Race
Qualifying
+
10
Highlights
Post-Qualifying
+
11
Pre-Race Buildup
+
12
Race
+
13
Post-Race
+
14
Highlights
+
15
Bonus Content
+
+
+
+
+
+
+
2. Make the Formula 1 library in Plex
+
The library needs Plex's Personal Media Shows agent. An agent is the part of Plex that looks up titles
+ and pictures; this one does not look your videos up on the internet, which suits recordings no online database
+ lists. Since Plex Media Server 1.43.0, Plex hides it when you make a new library unless one setting is on.
+
+
In the Plex Web App, open Settings and choose your server.
+
Choose Library, turn on Show Legacy Agent during library set up, and save
+ the change. (An older Plex Media Server does not have this setting and shows the agent anyway.)
+
Under Manage, choose Libraries, then Add Library.
+
Choose TV Shows and name the library, for example Formula 1. Note the exact
+ name: you will type it in step 4.
+
Add the folder that holds your season folders (Formula 1 in the example above).
+
Choose Advanced, and under Agent choose
+ Personal Media Shows (Legacy).
+
Finish adding the library.
+
+
You should see: one show per season folder, such as “Season 2025”, and inside it one season per race
+ weekend.
+
Already have a Formula 1 library with another agent? Plex's
+ page on agents shows how to change it, and says
+ the change applies only to videos added after it.
+
+
+
+
3. Install Kometa
+
+
Open Kometa's installation walkthrough and choose
+ the computer you will run it on. Kometa recommends its Docker version unless you already use Python.
+
Follow it until it asks for three things, and gather them as it says:
+
+
Your Plex address: the address that computer uses to reach Plex directly, such as
+ http://192.0.2.10:32400. Not app.plex.tv.
+
Your Plex token, a password for programs: in the Plex Web App, open any video's
+ ⋯ menu, choose Get Info, then the XML link at the bottom
+ (Plex's
+ page). The token is the part after X-Plex-Token= in the address of the page that opens.
+
Your TMDb key: sign in at themoviedb.org, open Settings from your account
+ menu, choose API and request a key. If it shows two keys, use the v3 one.
+
+
+
Make the file config.yml as the walkthrough shows, with your Plex address, Plex token and TMDb
+ key in it. Then come back here for its libraries part.
+
+
+
+
+
4. Point Kometa at the Formula 1 file
+
One file on this site tells Kometa which picture goes on which season, race weekend and session, for every
+ season from 1950 on.
+
+
Open config.yml in a plain text editor, such as Notepad on Windows or TextEdit on a Mac.
+
Replace its libraries: part with the lines below. If it already lists libraries of your own,
+ keep them and add the Formula 1: lines under them.
+
libraries:
+ Formula 1:
+ metadata_files:
+ - url: https://f1-circuits.zurag.be/kometa/formula-1-metadata.yml
+
+
Change Formula 1 to your library's exact name in Plex, if you named it otherwise.
+
Keep the spaces at the start of each line as shown: two per level. Kometa reads the levels from them.
+
Save the file. The plex: and tmdb: parts stay as you filled them in.
+
+
+
+
+
5. Run Kometa once
+
Type the command for the way you installed Kometa, in the window the walkthrough had you use:
+
+
Kometa with Python, from its folder:
+
uv run python kometa.py --run
+
Kometa with Docker (put the full path of the folder that holds config.yml in place of
+ FULL_PATH_TO_CONFIG):
+
docker run --rm -it -v "FULL_PATH_TO_CONFIG:/config:rw" kometateam/kometa --run
+
Kometa with Docker Compose, from the folder that holds compose.yml:
+
docker compose run --rm kometa --run
+
+
Kometa writes what it does as it goes. Let it finish: the first time it sets a picture on every season, race
+ weekend and session it finds, so it takes a while.
+
You should see: Kometa connect to TMDb and to Plex, work through your Formula 1 library, and end. In
+ Plex, after reloading the page, every season, race weekend and session has its picture.
+
+
+
+
6. Keep it up to date
+
Leave Kometa running in its normal way, without --run: the part “Scheduling and updates” of the
+ walkthrough shows how for your installation. Then it
+ runs by itself once a day, at 05:00 unless you change it. Each time it reads the Formula 1 file again, so a new
+ race weekend gets its pictures.
+
When the pictures get a new look, the file names new addresses for them, and Kometa puts the new pictures in on
+ its next run. A picture it has already put in is not sent again. To get a new look at once, run step 5 again.
+
+
+
If it doesn't work
+
+
Nothing changed in Plex. Open the newest meta.log in the logs folder
+ next to config.yml, and read the lines marked CRITICAL, then ERROR.
+
Kometa does not work on the library. The name under libraries: must be the
+ library's name in Plex, letter for letter.
+
A season gets no pictures. Its show must be called exactly Season 2025 (with its
+ own year) in Plex.
+
A race poster sits on the wrong race weekend. In Plex, each race weekend's season number must be
+ its round. Check the number at the start of its folder.
+
A thumbnail sits on the wrong session. Check the episode numbers against the table in step 1:
+ a sprint weekend is numbered differently from a standard one.
+
Pictures stay empty. Plex fetches every picture from this site, so the computer Plex runs on
+ must reach https://f1-circuits.zurag.be. Open
+ a poster in a browser on that computer to
+ check.
The file is /kometa/formula-1-metadata.yml,
+ a Kometa metadata file, explained on the Kometa page. Per show
+ ("Season 2025") it sets f1_season, round_prefix, shorten_gp
+ and the season poster as url_poster; per season of the show (a round) the race poster; per episode
+ the session thumbnail. It covers every season from 1950 to next year; Kometa skips what the library does not
+ hold. The first request after the service starts can take minutes: it reads every season's schedule from
+ Jolpica.
+
Every address in it carries the address version, ?v=a1. Such an address is kept by clients for
+ good; the version is raised when the look changes, which gives every picture a new address. Kometa (with its
+ cache on, the default) sets a poster only when its address differs from the one it set last, so the raise is
+ what brings a new look in.
+
The pictures are three routes, each a plain GET:
+ /posters/season/{season}.png, /posters/race/{race name}/{season}.png and
+ /posters/session/{race name}/{season}/{session}.png. A race name is Jolpica's, with its spaces and
+ other characters encoded: Qatar%20Grand%20Prix, S%C3%A3o%20Paulo%20Grand%20Prix.
+
They take options such as style=minimal, bg=photo, width=600 and
+ format=jpg. Try every option in the poster builder; all of
+ them are listed in the API reference. The file uses the default
+ look. For another look, save a copy of the file, add your options to its addresses, and give Kometa that copy
+ with a - file: line in place of the - url: line
+ (Kometa's page on files); your copy then no longer
+ takes in new races by itself.
+
+
+
+
+
+
+
+
diff --git a/service/Dockerfile b/service/Dockerfile
index 6e0463c..0092514 100644
--- a/service/Dockerfile
+++ b/service/Dockerfile
@@ -30,6 +30,8 @@ COPY circuits/ ./circuits/
COPY seasons/ ./seasons/
# The example site the app serves at /examples/.
COPY examples/ ./examples/
+# The guides the app serves at /guides/.
+COPY guides/ ./guides/
EXPOSE 8000
diff --git a/tests/test_image.py b/tests/test_image.py
new file mode 100644
index 0000000..c70481e
--- /dev/null
+++ b/tests/test_image.py
@@ -0,0 +1,23 @@
+"""Every directory the service serves is copied into its image: a mount of a directory the image lacks stops the
+service at its start (Starlette's StaticFiles checks its directory)."""
+import re
+import unittest
+from pathlib import Path
+
+ROOT = Path(__file__).resolve().parent.parent
+
+
+class ImageTest(unittest.TestCase):
+ def test_every_served_directory_is_copied_into_the_image(self):
+ app = (ROOT / "cdn-api.py").read_text(encoding="utf-8")
+ served = re.findall(r'StaticFiles\(directory=Path\(__file__\)\.resolve\(\)\.parent / "([^"]+)"', app)
+ self.assertTrue(served, "cdn-api.py serves no directory")
+ dockerfile = (ROOT / "service" / "Dockerfile").read_text(encoding="utf-8")
+ copied = set(re.findall(r"^COPY (\S+)/ \./\1/$", dockerfile, re.M))
+ self.assertEqual(sorted(set(served) - copied), [], "served by cdn-api.py, not copied by service/Dockerfile")
+ for directory in served:
+ self.assertTrue((ROOT / directory / "index.html").is_file(), f"{directory}/ has no index.html")
+
+
+if __name__ == "__main__":
+ unittest.main()