fix(scanner): split comma-joined ABS sidecar genres into separate tags
Audiobookshelf-style exports join genres into one comma-string
(["Epic, Action & Adventure, Military, Sword & Sorcery"]). The
smart-genre picker already split candidates for the genre column,
but the tags assembly used the raw unsplit array — so the whole
string landed as ONE element of media_items.tags and rendered as a
single tag everywhere.
Use pickSmartGenre's split candidates for tags too, exactly as the
function's own comment documents ('split parts included stay in
tags'). Commas inside a single subject heading remain legal within
one tag (EPUB dc:subject path unchanged).
This commit is contained in:
1 parent
ecfd7276ab
commit
ab2a5568ae
2 files changed
+34
-3
No files matched your search
@@ -8,6 +8,7 @@ import (
|
||||
"image/jpeg"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
@@ -196,6 +197,30 @@ func TestExtractAudiobookshelfSidecar(t *testing.T) {
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "joined genre string splits into separate tags (ABS export)",
|
||||
json: `{"title": "Joined Genres", "genres": ["Epic, Action & Adventure, Military, Sword & Sorcery"]}`,
|
||||
validate: func(t *testing.T, m *MediaMetadata) {
|
||||
want := []string{"Epic", "Action & Adventure", "Military", "Sword & Sorcery"}
|
||||
if len(m.Tags) != len(want) {
|
||||
t.Fatalf("Tags = %v, want %v", m.Tags, want)
|
||||
}
|
||||
for i, w := range want {
|
||||
if m.Tags[i] != w {
|
||||
t.Errorf("Tags[%d] = %q, want %q", i, m.Tags[i], w)
|
||||
}
|
||||
}
|
||||
inGenre := false
|
||||
for _, w := range want {
|
||||
if strings.EqualFold(m.Genre, w) {
|
||||
inGenre = true
|
||||
}
|
||||
}
|
||||
if !inGenre || m.Genre == "" {
|
||||
t.Errorf("Genre = %q, want a case-insensitive match of %v", m.Genre, want)
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "sparse sidecar (real-world Audiobookshelf export)",
|
||||
json: `{"title": "Sparse (1234)", "authors": ["X"], "tags": [], "description": null}`,
|
||||
|
||||
Reference in new issue
Block a user