diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..134a1a2 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +profile.out diff --git a/.travis.yml b/.travis.yml index 827faf3..18b954d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: go go: -- 1.7 +- 1.8 install: - go get -v -t . @@ -13,5 +13,11 @@ script: - go test -test.run Benchmark -cpu 1 -bench . - goveralls -service travis-ci -repotoken $COVERALLS_TOKEN -coverprofile cover.out +branches: + only: + - gh-pages + - /.*/ + notifications: - email: false + email: change + diff --git a/README.md b/README.md index 627e76d..3ba255c 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,12 @@ RSS 2.0: https://cyber.harvard. Podcasts: https://help.apple.com/itc/podcasts_connect/#/itca5b22233 ### Release Notes +1.3.0 +* fixes Item.Duration being set incorrectly. +* changed Item.AddEnclosure() parameter definition (Bytes not Seconds!). +* added Item.AddDuration formatting and override. +* added more documentation surrounding Item.Enclosure{} + 1.2.1 * added Podcast.AddSubTitle() and truncating to 64 chars. * added a number of Guards to protect against empty fields. @@ -78,7 +84,8 @@ Podcasts: ht * [type ISummary](#ISummary) * [type Image](#Image) * [type Item](#Item) - * [func (i \*Item) AddEnclosure(url string, enclosureType EnclosureType, lengthInSeconds int64)](#Item.AddEnclosure) + * [func (i \*Item) AddDuration(durationInSeconds int64)](#Item.AddDuration) + * [func (i \*Item) AddEnclosure(url string, enclosureType EnclosureType, lengthInBytes int64)](#Item.AddEnclosure) * [func (i \*Item) AddImage(url string)](#Item.AddImage) * [func (i \*Item) AddPubDate(datetime \*time.Time)](#Item.AddPubDate) * [func (i \*Item) AddSummary(summary string)](#Item.AddSummary) @@ -98,6 +105,7 @@ Podcasts: ht * [type TextInput](#TextInput) #### Examples +* [Item.AddDuration](#example_Item_AddDuration) * [Item.AddPubDate](#example_Item_AddPubDate) * [New](#example_New) * [Podcast.AddAuthor](#example_Podcast_AddAuthor) @@ -126,15 +134,27 @@ Author represents a named author and email. For iTunes compliance, both Name and Email are required. -## type [Enclosure](./enclosure.go#L46-L53) +## type [Enclosure](./enclosure.go#L46-L65) ``` go type Enclosure struct { - XMLName xml.Name `xml:"enclosure"` - URL string `xml:"url,attr"` - Length int64 `xml:"-"` - LengthFormatted string `xml:"length,attr"` - Type EnclosureType `xml:"-"` - TypeFormatted string `xml:"type,attr"` + XMLName xml.Name `xml:"enclosure"` + + // URL is the downloadable url for the content. (Required) + URL string `xml:"url,attr"` + + // Length is the size in Bytes of the download. (Required) + Length int64 `xml:"-"` + // LengthFormatted is the size in Bytes of the download. (Required) + // + // This field gets overwritten with the API when setting Length. + LengthFormatted string `xml:"length,attr"` + + // Type is MIME type encoding of the download. (Required) + Type EnclosureType `xml:"-"` + // TypeFormatted is MIME type encoding of the download. (Required) + // + // This field gets overwritten with the API when setting Type. + TypeFormatted string `xml:"type,attr"` } ``` Enclosure represents a download enclosure. @@ -268,10 +288,16 @@ Recommendations: - Always set an Enclosure.Length, to be nice to your downloaders. - Use Enclosure.Type instead of setting TypeFormatted for valid extensions. +### func (\*Item) [AddDuration](./item.go#L101) +``` go +func (i *Item) AddDuration(durationInSeconds int64) +``` +AddDuration adds the duration to the iTunes duration field. + ### func (\*Item) [AddEnclosure](./item.go#L52-L53) ``` go func (i *Item) AddEnclosure( - url string, enclosureType EnclosureType, lengthInSeconds int64) + url string, enclosureType EnclosureType, lengthInBytes int64) ``` AddEnclosure adds the downloadable asset to the podcast Item. @@ -436,7 +462,7 @@ Recommendations: https://help.apple.com/itc/podcasts_connect/#/itcb54353390 -### func (\*Podcast) [AddLastBuildDate](./podcast.go#L250) +### func (\*Podcast) [AddLastBuildDate](./podcast.go#L247) ``` go func (p *Podcast) AddLastBuildDate(datetime *time.Time) ``` @@ -444,7 +470,7 @@ AddLastBuildDate adds the datetime as a parsed PubDate. UTC time is used by default. -### func (\*Podcast) [AddPubDate](./podcast.go#L243) +### func (\*Podcast) [AddPubDate](./podcast.go#L240) ``` go func (p *Podcast) AddPubDate(datetime *time.Time) ``` @@ -452,7 +478,7 @@ AddPubDate adds the datetime as a parsed PubDate. UTC time is used by default. -### func (\*Podcast) [AddSubTitle](./podcast.go#L259) +### func (\*Podcast) [AddSubTitle](./podcast.go#L256) ``` go func (p *Podcast) AddSubTitle(subTitle string) ``` @@ -462,7 +488,7 @@ in iTunes. Note that this field should be just a few words long according to Apple. This method will truncate the string to 64 chars if too long with "..." -### func (\*Podcast) [AddSummary](./podcast.go#L276) +### func (\*Podcast) [AddSummary](./podcast.go#L273) ``` go func (p *Podcast) AddSummary(summary string) ``` @@ -473,19 +499,19 @@ Limit: 4000 characters Note that this field is a CDATA encoded field which allows for rich text such as html links: http://www.apple.com">Apple. -### func (\*Podcast) [Bytes](./podcast.go#L290) +### func (\*Podcast) [Bytes](./podcast.go#L287) ``` go func (p *Podcast) Bytes() []byte ``` Bytes returns an encoded []byte slice. -### func (\*Podcast) [Encode](./podcast.go#L295) +### func (\*Podcast) [Encode](./podcast.go#L292) ``` go func (p *Podcast) Encode(w io.Writer) error ``` Encode writes the bytes to the io.Writer stream in RSS 2.0 specification. -### func (\*Podcast) [String](./podcast.go#L306) +### func (\*Podcast) [String](./podcast.go#L303) ``` go func (p *Podcast) String() string ``` diff --git a/doc.go b/doc.go index 3746150..b2c5137 100644 --- a/doc.go +++ b/doc.go @@ -37,6 +37,12 @@ // // Release Notes // +// 1.3.0 +// * fixes Item.Duration being set incorrectly. +// * changed Item.AddEnclosure() parameter definition (Bytes not Seconds!). +// * added Item.AddDuration formatting and override. +// * added more documentation surrounding Item.Enclosure{} +// // 1.2.1 // * added Podcast.AddSubTitle() and truncating to 64 chars. // * added a number of Guards to protect against empty fields. diff --git a/enclosure.go b/enclosure.go index bd423fd..33b0b68 100644 --- a/enclosure.go +++ b/enclosure.go @@ -44,10 +44,22 @@ func (et EnclosureType) String() string { // Enclosure represents a download enclosure. type Enclosure struct { - XMLName xml.Name `xml:"enclosure"` - URL string `xml:"url,attr"` - Length int64 `xml:"-"` - LengthFormatted string `xml:"length,attr"` - Type EnclosureType `xml:"-"` - TypeFormatted string `xml:"type,attr"` + XMLName xml.Name `xml:"enclosure"` + + // URL is the downloadable url for the content. (Required) + URL string `xml:"url,attr"` + + // Length is the size in Bytes of the download. (Required) + Length int64 `xml:"-"` + // LengthFormatted is the size in Bytes of the download. (Required) + // + // This field gets overwritten with the API when setting Length. + LengthFormatted string `xml:"length,attr"` + + // Type is MIME type encoding of the download. (Required) + Type EnclosureType `xml:"-"` + // TypeFormatted is MIME type encoding of the download. (Required) + // + // This field gets overwritten with the API when setting Type. + TypeFormatted string `xml:"type,attr"` } diff --git a/example_test.go b/example_test.go index cf040e8..f8585c3 100644 --- a/example_test.go +++ b/example_test.go @@ -76,7 +76,7 @@ func Example_httpHandlers() { //