adding get son radio support to Jellyfin server

This commit is contained in:
natilou
2024-03-30 12:31:14 -03:00
parent c1bf789432
commit 0bd0ea8919
2 changed files with 11 additions and 3 deletions
@@ -452,3 +452,11 @@ func (j *jellyfinMediaProvider) fillPlaylist(p *jellyfin.Playlist, pl *mediaprov
pl.Owner = j.client.LoggedInUser() pl.Owner = j.client.LoggedInUser()
pl.Public = false pl.Public = false
} }
func (j *jellyfinMediaProvider) GetSongRadio(trackID string, count int) ([]*mediaprovider.Track, error) {
tr, err := j.client.GetInstantMix(trackID, jellyfin.TypeSong, count)
if err != nil {
return nil, err
}
return sharedutil.MapSlice(tr, toTrack), nil
}
+3 -3
View File
@@ -149,7 +149,7 @@ func (m *Controller) connectTracklistActionsWithReplayGainMode(tracklist *widget
go func() { go func() {
tracks, err := m.GetSongRadioTracks(track) tracks, err := m.GetSongRadioTracks(track)
if err != nil { if err != nil {
log.Printf("Error getting song radio: ", err) log.Println("Error getting song radio: ", err)
return return
} }
m.App.PlaybackManager.LoadTracks(tracks, false, false) m.App.PlaybackManager.LoadTracks(tracks, false, false)
@@ -886,12 +886,12 @@ func (c *Controller) ShowAlbumInfoDialog(albumID, albumName string, albumCover i
func (c *Controller) GetSongRadioTracks(sourceTrack *mediaprovider.Track) ([]*mediaprovider.Track, error) { func (c *Controller) GetSongRadioTracks(sourceTrack *mediaprovider.Track) ([]*mediaprovider.Track, error) {
r, ok := c.App.ServerManager.Server.(mediaprovider.SupportsSongRadio) r, ok := c.App.ServerManager.Server.(mediaprovider.SupportsSongRadio)
if !ok { if !ok {
return nil, fmt.Errorf("Server does not support song radio") return nil, fmt.Errorf("server does not support song radio")
} }
radioTracks, err := r.GetSongRadio(sourceTrack.ID, 100) radioTracks, err := r.GetSongRadio(sourceTrack.ID, 100)
if err != nil { if err != nil {
return nil, fmt.Errorf("Error getting song radio: ", err) return nil, fmt.Errorf("error getting song radio: %s", err.Error())
} }
// The goal of this implementation is to place the source track first in the queue. // The goal of this implementation is to place the source track first in the queue.