feat(domain): naming template engine (Jinja safe subset, MP variables, path layout)

- naming/engine: lexer/parser/AST/render for {{ }} / if-elif-else / whitelisted filters
  (default pad pad2 upper lower trim replace truncate date join); rejects for/set/attribute/
  subscript/call/~/% with line:col errors and 'did you mean' hints
- naming/variables: variable table aligned with MoviePilot names plus ours (cut, airDate,
  issue, slotName, libraryRoot ...); buildNamingVars from parsed release + entity + units
- naming/layout: split by literal '/', segment roles (category/root/season/sub/file),
  value escaping, reserved names, 255-byte segments, validateNamingTemplate
- naming/defaults: MP default movie/tv + our variety template, v1 syntax upgrade,
  entity > root > global override resolution, builtin preview samples
- path/binding: resolveTargetDirectory keeps bound dirs, only unbound segments render;
  renderMediaFileName = last segment of the full template; DEFAULT_TEMPLATES = MP v2
- differential: 34 cases vs MP (21 identical, 13 documented deviations)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
rootandClaude Opus 5.5 committed 2026-09-28 15:24:32 +08:00
1 parent e8745115f4
commit f7c75ad781
22 files changed
+2674 -281

No files matched your search

+3 -2
View File
@@ -1,3 +1,4 @@
import type { NamingEntityInput } from "../naming/variables.ts";
import { DEFAULT_TEMPLATES, type NamingTemplateSet, renderMediaFileName } from "../path/binding.ts";
import { buildNamingContext } from "../path/template.ts";
import { type ParseOptions, parseReleasePath } from "../release-parser/index.ts";
@@ -38,8 +39,8 @@ export interface OrganizeInput {
/** 种子内容根(整季包目录);只在它之内取父目录名参与解析 */
sourceRoot?: string;
files: readonly SourceFile[];
/** 本地实体的命名信息(不用发布标题命名) */
entity: { title: string; originalTitle?: string; year?: number };
/** 本地实体的命名信息(不用发布标题命名;可带英文名/外部 ID/季集元数据等命名变量来源) */
entity: NamingEntityInput;
/** 目标目录(宿主绝对路径,来自 path.resolveTargetDirectory + 库根) */
target: { movieDir?: string; seasonDirs?: Record<number, string>; device?: string | number };
templates?: NamingTemplateSet;