Skip to content

Commit f4e84d9

Browse files
committed
WIP - Jellyfin multi library
1 parent c5c8040 commit f4e84d9

File tree

5 files changed

+28
-5
lines changed

5 files changed

+28
-5
lines changed

backend/mediaprovider/jellyfin/iterators.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ func (j *jellyfinMediaProvider) IterateAlbums(sortOrder string, filter mediaprov
4242
jfSort.Mode = jellyfin.SortDesc
4343
}
4444
jfFilt, modifiedFilter := jfFilterFromFilter(filter)
45+
if j.currentLibraryID != "" {
46+
jfFilt.ParentID = j.currentLibraryID
47+
}
4548

4649
fetcher := func(offs, limit int) ([]*mediaprovider.Album, error) {
4750
al, err := j.client.GetAlbums(jellyfin.QueryOpts{
@@ -89,6 +92,9 @@ func (j *jellyfinMediaProvider) IterateTracks(searchQuery string) mediaprovider.
8992
fetcher = func(offs, limit int) ([]*mediaprovider.Track, error) {
9093
var opts jellyfin.QueryOpts
9194
opts.Paging = jellyfin.Paging{StartIndex: offs, Limit: limit}
95+
if j.currentLibraryID != "" {
96+
opts.Filter.ParentID = j.currentLibraryID
97+
}
9298
s, err := j.client.GetSongs(opts)
9399
if err != nil {
94100
return nil, err

backend/mediaprovider/jellyfin/jellyfinmediaprovider.go

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

6264
func (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
}

backend/mediaprovider/jellyfin/searchall.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func (j *jellyfinMediaProvider) SearchAll(searchQuery string, maxResults int) ([
5555

5656
wg.Add(1)
5757
go func() {
58-
g, e := j.client.GetGenres(jellyfin.Paging{})
58+
g, e := j.client.GetGenres(jellyfin.Paging{}, "")
5959
if e == nil {
6060
genres = sharedutil.FilterSlice(g, func(g jellyfin.NameID) bool {
6161
return helpers.AllTermsMatch(strings.ToLower(sanitize.Accents(g.Name)), queryLowerWords)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ require (
1010
github.com/deluan/sanitize v0.0.0-20230310221930-6e18967d9fc1
1111
github.com/dweymouth/fyne-advanced-list v0.0.0-20250211191927-58ea85eec72c
1212
github.com/dweymouth/fyne-tooltip v0.3.0
13-
github.com/dweymouth/go-jellyfin v0.0.0-20250531151636-29591764f0a0
13+
github.com/dweymouth/go-jellyfin v0.0.0-20250715154414-d0a1630ee74f
1414
github.com/godbus/dbus/v5 v5.1.0
1515
github.com/google/uuid v1.3.0
1616
github.com/hashicorp/go-retryablehttp v0.7.7

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ github.com/dweymouth/fyne/v2 v2.3.0-rc1.0.20250712002006-5064d705dac4 h1:Q3r94Ac
2525
github.com/dweymouth/fyne/v2 v2.3.0-rc1.0.20250712002006-5064d705dac4/go.mod h1:YZt7SksjvrSNJCwbWFV32WON3mE1Sr7L41D29qMZ/lU=
2626
github.com/dweymouth/go-jellyfin v0.0.0-20250531151636-29591764f0a0 h1:9t1CR83uzn5Va4Nycwncmuw/NEAN64O4lf82VBPzdfE=
2727
github.com/dweymouth/go-jellyfin v0.0.0-20250531151636-29591764f0a0/go.mod h1:fcUagHBaQnt06GmBAllNE0J4O/7064zXRWdqnTTtVjI=
28+
github.com/dweymouth/go-jellyfin v0.0.0-20250715154414-d0a1630ee74f h1:7O7Cn17pwKHG7zPgNhxMabXJP1ZdmNVxCb4i8yJgVZo=
29+
github.com/dweymouth/go-jellyfin v0.0.0-20250715154414-d0a1630ee74f/go.mod h1:fcUagHBaQnt06GmBAllNE0J4O/7064zXRWdqnTTtVjI=
2830
github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
2931
github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE=
3032
github.com/felixge/fgprof v0.9.3 h1:VvyZxILNuCiUCSXtPtYmmtGvb65nqXh2QFWc0Wpf2/g=

0 commit comments

Comments
 (0)