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 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 func (c *Controller) ServeJukebox(r *http.Request) *spec.Response { // nolint:gocyclo
if c.jukebox == nil { if c.jukebox == nil {
@@ -394,11 +394,16 @@ func (c *Controller) ServeJukebox(r *http.Request) *spec.Response { // nolint:go
if err != nil { if err != nil {
return nil, fmt.Errorf("fetch track: %w", err) return nil, fmt.Errorf("fetch track: %w", err)
} }
track, ok := file.(*db.Track) switch f := file.(type) {
if !ok { case *db.Track:
return nil, fmt.Errorf("%q: %w", path, errNotATrack) 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 return ret, nil
} }
@@ -10,3 +10,13 @@ func NewInternetRadioStation(irs *db.InternetRadioStation) *InternetRadioStation
HomepageURL: irs.HomepageURL, HomepageURL: irs.HomepageURL,
} }
} }
func NewTCInternetRadioStation(irs *db.InternetRadioStation) *TrackChild {
return &TrackChild{
ID: irs.SID(),
Title: irs.Name,
IsDir: false,
IsVideo: false,
Type: "internetradio",
}
}