feat(subsonic): add getNewestPodcasts
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -13,13 +13,13 @@ func NewPodcastChannel(p *db.Podcast) *PodcastChannel {
|
||||
Status: "skipped",
|
||||
}
|
||||
for _, episode := range p.Episodes {
|
||||
specEpisode := NewPodcastEpisode(p, episode)
|
||||
specEpisode := NewPodcastEpisode(episode)
|
||||
ret.Episode = append(ret.Episode, specEpisode)
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
func NewPodcastEpisode(p *db.Podcast, e *db.PodcastEpisode) *PodcastEpisode {
|
||||
func NewPodcastEpisode(e *db.PodcastEpisode) *PodcastEpisode {
|
||||
if e == nil {
|
||||
return nil
|
||||
}
|
||||
@@ -27,11 +27,11 @@ func NewPodcastEpisode(p *db.Podcast, e *db.PodcastEpisode) *PodcastEpisode {
|
||||
ID: e.SID(),
|
||||
StreamID: e.SID(),
|
||||
ContentType: e.MIME(),
|
||||
ChannelID: p.SID(),
|
||||
ChannelID: e.PodcastSID(),
|
||||
Title: e.Title,
|
||||
Description: e.Description,
|
||||
Status: string(e.Status),
|
||||
CoverArt: p.SID(),
|
||||
CoverArt: e.PodcastSID(),
|
||||
PublishDate: *e.PublishDate,
|
||||
Genre: "Podcast",
|
||||
Duration: e.Length,
|
||||
|
||||
@@ -44,6 +44,7 @@ type Response struct {
|
||||
JukeboxStatus *JukeboxStatus `xml:"jukeboxStatus" json:"jukeboxStatus,omitempty"`
|
||||
JukeboxPlaylist *JukeboxPlaylist `xml:"jukeboxPlaylist" json:"jukeboxPlaylist,omitempty"`
|
||||
Podcasts *Podcasts `xml:"podcasts" json:"podcasts,omitempty"`
|
||||
NewestPodcasts *NewestPodcasts `xml:"newestPodcasts" json:"newestPodcasts,omitempty"`
|
||||
Bookmarks *Bookmarks `xml:"bookmarks" json:"bookmarks,omitempty"`
|
||||
Starred *Starred `xml:"starred" json:"starred,omitempty"`
|
||||
StarredTwo *StarredTwo `xml:"starred2" json:"starred2,omitempty"`
|
||||
@@ -294,6 +295,10 @@ type Podcasts struct {
|
||||
List []*PodcastChannel `xml:"channel" json:"channel"`
|
||||
}
|
||||
|
||||
type NewestPodcasts struct {
|
||||
List []*PodcastEpisode `xml:"episode" json:"episode"`
|
||||
}
|
||||
|
||||
type PodcastChannel struct {
|
||||
ID *specid.ID `xml:"id,attr" json:"id"`
|
||||
URL string `xml:"url,attr" json:"url"`
|
||||
|
||||
Reference in New Issue
Block a user