feat(subsonic): better support for internet radio and podcast episodes in jukebox
fixes #572
This commit is contained in:
No files matched your search
@@ -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",
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user