From 984b53c6f1753ae1f1b118db6b8d99ee2d4a5c00 Mon Sep 17 00:00:00 2001 From: bel Date: Sat, 5 Apr 2025 00:55:26 -0600 Subject: [PATCH] overrides win --- main.go | 12 +++++++++++- main_test.go | 7 ++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index aaa8b58..daafb44 100644 --- a/main.go +++ b/main.go @@ -156,7 +156,7 @@ func one(ctx context.Context, outd, inf string, patterns []string, overrides Fie continue } - found := overrides + var found Fields groupNames := re.SubexpNames() groups := re.FindStringSubmatch(f) for i := 1; i < len(groupNames); i++ { @@ -173,6 +173,16 @@ func one(ctx context.Context, outd, inf string, patterns []string, overrides Fie } } + for _, wr := range [][2]*string{ + [2]*string{&found.Title, &overrides.Title}, + [2]*string{&found.Season, &overrides.Season}, + [2]*string{&found.Episode, &overrides.Episode}, + } { + if *wr[1] != "" { + *wr[0] = *wr[1] + } + } + if found.Title == "" || found.Season == "" || found.Episode == "" { continue } diff --git a/main_test.go b/main_test.go index 2bb63e2..893a663 100644 --- a/main_test.go +++ b/main_test.go @@ -168,10 +168,11 @@ func TestRecursive(t *testing.T) { }`) write("./showA/file.a") - // parse files + // parse files and const wins write("./showB/.show-ingestion.yaml", `{ "o": "`+outd+`/B_{{.Title}}_{{.Season}}_{{.Episode}}", - "p": [] + "p": [], + "c": {"title": "TITLE"} }`) write("./showB/title S01E02.b") @@ -198,7 +199,7 @@ func TestRecursive(t *testing.T) { } exists(t, path.Join(outd, "A", "A_SAEA.a")) - exists(t, path.Join(outd, "B_title_01_02", "title_S01E02.b")) + exists(t, path.Join(outd, "B_TITLE_01_02", "TITLE_S01E02.b")) exists(t, path.Join(outd, "C", "t_SsEe.c")) notExists(t, path.Join(outd, "D", "title_S02E04.d")) notExists(t, path.Join(outd, "title_S03E06.e"))