feat(subsonic): add getNewestPodcasts

This commit is contained in:
brian-doherty
2022-04-21 14:13:47 -05:00
committed by GitHub
parent dc4d9e4e96
commit f6687df3f3
6 changed files with 42 additions and 4 deletions

View File

@@ -29,6 +29,21 @@ func (c *Controller) ServeGetPodcasts(r *http.Request) *spec.Response {
return sub
}
func (c *Controller) ServeGetNewestPodcasts(r *http.Request) *spec.Response {
params := r.Context().Value(CtxParams).(params.Params)
count := params.GetOrInt("count", 10)
episodes, err := c.Podcasts.GetNewestPodcastEpisodes(count)
if err != nil {
return spec.NewError(10, "failed get podcast(s): %s", err)
}
sub := spec.NewResponse()
sub.NewestPodcasts = &spec.NewestPodcasts{}
for _, episode := range episodes {
sub.NewestPodcasts.List = append(sub.NewestPodcasts.List, spec.NewPodcastEpisode(episode))
}
return sub
}
func (c *Controller) ServeDownloadPodcastEpisode(r *http.Request) *spec.Response {
params := r.Context().Value(CtxParams).(params.Params)
id, err := params.GetID("id")