Require key-value data file syntax

This commit is contained in:
hbrain 2026-05-25 18:52:36 +00:00
parent 86cb85b56d
commit 8d2d422c6c
2 changed files with 18 additions and 22 deletions

View file

@ -107,39 +107,33 @@ Files are ordered by filename, so names like this work well:
## data.txt ## data.txt
`data.txt` is optional. `data.txt` is optional, but if present every non-empty, non-comment line must use mandatory `key: value` syntax. Plain positional lines are not supported.
Simplest format: Movie metadata keys:
```text ```text
Paris Trip Title: Paris Trip
Paris, France Location: Paris, France
May 2024 Date: May 2024
Description: Longer description shown in MVLog and embedded in final MP4 metadata.
``` ```
Those three lines mean: Supported metadata key aliases:
1. title - title: `Title` or `Name`
2. location - location: `Location`, `Place`, or `Where`
3. date - date: `Date`, `Dates`, or `When`
- description: `Description`, `Desc`, or `Synopsis`
If the date line is omitted, movmaker uses the date from the first picture/video and displays it like: If the date entry is omitted, movmaker uses the date from the first picture/video and displays it like:
```text ```text
May 2026 May 2026
``` ```
If the location line is omitted and GPS coordinates are found in the first picture/video that has them, movmaker reverse geocodes them and uses that as the location. It tries to return only `city/town/village, country`; if no city/town/village is found, it uses just the country. If the location entry is omitted and GPS coordinates are found in the first picture/video that has them, movmaker reverse geocodes them and uses that as the location. It tries to return only `city/town/village, country`; if no city/town/village is found, it uses just the country.
Key/value format also works: Any other `key: value` line is treated as a per-file caption where the key is the exact media filename:
```text
title: Paris Trip
date: May 2024
place: Paris, France
```
Optional per-file captions are supported:
```text ```text
IMG_001.jpg: Eiffel Tower IMG_001.jpg: Eiffel Tower

View file

@ -523,10 +523,12 @@ def parse_data_file(path: Path | None) -> MovieData:
return MovieData(captions={}) return MovieData(captions={})
data = MovieData(captions={}) data = MovieData(captions={})
for raw in path.read_text(encoding="utf-8", errors="replace").splitlines(): for line_no, raw in enumerate(path.read_text(encoding="utf-8", errors="replace").splitlines(), start=1):
line = raw.strip() line = raw.strip()
if not line or line.startswith("#") or ":" not in line: if not line or line.startswith("#"):
continue continue
if ":" not in line:
raise SystemExit(f"Invalid data file syntax in {path} line {line_no}: every entry must be key: value")
key, value = line.split(":", 1) key, value = line.split(":", 1)
key = key.strip() key = key.strip()
value = value.strip() value = value.strip()