Documentation
¶
Overview ¶
Package podcasts implements a podcast generator.
// initialise the podcast
p := &podcasts.Podcast{
Title: "My podcast",
Description: "This is my very simple podcast.",
Language: "EN",
Link: "http://www.example-podcast.com/my-podcast",
Copyright: "2015 My podcast copyright",
}
// add first podcast item
p.AddItem(&podcasts.Item{
Title: "Episode 1",
GUID: "http://www.example-podcast.com/my-podcast/1/episode-one",
PubDate: podcasts.NewPubDate(time.Now()),
Duration: podcasts.NewDuration(time.Second * 320),
Enclosure: &podcasts.Enclosure{
URL: "http://www.example-podcast.com/my-podcast/1/episode.mp3",
Length: "12312",
Type: "MP3",
},
})
// add second podcast item
p.AddItem(&podcasts.Item{
Title: "Episode 2",
GUID: "http://www.example-podcast.com/my-podcast/2/episode-two",
PubDate: podcasts.NewPubDate(time.Now()),
Duration: podcasts.NewDuration(time.Second * 210),
Enclosure: &podcasts.Enclosure{
URL: "http://www.example-podcast.com/my-podcast/2/episode.mp3",
Length: "46732",
Type: "MP3",
},
})
// get podcast feed, you can pass options to customise it
feed, err := p.Feed(
podcasts.Author("Author Name"),
podcasts.Block,
podcasts.Explicit,
podcasts.Complete,
podcasts.NewFeedURL("http://www.example-podcast.com/new-feed-url"),
podcasts.Subtitle("This is my very simple podcast subtitle."),
podcasts.Summary("This is my very simple podcast summary."),
podcasts.Owner("Podcast Owner", "[email protected]"),
podcasts.Image("http://www.example-podcast.com/my-podcast.jpg"),
)
// handle error
if err != nil {
log.Fatal(err)
}
// finally write the xml to any io.Writer
feed.Write(os.Stdout)
Index ¶
- Constants
- Variables
- func Author(author string) func(f *Feed) error
- func Block(f *Feed) error
- func Complete(f *Feed) error
- func Explicit(f *Feed) error
- func Image(href string) func(feed *Feed) error
- func NewFeedURL(newURL string) func(feed *Feed) error
- func Owner(name, email string) func(feed *Feed) error
- func Subtitle(subtitle string) func(feed *Feed) error
- func Summary(summary string) func(f *Feed) error
- type CDATAText
- type Channel
- type Duration
- type Enclosure
- type Feed
- type Item
- type ItunesCategory
- type ItunesImage
- type ItunesOwner
- type Podcast
- type PubDate
Constants ¶
const (
// ValueYes represents positive value used in XML feed.
ValueYes = "yes"
)
Variables ¶
var ( // ErrInvalidURL represents a error returned for invalid url. ErrInvalidURL = errors.New("podcasts: invalid url") // ErrInvalidImage represents a error returned for invalid image. ErrInvalidImage = errors.New("podcasts: invalid image") )
Functions ¶
func NewFeedURL ¶
NewFeedURL sets itunes:new-feed-url of given feed.
Types ¶
type CDATAText ¶
type CDATAText struct {
Value string `xml:",cdata"`
}
CDATAText represents some content that may contain embedded HTML such as <a href="...">...</a> links.
type Channel ¶
type Channel struct {
XMLName xml.Name `xml:"channel"`
Title string `xml:"title"`
Link string `xml:"link"`
Copyright string `xml:"copyright"`
Language string `xml:"language"`
Description string `xml:"description"`
Author string `xml:"itunes:author,omitempty"`
Block string `xml:"itunes:block,omitempty"`
Explicit string `xml:"itunes:explicit,omitempty"`
Complete string `xml:"itunes:complete,omitempty"`
NewFeedURL string `xml:"itunes:new-feed-url,omitempty"`
Subtitle string `xml:"itunes:subtitle,omitempty"`
Summary *CDATAText `xml:"itunes:summary,omitempty"`
Owner *ItunesOwner
Image *ItunesImage
Items []*Item
Categories []*ItunesCategory
}
Channel represents a RSS channel for given podcast.
type Duration ¶
Duration represents itunes:duration attribute of given podcast item.
func (Duration) MarshalXML ¶
MarshalXML marshalls duration using HH:MM:SS, H:MM:SS, MM:SS, M:SS formats.
type Enclosure ¶
type Enclosure struct {
XMLName xml.Name `xml:"enclosure"`
URL string `xml:"url,attr"`
Length string `xml:"length,attr,omitempty"`
Type string `xml:"type,attr"`
}
Enclosure represents audio or video file of given item.
type Feed ¶
type Feed struct {
XMLName xml.Name `xml:"rss"`
ItunesXMLNS string `xml:"xmlns:itunes,attr"`
ContentXMLNS string `xml:"xmlns:content,attr"`
Version string `xml:"version,attr"`
Channel *Channel
}
Feed wraps the given RSS channel.
func (*Feed) SetOptions ¶
SetOptions sets options of given feed.
type Item ¶
type Item struct {
XMLName xml.Name `xml:"item"`
Title string `xml:"title"`
GUID string `xml:"guid"`
PubDate *PubDate `xml:"pubDate"`
Description *CDATAText `xml:"description,omitempty"`
ContentEncoded *CDATAText `xml:"content:encoded,omitempty"`
Author string `xml:"itunes:author,omitempty"`
Block string `xml:"itunes:block,omitempty"`
Duration *Duration `xml:"itunes:duration,omitempty"`
Explicit string `xml:"itunes:explicit,omitempty"`
ClosedCaptioned string `xml:"itunes:isClosedCaptioned,omitempty"`
Order int `xml:"itunes:order,omitempty"`
Subtitle string `xml:"itunes:subtitle,omitempty"`
Summary *CDATAText `xml:"itunes:summary,omitempty"`
Enclosure *Enclosure
Image *ItunesImage
}
Item represents item of given channel.
type ItunesCategory ¶
type ItunesCategory struct {
XMLName xml.Name `xml:"itunes:category"`
Text string `xml:"text,attr"`
Categories []*ItunesCategory
}
ItunesCategory represents itunes:category of given channel.
type ItunesImage ¶
ItunesImage represents the itunes:image of given item or channel.
type ItunesOwner ¶
type ItunesOwner struct {
XMLName xml.Name `xml:"itunes:owner"`
Name string `xml:"itunes:name"`
Email string `xml:"itunes:email"`
}
ItunesOwner represents the itunes:owner of given channel.
type Podcast ¶
type Podcast struct {
Title string
Description string
Link string
Language string
Copyright string
// contains filtered or unexported fields
}
Podcast represents a web podcast.
type PubDate ¶
PubDate represents pubDate attribute of given podcast item.
func (PubDate) MarshalXML ¶
MarshalXML marshalls pubdate using the rfc2822 time format.