diff --git a/doc.go b/doc.go
index cefd102..f5aec2a 100644
--- a/doc.go
+++ b/doc.go
@@ -37,6 +37,13 @@
//
// Release Notes
//
+// 1.2.0
+// * added Podcast.AddPubDate() and Podcast.AddLastBuildDate() overrides.
+// * added Item.AddImage() to mask some cumbersome addition of IImage.
+// * added Item.AddPubDate to simply datetime setters.
+// * added more examples (mostly around Item struct).
+// * tweaked some documentation.
+//
// 1.1.0
// * Enabling CDATA in ISummary fields for Podcast and Channel.
//
diff --git a/example_test.go b/example_test.go
index 9752718..c600dcf 100644
--- a/example_test.go
+++ b/example_test.go
@@ -40,6 +40,7 @@ func Example_httpHandlers() {
Description: "Description for Episode " + n,
PubDate: &d,
}
+ item.AddImage("http://example.com/episode-" + n + ".png")
item.AddSummary(`item example.com`)
// add a Download to the Item
item.AddEnclosure("http://e.com/"+n+".mp3", podcast.MP3, 55*(i+1))
@@ -75,7 +76,7 @@ func Example_httpHandlers() {
//
eduncan911 Podcasts
// http://eduncan911.com/
// An example Podcast
- // go podcast v1.1.0 (github.com/eduncan911/podcast)
+ // go podcast v1.2.0 (github.com/eduncan911/podcast)
// en-us
// Mon, 06 Feb 2017 08:21:52 +0000
// me@janedoe.com (Jane Doe)
@@ -95,7 +96,7 @@ func Example_httpHandlers() {
//
// me@janedoe.com (Jane Doe)
// example.com]]>
- //
+ //
// 110
//
// -
@@ -107,7 +108,7 @@ func Example_httpHandlers() {
//
// me@janedoe.com (Jane Doe)
// example.com]]>
- //
+ //
// 165
//
//
@@ -141,6 +142,7 @@ func Example_ioWriter() {
ISubtitle: "A simple episode " + n,
PubDate: &d,
}
+ item.AddImage("http://example.com/episode-" + n + ".png")
item.AddSummary(`item k example.com`)
// add a Download to the Item
item.AddEnclosure("http://example.com/"+n+".mp3", podcast.MP3, 55*(i+1))
@@ -163,7 +165,7 @@ func Example_ioWriter() {
// Sample Podcasts
// http://example.com/
// An example Podcast
- // go podcast v1.1.0 (github.com/eduncan911/podcast)
+ // go podcast v1.2.0 (github.com/eduncan911/podcast)
// en-us
// Mon, 06 Feb 2017 08:21:52 +0000
// jane.doe@example.com (Jane Doe)
@@ -185,7 +187,7 @@ func Example_ioWriter() {
// jane.doe@example.com (Jane Doe)
// A simple episode 9
// example.com]]>
- //
+ //
// 550
//
// -
@@ -198,7 +200,7 @@ func Example_ioWriter() {
// jane.doe@example.com (Jane Doe)
// A simple episode 10
// example.com]]>
- //
+ //
// 605
//
//
diff --git a/examples_test.go b/examples_test.go
index 4912a68..0991c7e 100644
--- a/examples_test.go
+++ b/examples_test.go
@@ -103,10 +103,32 @@ func ExamplePodcast_AddItem() {
// http://example.com/1.mp3 Episode 1 http://example.com/1.mp3 Description for Episode 1 &{{ } me@test.com (the name)} 2017-04-22 08:21:52 +0000 UTC Sat, 22 Apr 2017 08:21:52 +0000 {{ } http://example.com/1.mp3 183 183 audio/mpeg audio/mpeg} me@test.com (the name) 183 A simple episode 1 &{{ } See more at Here}
}
+func ExamplePodcast_AddLastBuildDate() {
+ p := podcast.New("title", "link", "description", nil, nil)
+ d := pubDate.AddDate(0, 0, -7)
+
+ p.AddLastBuildDate(&d)
+
+ fmt.Println(p.LastBuildDate)
+ // Output:
+ // Sat, 28 Jan 2017 08:21:52 +0000
+}
+
+func ExamplePodcast_AddPubDate() {
+ p := podcast.New("title", "link", "description", nil, nil)
+ d := pubDate.AddDate(0, 0, -5)
+
+ p.AddPubDate(&d)
+
+ fmt.Println(p.PubDate)
+ // Output:
+ // Mon, 30 Jan 2017 08:21:52 +0000
+}
+
func ExamplePodcast_AddSummary() {
p := podcast.New("title", "link", "description", nil, nil)
- // add the Image
+ // add a summary
p.AddSummary(`A very cool podcast with a long summary!
See more at our website: example.com
@@ -161,7 +183,7 @@ See more at our website: example.com
// eduncan911 Podcasts
// http://eduncan911.com/
// An example Podcast
- // go podcast v1.1.0 (github.com/eduncan911/podcast)
+ // go podcast v1.2.0 (github.com/eduncan911/podcast)
// en-us
// Mon, 06 Feb 2017 08:21:52 +0000
// me@janedoe.com (Jane Doe)
@@ -196,3 +218,25 @@ See more at our website: example.com
//
//
}
+
+func ExampleItem_AddPubDate() {
+ p := podcast.New("title", "link", "description", nil, nil)
+ i := podcast.Item{
+ Title: "item title",
+ Description: "item desc",
+ Link: "item link",
+ }
+ d := pubDate.AddDate(0, 0, -11)
+
+ // add the pub date
+ i.AddPubDate(&d)
+
+ if i.PubDate != nil {
+ fmt.Println(i.PubDateFormatted, *i.PubDate)
+ }
+ p.AddItem(i) // this should not override with Podcast.PubDate
+ fmt.Println(i.PubDateFormatted, *i.PubDate)
+ // Output:
+ // Tue, 24 Jan 2017 08:21:52 +0000 2017-01-24 08:21:52 +0000 UTC
+ // Tue, 24 Jan 2017 08:21:52 +0000 2017-01-24 08:21:52 +0000 UTC
+}
diff --git a/item.go b/item.go
index 0d32930..c37bc0c 100644
--- a/item.go
+++ b/item.go
@@ -58,6 +58,27 @@ func (i *Item) AddEnclosure(
}
}
+// AddImage adds the image as an iTunes-only IImage. RSS 2.0 does not have
+// the specification of Images at the Item level.
+//
+// Podcast feeds contain artwork that is a minimum size of
+// 1400 x 1400 pixels and a maximum size of 3000 x 3000 pixels,
+// 72 dpi, in JPEG or PNG format with appropriate file
+// extensions (.jpg, .png), and in the RGB colorspace. To optimize
+// images for mobile devices, Apple recommends compressing your
+// image files.
+func (i *Item) AddImage(url string) {
+ i.IImage = &IImage{HREF: url}
+}
+
+// AddPubDate adds the datetime as a parsed PubDate.
+//
+// UTC time is used by default.
+func (i *Item) AddPubDate(datetime *time.Time) {
+ i.PubDate = datetime
+ i.PubDateFormatted = parseDateRFC1123Z(i.PubDate)
+}
+
// AddSummary adds the iTunes summary.
//
// Limit: 4000 characters
diff --git a/podcast.go b/podcast.go
index 4e380d3..fcb577b 100644
--- a/podcast.go
+++ b/podcast.go
@@ -12,7 +12,7 @@ import (
)
const (
- pVersion = "1.1.0"
+ pVersion = "1.2.0"
)
// Podcast represents a podcast.
@@ -231,6 +231,20 @@ func (p *Podcast) AddItem(i Item) (int, error) {
return len(p.Items), nil
}
+// AddPubDate adds the datetime as a parsed PubDate.
+//
+// UTC time is used by default.
+func (p *Podcast) AddPubDate(datetime *time.Time) {
+ p.PubDate = parseDateRFC1123Z(datetime)
+}
+
+// AddLastBuildDate adds the datetime as a parsed PubDate.
+//
+// UTC time is used by default.
+func (p *Podcast) AddLastBuildDate(datetime *time.Time) {
+ p.LastBuildDate = parseDateRFC1123Z(datetime)
+}
+
// AddSummary adds the iTunes summary.
//
// Limit: 4000 characters