Files
silo-server/internal/naming/folderid_test.go
T
75b476d124 fix(naming,metadata): anchor identity on provider IDs, drop bare-numeric IDs, back off match queue retries (#112)
* fix(naming,metadata): anchor identity on provider IDs, drop bare-numeric IDs, back off match queue retries

Three scanner/matching fixes validated against dev data:

- Group identity: explicit structured provider tags ({tmdb-...},
  [tvdbid-...]) now anchor a group's identity, so folder/file title
  conflicts (renamed releases in Radarr-tagged folders) no longer mark
  groups ambiguous and silently exclude them from matching. 3,049 of
  3,121 ambiguous groups on dev carried explicit tags.

- ParseFolderIDs: remove bare trailing numeric ID parsing entirely,
  mirroring Jellyfin's path-attribute model (bracketed key tags plus
  unambiguous tt-prefixed IMDb ids only). Titles ending in numbers
  ("District 9", "Beverly Hills 90210", "Season 01") were misparsed as
  trusted IDs, which suppresses title search and silently mismatches.
  The folderType parameter existed only to type bare numerics, so it
  is gone too.

- Match queues: replace the constant 15s/30s retry delay with shared
  exponential backoff capped at 24h. Terminal failures ("no metadata
  found from any provider") had rows at 15k+ attempts hot-looping
  every 15s on dev.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(naming): merge trailing bare IMDb id with structured folder tags

ParseFolderIDs returned early on any structured tag, so a folder like
"Show [tvdbid-81189] tt1375666" lost the trailing IMDb id. Parse both and
merge, with an explicit structured imdb tag still taking precedence over a
trailing bare id. Matches Jellyfin, which resolves each provider key
independently.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-06-09 16:38:20 -04:00

47 lines
1.6 KiB
Go

package naming
import "testing"
func TestParseFolderIDs_BracketedBareImdb(t *testing.T) {
cases := []struct {
name, folder, wantImdb string
}{
{"square brackets", "17 Blocks (2021) [tt10011226]", "tt10011226"},
{"curly braces", "Some Show {tt1234567}", "tt1234567"},
{"8-digit tt", "Movie (2024) [tt12345678]", "tt12345678"},
}
for _, c := range cases {
got := ParseFolderIDs(c.folder)
if got == nil || got.ImdbID != c.wantImdb {
t.Errorf("%s: ParseFolderIDs(%q) = %+v, want ImdbID=%q", c.name, c.folder, got, c.wantImdb)
}
}
// must NOT change existing behavior:
if got := ParseFolderIDs("Movie [imdb-tt1375666]"); got == nil || got.ImdbID != "tt1375666" {
t.Errorf("structured imdb regressed: %+v", got)
}
if got := ParseFolderIDs("Some Movie (2020) [BB]"); got != nil {
t.Errorf("non-tt bracket tag must not parse as id, got %+v", got)
}
if got := ParseFolderIDs("17 Blocks (2021)"); got != nil {
t.Errorf("no-id folder must return nil, got %+v", got)
}
}
func TestParseStructuredFolderIDs_BracketedBareImdb(t *testing.T) {
got := ParseStructuredFolderIDs("17 Blocks (2021) [tt10011226]")
if got == nil || got.ImdbID != "tt10011226" {
t.Fatalf("ParseStructuredFolderIDs bare imdb = %+v, want ImdbID tt10011226", got)
}
got = ParseStructuredFolderIDs("Some Movie {tmdb-12345} [tt7654321]")
if got == nil || got.TmdbID != "12345" || got.ImdbID != "tt7654321" {
t.Fatalf("ParseStructuredFolderIDs mixed ids = %+v, want tmdb+imdb", got)
}
got = ParseStructuredFolderIDs("Some Movie [imdb-tt1375666] [tt7654321]")
if got == nil || got.ImdbID != "tt1375666" {
t.Fatalf("structured imdb should win over bare imdb, got %+v", got)
}
}