From e15ea11fc736a032b4254e446b7c29b623b2c0c0 Mon Sep 17 00:00:00 2001 From: Mareks Ruskuls Date: Fri, 3 Jul 2020 19:10:54 +0300 Subject: [PATCH 1/7] Allow to add catgories --- options.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/options.go b/options.go index bd3743b..cf9eea8 100644 --- a/options.go +++ b/options.go @@ -102,3 +102,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 + } +} From 3a59ee1ecd08297d8172ce6a8ad7e453326b5d56 Mon Sep 17 00:00:00 2001 From: Mareks Ruskuls Date: Fri, 3 Jul 2020 19:15:46 +0300 Subject: [PATCH 2/7] Add `` tag to item for valid item Validator: https://castfeedvalidator.com/ --- feed.go | 1 + 1 file changed, 1 insertion(+) diff --git a/feed.go b/feed.go index 1511d71..bd24ba7 100644 --- a/feed.go +++ b/feed.go @@ -68,6 +68,7 @@ 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"` From 7d1ae7d43760cb675e897bd570757ba71a5d64c6 Mon Sep 17 00:00:00 2001 From: Mareks Ruskuls Date: Fri, 3 Jul 2020 19:20:48 +0300 Subject: [PATCH 3/7] Render `` tag with `no` value. --- options.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/options.go b/options.go index cf9eea8..c55a036 100644 --- a/options.go +++ b/options.go @@ -13,9 +13,10 @@ 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. @@ -37,6 +38,11 @@ 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 { From 91beb6a53c10227cbbf271d16116cb697019e509 Mon Sep 17 00:00:00 2001 From: Mareks Ruskuls Date: Fri, 3 Jul 2020 19:40:33 +0300 Subject: [PATCH 4/7] Add `ValueNo` constant as `ValueYes` --- options.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/options.go b/options.go index c55a036..66de23e 100644 --- a/options.go +++ b/options.go @@ -19,6 +19,7 @@ const ( ValueNo = "no" ) + // Author sets itunes:author of given feed. func Author(author string) func(f *Feed) error { return func(f *Feed) error { @@ -49,7 +50,6 @@ 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 { From 51bebf111731b4627a5bce8119adefb25c0d94a2 Mon Sep 17 00:00:00 2001 From: Mareks Ruskuls Date: Fri, 3 Jul 2020 19:40:56 +0300 Subject: [PATCH 5/7] `ItunesTitle` field added for feed item --- feed.go | 1 + 1 file changed, 1 insertion(+) diff --git a/feed.go b/feed.go index bd24ba7..2d00e42 100644 --- a/feed.go +++ b/feed.go @@ -76,6 +76,7 @@ type Item struct { 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 From 8079b0e1f6b33d95938b67a6281da8ef227a2d43 Mon Sep 17 00:00:00 2001 From: Mareks Ruskuls Date: Fri, 3 Jul 2020 19:47:14 +0300 Subject: [PATCH 6/7] Allow to add `` and `` --- feed.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/feed.go b/feed.go index 2d00e42..1255596 100644 --- a/feed.go +++ b/feed.go @@ -81,6 +81,8 @@ type Item struct { 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. From b3411f06269aa48455d59a566b415e9433799364 Mon Sep 17 00:00:00 2001 From: Mareks Ruskuls Date: Fri, 3 Jul 2020 20:42:46 +0300 Subject: [PATCH 7/7] Change `Duration` type to string `time.Duration` parsed as long int `13000000000` Should be in format as `00:54:12` (HH:MH:SS) --- feed.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/feed.go b/feed.go index 1255596..29d3c74 100644 --- a/feed.go +++ b/feed.go @@ -72,7 +72,7 @@ type Item struct { 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"`