add some podcast nit changes and make podcasts mandatory

This commit is contained in:
Alex McGrath
2021-01-11 11:50:44 +00:00
committed by Senan Kelly
parent 9c4286b0e2
commit 37fca3a087
16 changed files with 332 additions and 267 deletions

View File

@@ -0,0 +1,45 @@
package spec
import "go.senan.xyz/gonic/server/db"
func NewPodcastChannel(p *db.Podcast) *PodcastChannel {
ret := &PodcastChannel{
ID: p.SID(),
OriginalImageURL: p.ImageURL,
Title: p.Title,
Description: p.Description,
URL: p.URL,
CoverArt: p.SID(),
Status: "skipped",
}
for _, episode := range p.Episodes {
specEpisode := NewPodcastEpisode(p, episode)
ret.Episode = append(ret.Episode, specEpisode)
}
return ret
}
func NewPodcastEpisode(p *db.Podcast, e *db.PodcastEpisode) *PodcastEpisode {
if e == nil {
return nil
}
return &PodcastEpisode{
ID: e.SID(),
StreamID: e.SID(),
ContentType: e.MIME(),
ChannelID: p.SID(),
Title: e.Title,
Description: e.Description,
Status: e.Status,
CoverArt: p.SID(),
PublishDate: *e.PublishDate,
Genre: "Podcast",
Duration: e.Length,
Year: e.PublishDate.Year(),
Suffix: e.Ext(),
BitRate: e.Bitrate,
IsDir: false,
Path: e.Path,
Size: e.Size,
}
}

View File

@@ -288,24 +288,24 @@ type JukeboxPlaylist struct {
}
type Podcasts struct {
List []PodcastChannel `xml:"channel" json:"channel"`
List []*PodcastChannel `xml:"channel" json:"channel"`
}
type PodcastChannel struct {
ID specid.ID `xml:"id,attr" json:"id"`
ID *specid.ID `xml:"id,attr" json:"id"`
URL string `xml:"url,attr" json:"url"`
Title string `xml:"title,attr" json:"title"`
Description string `xml:"description,attr" json:"description"`
CoverArt specid.ID `xml:"coverArt,attr" json:"coverArt,omitempty"`
CoverArt *specid.ID `xml:"coverArt,attr" json:"coverArt,omitempty"`
OriginalImageURL string `xml:"originalImageUrl,attr" json:"originalImageUrl,omitempty"`
Status string `xml:"status,attr" json:"status"`
Episode []PodcastEpisode `xml:"episode" json:"episode,omitempty"`
Episode []*PodcastEpisode `xml:"episode" json:"episode,omitempty"`
}
type PodcastEpisode struct {
ID specid.ID `xml:"id,attr" json:"id"`
StreamID specid.ID `xml:"streamId,attr" json:"streamId"`
ChannelID specid.ID `xml:"channelId,attr" json:"channelId"`
ID *specid.ID `xml:"id,attr" json:"id"`
StreamID *specid.ID `xml:"streamId,attr" json:"streamId"`
ChannelID *specid.ID `xml:"channelId,attr" json:"channelId"`
Title string `xml:"title,attr" json:"title"`
Description string `xml:"description,attr" json:"description"`
PublishDate time.Time `xml:"publishDate,attr" json:"publishDate"`
@@ -314,7 +314,7 @@ type PodcastEpisode struct {
IsDir bool `xml:"isDir,attr" json:"isDir"`
Year int `xml:"year,attr" json:"year"`
Genre string `xml:"genre,attr" json:"genre"`
CoverArt specid.ID `xml:"coverArt,attr" json:"coverArt"`
CoverArt *specid.ID `xml:"coverArt,attr" json:"coverArt"`
Size int `xml:"size,attr" json:"size"`
ContentType string `xml:"contentType,attr" json:"contentType"`
Suffix string `xml:"suffix,attr" json:"suffix"`