diff --git a/movmaker.py b/movmaker.py index 347f082..ee65fc8 100755 --- a/movmaker.py +++ b/movmaker.py @@ -523,9 +523,13 @@ def parse_data_file(path: Path | None) -> MovieData: return MovieData(captions={}) data = MovieData(captions={}) - for line_no, raw in enumerate(path.read_text(encoding="utf-8", errors="replace").splitlines(), start=1): - line = raw.strip() + lines = path.read_text(encoding="utf-8", errors="replace").splitlines() + i = 0 + while i < len(lines): + line_no = i + 1 + line = lines[i].strip() if not line or line.startswith("#"): + i += 1 continue if ":" not in line: raise SystemExit(f"Invalid data file syntax in {path} line {line_no}: every entry must be key: value") @@ -533,6 +537,21 @@ def parse_data_file(path: Path | None) -> MovieData: key = key.strip() value = value.strip() low = key.lower() + if value == "|" and low in {"description", "desc", "synopsis"}: + block: list[str] = [] + i += 1 + while i < len(lines): + raw = lines[i] + if raw.strip() and not raw.startswith((" ", "\t")): + break + if raw.startswith(" "): + raw = raw[2:] + elif raw.startswith((" ", "\t")): + raw = raw[1:] + block.append(raw.rstrip()) + i += 1 + data.description = "\n".join(block).strip() + continue if low in {"title", "name"}: data.title = value elif low in {"date", "dates", "when"}: @@ -543,6 +562,7 @@ def parse_data_file(path: Path | None) -> MovieData: data.description = value elif key: data.captions[key] = value + i += 1 return data