Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,21 @@ type Item struct {
XMLName xml.Name `xml:"item"`
Title string `xml:"title"`
GUID string `xml:"guid"`
Link string `xml:"link"`
PubDate *PubDate `xml:"pubDate"`
Author string `xml:"itunes:author,omitempty"`
Block string `xml:"itunes:block,omitempty"`
Duration time.Duration `xml:"itunes:duration,omitempty"`
Duration string `xml:"itunes:duration,omitempty"`
Explicit string `xml:"itunes:explicit,omitempty"`
ClosedCaptioned string `xml:"itunes:isClosedCaptioned,omitempty"`
Order int `xml:"itunes:order,omitempty"`
ItunesTitle string `xml:"itunes:title,omitempty"`
Subtitle string `xml:"itunes:subtitle,omitempty"`
Summary *ItunesSummary `xml:"itunes:summary,omitempty"`
Enclosure *Enclosure
Image *ItunesImage
Season int `xml:"itunes:season,omitempty"`
Episode int `xml:"itunes:episode,omitempty"`
}

// Channel represents a RSS channel for given podcast.
Expand Down
31 changes: 29 additions & 2 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ var (
ErrInvalidImage = errors.New("podcasts: invalid image")
)

// Values represents positive/negative value used in XML feed.
const (
// ValueYes represents positive value used in XML feed.
ValueYes = "yes"
ValueNo = "no"
)


// Author sets itunes:author of given feed.
func Author(author string) func(f *Feed) error {
return func(f *Feed) error {
Expand All @@ -37,13 +39,17 @@ func Explicit(f *Feed) error {
f.Channel.Explicit = ValueYes
return nil
}
// NotExplicit disables itunes:explicit of given feed.
func NotExplicit(f *Feed) error {
f.Channel.Explicit = ValueNo
return nil
}

// Complete enables itunes:complete of given feed.
func Complete(f *Feed) error {
f.Channel.Complete = ValueYes
return nil
}

// NewFeedURL sets itunes:new-feed-url of given feed.
func NewFeedURL(newURL string) func(f *Feed) error {
return func(f *Feed) error {
Expand Down Expand Up @@ -102,3 +108,24 @@ func Image(href string) func(f *Feed) error {
return nil
}
}



// Category appends itunes:category of given feed.
// Execute multiple times to add new main category and subcategories
func Category(category string, subcategories []string) func(f *Feed) error {
return func(f *Feed) error {
c := &ItunesCategory{
Text: category,
}

for _, subcategory := range subcategories {
c.Categories = append(c.Categories, &ItunesCategory{
Text: subcategory,
})
}

f.Channel.Categories = append(f.Channel.Categories, c)
return nil
}
}