@@ -44,6 +44,8 @@ type jellyfinMediaProvider struct {
4444 client * jellyfin.Client
4545 prefetchCoverCB func (coverArtID string )
4646
47+ currentLibraryID string
48+
4749 genresCached []* mediaprovider.Genre
4850 genresCachedAt int64 // unix
4951}
@@ -60,10 +62,17 @@ func (j *jellyfinMediaProvider) SetPrefetchCoverCallback(cb func(coverArtID stri
6062}
6163
6264func (j * jellyfinMediaProvider ) GetLibraries () ([]mediaprovider.Library , error ) {
63- return nil , nil
65+ v , err := j .client .GetUserViews ()
66+ if err != nil {
67+ return nil , err
68+ }
69+ return sharedutil .FilterMapSlice (v , func (v * jellyfin.BaseItem ) (mediaprovider.Library , bool ) {
70+ return mediaprovider.Library {Name : v .Name , ID : v .ID }, v .CollectionType == string (jellyfin .CollectionTypeMusic )
71+ }), nil
6472}
6573
66- func (j * jellyfinMediaProvider ) SetLibrary (string ) error {
74+ func (j * jellyfinMediaProvider ) SetLibrary (id string ) error {
75+ j .currentLibraryID = id
6776 return nil
6877}
6978
@@ -186,6 +195,9 @@ func (j *jellyfinMediaProvider) GetTopTracks(artist mediaprovider.Artist, limit
186195 opts .Filter .ArtistID = artist .ID
187196 opts .Sort .Field = jellyfin .SortByCommunityRating
188197 opts .Sort .Mode = jellyfin .SortDesc
198+ if j .currentLibraryID != "" {
199+ opts .Filter .ParentID = j .currentLibraryID
200+ }
189201 tr , err := j .client .GetSongs (opts )
190202 if err != nil {
191203 return nil , err
@@ -201,6 +213,9 @@ func (j *jellyfinMediaProvider) GetRandomTracks(genreName string, limit int) ([]
201213 opts .Paging .Limit = limit
202214 opts .Filter .Genres = []string {genreName }
203215 opts .Sort .Field = jellyfin .SortByRandom
216+ if j .currentLibraryID != "" {
217+ opts .Filter .ParentID = j .currentLibraryID
218+ }
204219 tr , err := j .client .GetSongs (opts )
205220 if err != nil {
206221 return nil , err
@@ -266,7 +281,7 @@ func (j *jellyfinMediaProvider) GetGenres() ([]*mediaprovider.Genre, error) {
266281 return j .genresCached , nil
267282 }
268283
269- g , err := j .client .GetGenres (jellyfin.Paging {})
284+ g , err := j .client .GetGenres (jellyfin.Paging {}, "" )
270285 if err != nil {
271286 return nil , err
272287 }
0 commit comments