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:
co-authored by
Claude Opus 4.7
parent
5f1ca3f825
commit
fab95e291f
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user