feat(subsonic): better support for internet radio and podcast episodes in jukebox

fixes #572
This commit is contained in:
sentriz
2025-09-18 15:45:34 +01:00
parent 8ac8779b92
commit 3db183bda4
2 changed files with 20 additions and 5 deletions

No files matched your search

+10 -5
View File
@@ -352,7 +352,7 @@ func (c *Controller) ServeGetRandomSongs(r *http.Request) *spec.Response {
return sub
}
var errNotATrack = errors.New("not a track")
var errUnknownPlaylistEntry = errors.New("unknown playlist entry")
func (c *Controller) ServeJukebox(r *http.Request) *spec.Response { // nolint:gocyclo
if c.jukebox == nil {
@@ -394,11 +394,16 @@ func (c *Controller) ServeJukebox(r *http.Request) *spec.Response { // nolint:go
if err != nil {
return nil, fmt.Errorf("fetch track: %w", err)
}
track, ok := file.(*db.Track)
if !ok {
return nil, fmt.Errorf("%q: %w", path, errNotATrack)
switch f := file.(type) {
case *db.Track:
ret = append(ret, spec.NewTrackByTags(f, f.Album))
case *db.InternetRadioStation:
ret = append(ret, spec.NewTCInternetRadioStation(f))
case *db.PodcastEpisode:
ret = append(ret, spec.NewTCPodcastEpisode(f))
default:
return nil, fmt.Errorf("%q: %w", path, errUnknownPlaylistEntry)
}
ret = append(ret, spec.NewTrackByTags(track, track.Album))
}
return ret, nil
}
@@ -10,3 +10,13 @@ func NewInternetRadioStation(irs *db.InternetRadioStation) *InternetRadioStation
HomepageURL: irs.HomepageURL,
}
}
func NewTCInternetRadioStation(irs *db.InternetRadioStation) *TrackChild {
return &TrackChild{
ID: irs.SID(),
Title: irs.Name,
IsDir: false,
IsVideo: false,
Type: "internetradio",
}
}