feat(audiobooks): library-type recognizers for scanner dispatch

isAudiobookLibraryType and isPodcastLibraryType match singular and
plural forms case-insensitively, mirroring isMovieLibraryType. Used by
upcoming scanner walk branches (Task 4) that filter audio files into
audiobook and podcast libraries.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
RXWatcher
2026-05-24 13:50:46 +02:00
co-authored by Claude Opus 4.7
parent 5f1ca3f825
commit fab95e291f
2 changed files with 56 additions and 0 deletions
+16
View File
@@ -215,6 +215,22 @@ func isMovieLibraryType(libraryType string) bool {
return false
}
}
func isAudiobookLibraryType(libraryType string) bool {
switch strings.ToLower(strings.TrimSpace(libraryType)) {
case "audiobook", "audiobooks":
return true
default:
return false
}
}
func isPodcastLibraryType(libraryType string) bool {
switch strings.ToLower(strings.TrimSpace(libraryType)) {
case "podcast", "podcasts":
return true
default:
return false
}
}
func canonicalWalkPath(path string) (string, error) {
resolved, err := filepath.EvalSymlinks(path)
+40
View File
@@ -129,3 +129,43 @@ func testStringSliceContains(values []string, target string) bool {
}
return false
}
func TestIsAudiobookLibraryType(t *testing.T) {
cases := []struct {
in string
want bool
}{
{"audiobooks", true},
{"audiobook", true},
{"Audiobook", true},
{" AUDIOBOOKS ", true},
{"movies", false},
{"series", false},
{"", false},
}
for _, tc := range cases {
if got := isAudiobookLibraryType(tc.in); got != tc.want {
t.Errorf("isAudiobookLibraryType(%q) = %v, want %v", tc.in, got, tc.want)
}
}
}
func TestIsPodcastLibraryType(t *testing.T) {
cases := []struct {
in string
want bool
}{
{"podcasts", true},
{"podcast", true},
{"Podcast", true},
{" PODCASTS ", true},
{"series", false},
{"audiobooks", false},
{"", false},
}
for _, tc := range cases {
if got := isPodcastLibraryType(tc.in); got != tc.want {
t.Errorf("isPodcastLibraryType(%q) = %v, want %v", tc.in, got, tc.want)
}
}
}