diff --git a/item.go b/item.go index 88294e5..a5612b5 100644 --- a/item.go +++ b/item.go @@ -18,6 +18,7 @@ import ( // - Title // - Description // - Enclosure (HREF, Type and Length all required) +// - IEpisode (iTunes episode number) // // Recommendations: // - Setting the minimal fields sets most of other fields, including iTunes. @@ -41,6 +42,7 @@ type Item struct { // https://help.apple.com/itc/podcasts_connect/#/itcb54353390 IAuthor string `xml:"itunes:author,omitempty"` + IEpisode int `xml:"itunes:episode"` ISubtitle string `xml:"itunes:subtitle,omitempty"` ISummary *ISummary IImage *IImage diff --git a/podcast.go b/podcast.go index b71d5df..24472be 100644 --- a/podcast.go +++ b/podcast.go @@ -52,7 +52,7 @@ type Podcast struct { INewFeedURL string `xml:"itunes:new-feed-url,omitempty"` IOwner *Author // Author is formatted for itunes as-is ICategories []*ICategory - + IType string `xml:"itunes:type,omitempty"` Items []*Item encode func(w io.Writer, o interface{}) error @@ -72,7 +72,7 @@ func New(title, link, description string, PubDate: parseDateRFC1123Z(pubDate), LastBuildDate: parseDateRFC1123Z(lastBuildDate), Language: "en-us", - + IType: "episodic", // setup dependency (could inject later) encode: encoder, } @@ -328,6 +328,12 @@ func (p *Podcast) AddItem(i Item) (int, error) { } p.Items = append(p.Items, &i) + + //if episode number is not passed; we will just increase the items by one + if i.IEpisode == 0 && p.IType == "episodic" { + i.IEpisode = len(p.Items) + 1 + } + return len(p.Items), nil } @@ -382,6 +388,21 @@ func (p *Podcast) AddSummary(summary string) { } } +// AddIType adds the specified type to the podcast to the podcast. +func (p *Podcast) AddIType(iType string) { + if len(iType) == 0 { + return + } + + if iType == "serial" { + p.IType = "serial" + return + } + + p.IType = "episodic" + +} + // Bytes returns an encoded []byte slice. func (p *Podcast) Bytes() []byte { return []byte(p.String())