Skip to content

Commit 65c8af1

Browse files
committed
fix(library): accept artist section types
1 parent 7e23b8d commit 65c8af1

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

‎internal/cmd/library_helpers_test.go‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,31 @@ func TestSectionTypeIDForLibrary(t *testing.T) {
114114
}
115115
}
116116

117+
func TestSectionTypeIDForLibraryMapsArtistSectionsToMusicType(t *testing.T) {
118+
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
119+
if r.URL.Path != "/library/sections" {
120+
http.NotFound(w, r)
121+
return
122+
}
123+
w.Header().Set("Content-Type", "application/xml")
124+
_, _ = w.Write([]byte(`<?xml version="1.0" encoding="UTF-8"?><MediaContainer><Directory key="7" title="Audiobooks" type="artist" /></MediaContainer>`))
125+
}))
126+
defer server.Close()
127+
128+
client, err := plexclient.NewClient(server.URL, "token")
129+
if err != nil {
130+
t.Fatalf("NewClient() error = %v", err)
131+
}
132+
133+
sectionTypeID, err := sectionTypeIDForLibrary(context.Background(), client, "7")
134+
if err != nil {
135+
t.Fatalf("sectionTypeIDForLibrary() error = %v", err)
136+
}
137+
if sectionTypeID != 8 {
138+
t.Fatalf("expected artist section to map to music type ID 8, got %d", sectionTypeID)
139+
}
140+
}
141+
117142
func TestSectionTypeIDForLibraryFailsForUnknownSection(t *testing.T) {
118143
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
119144
if r.URL.Path != "/library/sections" {

‎internal/cmd/library_sections.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ func librarySectionTypeIDValue(value string) (int64, bool) {
333333
return 1, true
334334
case "show":
335335
return 2, true
336-
case "music":
336+
case "music", "artist":
337337
return 8, true
338338
case "photo":
339339
return 13, true

0 commit comments

Comments
 (0)