Folders tagged with a bare IMDb id in brackets (Plex/Kodi style, e.g. '17 Blocks (2021) [tt10011226]') had the id silently dropped — folderIDPattern needs an 'imdb-' prefix and trailingImdbIDPattern needs an un-bracketed trailing tt-id. Recognize bracketed bare tt-ids so these items get the trusted-ID match path instead of falling to title+year scoring.
30 lines
1.0 KiB
Go
30 lines
1.0 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, "movie")
|
|
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]", "movie"); got == nil || got.ImdbID != "tt1375666" {
|
|
t.Errorf("structured imdb regressed: %+v", got)
|
|
}
|
|
if got := ParseFolderIDs("Some Movie (2020) [BB]", "movie"); got != nil {
|
|
t.Errorf("non-tt bracket tag must not parse as id, got %+v", got)
|
|
}
|
|
if got := ParseFolderIDs("17 Blocks (2021)", "movie"); got != nil {
|
|
t.Errorf("no-id folder must return nil, got %+v", got)
|
|
}
|
|
}
|