Expanded scripting/naming helpers: pad, sort_name/sort_initial, upper/lower_initial, acronym, validate_file_name, space/space_with, colon/colon_with
Ports the next slice of FileBot's ExpressionFormatMethods.java as Rhai-callable
methods usable inside any { } naming-scheme expression, alongside the existing
any/all_of/concat helpers:
- pad/pad_with: left-pad a value's string form (default '0'), non-mutating,
non-truncating - deliberately a different Rhai method name for the 3-arg
custom-char form (pad_with) since Rhai's own built-in pad(length, char)
right-pads and mutates in place, which collides in behavior (not API) with
what FileBot's zero-padded season/episode numbers need.
- sort_name/sort_initial: move a leading The/A/An article to the end for
alphabetical sorting, e.g. "The Office" -> "Office, The".
- upper_initial/lower_initial: case-convert only the first character.
- acronym: first letter of each word, uppercased.
- validate_file_name: strip characters illegal in filenames, collapse
whitespace runs, trim trailing dots.
- space/space_with, colon/colon_with: separator and colon normalization.
16 new unit tests in functions.rs (143 lib tests total, up from 126) plus 3
new integration tests in expression_format.rs demonstrating the helpers used
inside real naming-scheme expressions (14 total, up from 11). Verified via
cargo test --workspace, cargo check --workspace, and npm run build, all
clean. Updated README (status paragraph and porting-roadmap item 2).
This commit is contained in:
@@ -64,7 +64,12 @@ file via a native Save dialog — this closes out the full original panel set (R
|
||||
Episodes/Subtitles/SFV/Filter/List); see "List" below. Real media-file probing (real
|
||||
resolution, frame rate, duration, and codecs read straight from a video file's own
|
||||
container header, not guessed from its filename) is wired into the Rename panel's
|
||||
"Match" step — see "Real media-file probing" below. See "Porting roadmap" below.
|
||||
"Match" step — see "Real media-file probing" below. The naming-expression engine's Rhai
|
||||
scripting layer also gained a batch of FileBot-style string helpers — `.pad()`,
|
||||
`.sort_name()`/`.sort_initial()`, `.upper_initial()`/`.lower_initial()`, `.acronym()`,
|
||||
`.validate_file_name()`, `.space()`/`.space_with()`, `.colon()`/`.colon_with()` — callable
|
||||
inside any `{ }` naming-scheme expression, e.g. `{n.sort_name()}/S{s.pad(2)}E{e.pad(2)}`;
|
||||
see "Porting roadmap" below.
|
||||
|
||||
The naming scheme is fully user-editable from the app (the "Naming Scheme" button next
|
||||
to the New Names list) — the default is `{show name} - {season number}x{episode
|
||||
@@ -593,9 +598,18 @@ ported from, for anyone picking this up:
|
||||
wiring probed bindings into the List/Filter panels (currently Rename-panel-only).
|
||||
2. **String/expression helper methods** — `net.filebot.format.ExpressionFormatMethods`
|
||||
(636 lines): FileBot-specific Groovy string extensions like `.pad()`, `.sortName()`.
|
||||
Only a small subset (`any`, `all_of`, `concat`) is ported so far
|
||||
(`crates/aurora-curator-core/src/format/functions.rs`); Rhai's built-ins cover some of the
|
||||
rest already.
|
||||
Ported so far (`crates/aurora-curator-core/src/format/functions.rs`): `any`, `all_of`,
|
||||
`concat`, plus a newer batch of naming/scripting helpers — `pad`/`pad_with`
|
||||
(left-pad, non-mutating; note this is a deliberately different name collision-avoidance
|
||||
from Rhai's own built-in `pad(length, char)`, which right-pads and mutates in place —
|
||||
not a fit for FileBot's zero-padded season/episode numbers), `sort_name`/`sort_initial`
|
||||
(moves a leading "The"/"A"/"An" article to the end, e.g. `{n.sort_name()}` turns
|
||||
`"The Office"` into `"Office, The"`), `upper_initial`/`lower_initial`, `acronym`,
|
||||
`validate_file_name` (strips characters illegal in filenames, collapses whitespace,
|
||||
trims trailing dots), and `space`/`space_with`/`colon`/`colon_with` (separator/colon
|
||||
normalization). Rhai's built-ins cover some of the rest already. Still not ported:
|
||||
FileBot's CSV/file-reading and shell-quoting helpers (`csv`, `read_lines`,
|
||||
`quote_bash`, `quote_powershell`, etc.).
|
||||
3. **Matching/similarity engine** — `net.filebot.similarity.*`. Local filename-based
|
||||
season/episode detection is done (`crates/aurora-curator-core/src/matching`, ported from the
|
||||
pattern-matching half of `SeasonEpisodeMatcher.java`, adapted to Rust's `regex` crate
|
||||
|
||||
Reference in New Issue
Block a user