support library scoping on more Jellyfin browsing operations
This commit is contained in:
@@ -54,6 +54,7 @@ func (j *jellyfinMediaProvider) IterateArtists(sortOrder string, filter mediapro
|
||||
return j.client.GetAlbumArtists(jellyfin.QueryOpts{
|
||||
Sort: jfSort,
|
||||
Paging: paging,
|
||||
Filter: jellyfin.Filter{ParentID: j.currentLibraryID},
|
||||
})
|
||||
},
|
||||
sortFn,
|
||||
|
||||
@@ -77,7 +77,10 @@ func (j *jellyfinMediaProvider) IterateAlbums(sortOrder string, filter mediaprov
|
||||
|
||||
func (j *jellyfinMediaProvider) SearchAlbums(searchQuery string, filter mediaprovider.AlbumFilter) mediaprovider.AlbumIterator {
|
||||
fetcher := func(offs, limit int) ([]*mediaprovider.Album, error) {
|
||||
sr, err := j.client.Search(searchQuery, jellyfin.TypeAlbum, jellyfin.Paging{StartIndex: offs, Limit: limit})
|
||||
var opts jellyfin.QueryOpts
|
||||
opts.Paging = jellyfin.Paging{StartIndex: offs, Limit: limit}
|
||||
opts.Filter.ParentID = j.currentLibraryID
|
||||
sr, err := j.client.Search(searchQuery, jellyfin.TypeAlbum, opts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -103,7 +106,10 @@ func (j *jellyfinMediaProvider) IterateTracks(searchQuery string) mediaprovider.
|
||||
}
|
||||
} else {
|
||||
fetcher = func(offs, limit int) ([]*mediaprovider.Track, error) {
|
||||
sr, err := j.client.Search(searchQuery, jellyfin.TypeSong, jellyfin.Paging{StartIndex: offs, Limit: limit})
|
||||
var opts jellyfin.QueryOpts
|
||||
opts.Paging = jellyfin.Paging{StartIndex: offs, Limit: limit}
|
||||
opts.Filter.ParentID = j.currentLibraryID
|
||||
sr, err := j.client.Search(searchQuery, jellyfin.TypeSong, opts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -73,6 +73,7 @@ func (j *jellyfinMediaProvider) GetLibraries() ([]mediaprovider.Library, error)
|
||||
|
||||
func (j *jellyfinMediaProvider) SetLibrary(id string) error {
|
||||
j.currentLibraryID = id
|
||||
j.genresCached = nil
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -235,15 +236,16 @@ func (j *jellyfinMediaProvider) GetCoverArt(id string, size int) (image.Image, e
|
||||
return j.client.GetItemImage(id, "Primary", size, 92)
|
||||
}
|
||||
|
||||
func (s *jellyfinMediaProvider) GetFavorites() (mediaprovider.Favorites, error) {
|
||||
func (j *jellyfinMediaProvider) GetFavorites() (mediaprovider.Favorites, error) {
|
||||
var wg sync.WaitGroup
|
||||
var favorites mediaprovider.Favorites
|
||||
|
||||
var opts jellyfin.QueryOpts
|
||||
opts.Filter.Favorite = true
|
||||
opts.Filter.ParentID = j.currentLibraryID
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
var opts jellyfin.QueryOpts
|
||||
opts.Filter.Favorite = true
|
||||
al, err := s.client.GetAlbums(opts)
|
||||
al, err := j.client.GetAlbums(opts)
|
||||
if err == nil && len(al) > 0 {
|
||||
favorites.Albums = sharedutil.MapSlice(al, toAlbum)
|
||||
}
|
||||
@@ -252,9 +254,7 @@ func (s *jellyfinMediaProvider) GetFavorites() (mediaprovider.Favorites, error)
|
||||
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
var opts jellyfin.QueryOpts
|
||||
opts.Filter.Favorite = true
|
||||
ar, err := s.client.GetAlbumArtists(opts)
|
||||
ar, err := j.client.GetAlbumArtists(opts)
|
||||
if err == nil && len(ar) > 0 {
|
||||
favorites.Artists = sharedutil.MapSlice(ar, toArtist)
|
||||
}
|
||||
@@ -263,9 +263,7 @@ func (s *jellyfinMediaProvider) GetFavorites() (mediaprovider.Favorites, error)
|
||||
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
var opts jellyfin.QueryOpts
|
||||
opts.Filter.Favorite = true
|
||||
tr, err := s.client.GetSongs(opts)
|
||||
tr, err := j.client.GetSongs(opts)
|
||||
if err == nil && len(tr) > 0 {
|
||||
favorites.Tracks = sharedutil.MapSlice(tr, toTrack)
|
||||
}
|
||||
@@ -281,7 +279,7 @@ func (j *jellyfinMediaProvider) GetGenres() ([]*mediaprovider.Genre, error) {
|
||||
return j.genresCached, nil
|
||||
}
|
||||
|
||||
g, err := j.client.GetGenres(jellyfin.Paging{}, "")
|
||||
g, err := j.client.GetGenres(jellyfin.Paging{}, j.currentLibraryID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -20,21 +20,24 @@ func (j *jellyfinMediaProvider) SearchAll(searchQuery string, maxResults int) ([
|
||||
var genres []jellyfin.NameID
|
||||
var playlists []*jellyfin.Playlist
|
||||
|
||||
var opts jellyfin.QueryOpts
|
||||
opts.Paging.Limit = limit
|
||||
opts.Filter.ParentID = j.currentLibraryID
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
albumResult, _ := j.client.Search(searchQuery, jellyfin.TypeAlbum, jellyfin.Paging{Limit: limit})
|
||||
albumResult, _ := j.client.Search(searchQuery, jellyfin.TypeAlbum, opts)
|
||||
albums = albumResult.Albums
|
||||
wg.Done()
|
||||
}()
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
artistResult, _ := j.client.Search(searchQuery, jellyfin.TypeArtist, jellyfin.Paging{Limit: limit})
|
||||
artistResult, _ := j.client.Search(searchQuery, jellyfin.TypeArtist, opts)
|
||||
artists = artistResult.Artists
|
||||
wg.Done()
|
||||
}()
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
songResult, _ := j.client.Search(searchQuery, jellyfin.TypeSong, jellyfin.Paging{Limit: limit})
|
||||
songResult, _ := j.client.Search(searchQuery, jellyfin.TypeSong, opts)
|
||||
songs = songResult.Songs
|
||||
wg.Done()
|
||||
}()
|
||||
|
||||
@@ -10,7 +10,7 @@ require (
|
||||
github.com/deluan/sanitize v0.0.0-20230310221930-6e18967d9fc1
|
||||
github.com/dweymouth/fyne-advanced-list v0.0.0-20250211191927-58ea85eec72c
|
||||
github.com/dweymouth/fyne-tooltip v0.3.0
|
||||
github.com/dweymouth/go-jellyfin v0.0.0-20250715154414-d0a1630ee74f
|
||||
github.com/dweymouth/go-jellyfin v0.0.0-20250716005557-0ea2becece1f
|
||||
github.com/godbus/dbus/v5 v5.1.0
|
||||
github.com/google/uuid v1.3.0
|
||||
github.com/hashicorp/go-retryablehttp v0.7.7
|
||||
|
||||
@@ -27,6 +27,8 @@ github.com/dweymouth/go-jellyfin v0.0.0-20250531151636-29591764f0a0 h1:9t1CR83uz
|
||||
github.com/dweymouth/go-jellyfin v0.0.0-20250531151636-29591764f0a0/go.mod h1:fcUagHBaQnt06GmBAllNE0J4O/7064zXRWdqnTTtVjI=
|
||||
github.com/dweymouth/go-jellyfin v0.0.0-20250715154414-d0a1630ee74f h1:7O7Cn17pwKHG7zPgNhxMabXJP1ZdmNVxCb4i8yJgVZo=
|
||||
github.com/dweymouth/go-jellyfin v0.0.0-20250715154414-d0a1630ee74f/go.mod h1:fcUagHBaQnt06GmBAllNE0J4O/7064zXRWdqnTTtVjI=
|
||||
github.com/dweymouth/go-jellyfin v0.0.0-20250716005557-0ea2becece1f h1:QsKPwFpTHuYHEEuhvp4VBClkHh00bNNgQ/2Ij1bkk8M=
|
||||
github.com/dweymouth/go-jellyfin v0.0.0-20250716005557-0ea2becece1f/go.mod h1:fcUagHBaQnt06GmBAllNE0J4O/7064zXRWdqnTTtVjI=
|
||||
github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
|
||||
github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE=
|
||||
github.com/felixge/fgprof v0.9.3 h1:VvyZxILNuCiUCSXtPtYmmtGvb65nqXh2QFWc0Wpf2/g=
|
||||
|
||||
Reference in New Issue
Block a user