WIP - Jellyfin multi library
This commit is contained in:
@@ -42,6 +42,9 @@ func (j *jellyfinMediaProvider) IterateAlbums(sortOrder string, filter mediaprov
|
|||||||
jfSort.Mode = jellyfin.SortDesc
|
jfSort.Mode = jellyfin.SortDesc
|
||||||
}
|
}
|
||||||
jfFilt, modifiedFilter := jfFilterFromFilter(filter)
|
jfFilt, modifiedFilter := jfFilterFromFilter(filter)
|
||||||
|
if j.currentLibraryID != "" {
|
||||||
|
jfFilt.ParentID = j.currentLibraryID
|
||||||
|
}
|
||||||
|
|
||||||
fetcher := func(offs, limit int) ([]*mediaprovider.Album, error) {
|
fetcher := func(offs, limit int) ([]*mediaprovider.Album, error) {
|
||||||
al, err := j.client.GetAlbums(jellyfin.QueryOpts{
|
al, err := j.client.GetAlbums(jellyfin.QueryOpts{
|
||||||
@@ -89,6 +92,9 @@ func (j *jellyfinMediaProvider) IterateTracks(searchQuery string) mediaprovider.
|
|||||||
fetcher = func(offs, limit int) ([]*mediaprovider.Track, error) {
|
fetcher = func(offs, limit int) ([]*mediaprovider.Track, error) {
|
||||||
var opts jellyfin.QueryOpts
|
var opts jellyfin.QueryOpts
|
||||||
opts.Paging = jellyfin.Paging{StartIndex: offs, Limit: limit}
|
opts.Paging = jellyfin.Paging{StartIndex: offs, Limit: limit}
|
||||||
|
if j.currentLibraryID != "" {
|
||||||
|
opts.Filter.ParentID = j.currentLibraryID
|
||||||
|
}
|
||||||
s, err := j.client.GetSongs(opts)
|
s, err := j.client.GetSongs(opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -44,6 +44,8 @@ type jellyfinMediaProvider struct {
|
|||||||
client *jellyfin.Client
|
client *jellyfin.Client
|
||||||
prefetchCoverCB func(coverArtID string)
|
prefetchCoverCB func(coverArtID string)
|
||||||
|
|
||||||
|
currentLibraryID string
|
||||||
|
|
||||||
genresCached []*mediaprovider.Genre
|
genresCached []*mediaprovider.Genre
|
||||||
genresCachedAt int64 // unix
|
genresCachedAt int64 // unix
|
||||||
}
|
}
|
||||||
@@ -60,10 +62,17 @@ func (j *jellyfinMediaProvider) SetPrefetchCoverCallback(cb func(coverArtID stri
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (j *jellyfinMediaProvider) GetLibraries() ([]mediaprovider.Library, error) {
|
func (j *jellyfinMediaProvider) GetLibraries() ([]mediaprovider.Library, error) {
|
||||||
return nil, nil
|
v, err := j.client.GetUserViews()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return sharedutil.FilterMapSlice(v, func(v *jellyfin.BaseItem) (mediaprovider.Library, bool) {
|
||||||
|
return mediaprovider.Library{Name: v.Name, ID: v.ID}, v.CollectionType == string(jellyfin.CollectionTypeMusic)
|
||||||
|
}), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (j *jellyfinMediaProvider) SetLibrary(string) error {
|
func (j *jellyfinMediaProvider) SetLibrary(id string) error {
|
||||||
|
j.currentLibraryID = id
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,6 +195,9 @@ func (j *jellyfinMediaProvider) GetTopTracks(artist mediaprovider.Artist, limit
|
|||||||
opts.Filter.ArtistID = artist.ID
|
opts.Filter.ArtistID = artist.ID
|
||||||
opts.Sort.Field = jellyfin.SortByCommunityRating
|
opts.Sort.Field = jellyfin.SortByCommunityRating
|
||||||
opts.Sort.Mode = jellyfin.SortDesc
|
opts.Sort.Mode = jellyfin.SortDesc
|
||||||
|
if j.currentLibraryID != "" {
|
||||||
|
opts.Filter.ParentID = j.currentLibraryID
|
||||||
|
}
|
||||||
tr, err := j.client.GetSongs(opts)
|
tr, err := j.client.GetSongs(opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -201,6 +213,9 @@ func (j *jellyfinMediaProvider) GetRandomTracks(genreName string, limit int) ([]
|
|||||||
opts.Paging.Limit = limit
|
opts.Paging.Limit = limit
|
||||||
opts.Filter.Genres = []string{genreName}
|
opts.Filter.Genres = []string{genreName}
|
||||||
opts.Sort.Field = jellyfin.SortByRandom
|
opts.Sort.Field = jellyfin.SortByRandom
|
||||||
|
if j.currentLibraryID != "" {
|
||||||
|
opts.Filter.ParentID = j.currentLibraryID
|
||||||
|
}
|
||||||
tr, err := j.client.GetSongs(opts)
|
tr, err := j.client.GetSongs(opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -266,7 +281,7 @@ func (j *jellyfinMediaProvider) GetGenres() ([]*mediaprovider.Genre, error) {
|
|||||||
return j.genresCached, nil
|
return j.genresCached, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
g, err := j.client.GetGenres(jellyfin.Paging{})
|
g, err := j.client.GetGenres(jellyfin.Paging{}, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ func (j *jellyfinMediaProvider) SearchAll(searchQuery string, maxResults int) ([
|
|||||||
|
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
g, e := j.client.GetGenres(jellyfin.Paging{})
|
g, e := j.client.GetGenres(jellyfin.Paging{}, "")
|
||||||
if e == nil {
|
if e == nil {
|
||||||
genres = sharedutil.FilterSlice(g, func(g jellyfin.NameID) bool {
|
genres = sharedutil.FilterSlice(g, func(g jellyfin.NameID) bool {
|
||||||
return helpers.AllTermsMatch(strings.ToLower(sanitize.Accents(g.Name)), queryLowerWords)
|
return helpers.AllTermsMatch(strings.ToLower(sanitize.Accents(g.Name)), queryLowerWords)
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ require (
|
|||||||
github.com/deluan/sanitize v0.0.0-20230310221930-6e18967d9fc1
|
github.com/deluan/sanitize v0.0.0-20230310221930-6e18967d9fc1
|
||||||
github.com/dweymouth/fyne-advanced-list v0.0.0-20250211191927-58ea85eec72c
|
github.com/dweymouth/fyne-advanced-list v0.0.0-20250211191927-58ea85eec72c
|
||||||
github.com/dweymouth/fyne-tooltip v0.3.0
|
github.com/dweymouth/fyne-tooltip v0.3.0
|
||||||
github.com/dweymouth/go-jellyfin v0.0.0-20250531151636-29591764f0a0
|
github.com/dweymouth/go-jellyfin v0.0.0-20250715154414-d0a1630ee74f
|
||||||
github.com/godbus/dbus/v5 v5.1.0
|
github.com/godbus/dbus/v5 v5.1.0
|
||||||
github.com/google/uuid v1.3.0
|
github.com/google/uuid v1.3.0
|
||||||
github.com/hashicorp/go-retryablehttp v0.7.7
|
github.com/hashicorp/go-retryablehttp v0.7.7
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ github.com/dweymouth/fyne/v2 v2.3.0-rc1.0.20250712002006-5064d705dac4 h1:Q3r94Ac
|
|||||||
github.com/dweymouth/fyne/v2 v2.3.0-rc1.0.20250712002006-5064d705dac4/go.mod h1:YZt7SksjvrSNJCwbWFV32WON3mE1Sr7L41D29qMZ/lU=
|
github.com/dweymouth/fyne/v2 v2.3.0-rc1.0.20250712002006-5064d705dac4/go.mod h1:YZt7SksjvrSNJCwbWFV32WON3mE1Sr7L41D29qMZ/lU=
|
||||||
github.com/dweymouth/go-jellyfin v0.0.0-20250531151636-29591764f0a0 h1:9t1CR83uzn5Va4Nycwncmuw/NEAN64O4lf82VBPzdfE=
|
github.com/dweymouth/go-jellyfin v0.0.0-20250531151636-29591764f0a0 h1:9t1CR83uzn5Va4Nycwncmuw/NEAN64O4lf82VBPzdfE=
|
||||||
github.com/dweymouth/go-jellyfin v0.0.0-20250531151636-29591764f0a0/go.mod h1:fcUagHBaQnt06GmBAllNE0J4O/7064zXRWdqnTTtVjI=
|
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/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
|
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/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE=
|
||||||
github.com/felixge/fgprof v0.9.3 h1:VvyZxILNuCiUCSXtPtYmmtGvb65nqXh2QFWc0Wpf2/g=
|
github.com/felixge/fgprof v0.9.3 h1:VvyZxILNuCiUCSXtPtYmmtGvb65nqXh2QFWc0Wpf2/g=
|
||||||
|
|||||||
Reference in New Issue
Block a user