gopod

package module
v0.0.0-...-33034c7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2023 License: MIT Imports: 4 Imported by: 0

README

About

This is a library implementing an RSS/Podcast feed generator for the Go programming language (http://golang.org/).

RSS (Rich Site Summary, or Really Simple Syndication) is a data format used to publish frequently updated works - such as blog entries, news headlines, audio and video - in a standardized format. Podcasts utilize this format to deliver audio and video files and assiciated metadata.

An RSS document (which is called a "feed", "web feed", or "channel") includes full or summarized text, plus metadata such as publishing dates and authorship.

Installing

$ go get github.com/jbckmn/gopod

Example

The best example is in the test file

Docs

http://godoc.org/github.com/jbckmn/gopod

Documentation

Overview

Package gopod implements a RSS/Podcast 2.0 feed generator

RSS (Rich Site Summary, or Really Simple Syndication) is a data format used to publish frequently updated works - such as blog entries, news headlines, audio and video - in a standardized format. Podcasts utilize this format to deliver audio and video files and assiciated metadata.

An RSS document (which is called a "feed", "web feed", or "channel") includes full or summarized text, plus metadata such as publishing dates and authorship.

Spec located at: http://cyber.law.harvard.edu/rss/rss.html

Example Usage

c := gopod.ChannelFavtory("Ruby Developer", "http://RubyDeveloper.com/", "Ruby Developer Blog", "http://example.com/image.png")
c.AddItem(&gopod.Item{
	Title:"Ruby Developer",
	Link:"http://RubyDeveloper.com/",
	Description:"My Blog",
	PubDate:time.Now().Unix(),
})
c.AddItem(&gopod.Item{
	Title:"Stack Overflow",
	Link:"http://stackoverflow.com/users/1305696/daniel",
	Description:"My Stack Overflow",
	PubDate:time.Now().Unix(),
})
c.AddItem(&gopod.Item{
	Title:"LinkedIn",
	Link:"http://www.linkedin.com/in/dangogh",
	Description:"My LinkedIn",
	PubDate:time.Now().Unix(),
})
output := c.Publish()

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AtomLink struct {
	Href string `xml:"href,attr"`
	Rel  string `xml:"rel,attr"`
	Type string `xml:"type,attr"`

	XMLName xml.Name `xml:"atom:link"`
}

type Channel

type Channel struct {
	// The name of the channel. It's how people refer to your service. If you have
	// an HTML website that contains the same information as your RSS file, the
	// title of your channel should be the same as the title of your website.
	Title string `xml:"title"`
	// The URL to the HTML website corresponding to the channel.
	Link string `xml:"link"`
	// Phrase or sentence describing the channel.
	Description string `xml:"description"`

	/////////////////////
	// Optional Fields //
	/////////////////////
	Language       string `xml:"language,omitempty"`
	Copyright      string `xml:"copyright,omitempty"`
	ManagingEditor string `xml:"managingEditor,omitempty"`
	WebMaster      string `xml:"webMaster,omitempty"`
	PubDate        string `xml:"pubDate,omitempty"`
	LastBuildDate  string `xml:"lastBuildDate,omitempty"`
	Category       string `xml:"category,omitempty"`
	Generator      string `xml:"generator,omitempty"`
	Docs           string `xml:"docs,omitempty"`
	TTL            string `xml:"ttl,omitempty"`
	SkipHours      string `xml:"skiphours,omitempty"`
	SkipDays       string `xml:"skipdays,omitempty"`
	TunesAuthor    string `xml:"itunes:author,omitempty"`
	TunesSubtitle  string `xml:"itunes:subtitle,omitempty"`
	TunesSummary   string `xml:"itunes:summary,omitempty"`
	TunesExplicit  string `xml:"itunes:explicit,omitempty"`

	TunesOwner []*TunesOwner
	TunesImage []*TunesImage
	AtomLink   []*AtomLink
	Items      []*Item

	// Stub member just for the xml generator.
	XMLName xml.Name `xml:"channel"`
}

func ChannelFactory

func ChannelFactory(Title string, Link string, Description string, Image string) *Channel

Use this to create the base channel of the rss feed. The Title is the name of the channel. It's how people refer to your service. If you have an HTML website that contains the same information as your RSS file, the title of your channel should be the same as the title of your website. The Link is the URL to the HTML website corresponding to the channel. The Description is the phrase or sentence describing the channel. The Image is the image to be displayed with the podcast.

func (*Channel) AddItem

func (c *Channel) AddItem(i *Item)

Add an item to the feed list

func (*Channel) Publish

func (c *Channel) Publish() []byte

Publish the prepared rss feed without indentation

func (*Channel) PublishIndent

func (c *Channel) PublishIndent() []byte

Publish the prepared rss feed with indentation

func (*Channel) SetCategory

func (c *Channel) SetCategory(cat string)

(optional) Set the category field. The category field specifies one or more categories that the channel belongs to. It follows the same rules as the <item>-level category element. ( http://cyber.law.harvard.edu/rss/rss.html#syndic8 )

func (*Channel) SetCopyright

func (c *Channel) SetCopyright(Copyright string)

(optional) Set the channel's Copyright notice for content.

func (*Channel) SetDocs

func (c *Channel) SetDocs(docs string)

(optional) Set the docs field. The docs field is a URL that points to the documentation for the format used in the RSS file. It's usually a pointer to "http://cyber.law.harvard.edu/rss/rss.html". It's for people who might stumble across an RSS file on a Web server 25 years from now and wonder what it is.

func (*Channel) SetGenerator

func (c *Channel) SetGenerator(gen string)

(optional) Set generator field. The generator field is a string indicating the program used to generate the rss feed.

func (*Channel) SetLanguage

func (c *Channel) SetLanguage(Language string)

(optional) Set the channel's language field to the language the channel is written in. This allows aggregators to group all Italian language sites, for example, on a single page. A list of allowable values for this element, as provided by Netscape ( http://cyber.law.harvard.edu/rss/languages.html ). You may also use values defined by the W3C ( http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes )

func (*Channel) SetLastBuildDate

func (c *Channel) SetLastBuildDate(t interface{})

(optional) Set the lastBuildDate field. The lastBuildDate is The last time the content of the channel changed. This method can take an instance of time.Time, a Unix timestamp (int64) or a raw string.

func (*Channel) SetManagingEditor

func (c *Channel) SetManagingEditor(ManagingEditor string)

(optional) Set the channel's ManagingEditor field. The ManagingEditor field should contain the email address for the person responsible for editorial content.

func (*Channel) SetPubDate

func (c *Channel) SetPubDate(t interface{})

(optional) Set the channel's pubDate field. This method can take an instance of time.Time, a unix timestamp (int64) or a raw string to use for the date. The date should represent the publication date for the content in the channel. For example, the New York Times publishes on a daily basis, the publication date flips once every 24 hours. That's when the pubDate of the channel changes. All date-times in RSS conform to the Date and Time Specification of RFC 822, with the exception that the year may be expressed with two characters or four characters (four preferred).

func (*Channel) SetSkipDays

func (c *Channel) SetSkipDays(skipdays string)

(optional) Set the channel's skipHous field. The skipHours field is a hint for aggregators telling them which hours they can skip. More info: http://cyber.law.harvard.edu/rss/skipHoursDays.html#skiphours

func (*Channel) SetSkipHours

func (c *Channel) SetSkipHours(skiphours string)

(optional) Set the channel's skipDays field. The skipDays field is a hint for aggregators telling them which days they can skip. More info: http://cyber.law.harvard.edu/rss/skipHoursDays.html#skipdays

func (*Channel) SetTTL

func (c *Channel) SetTTL(ttl string)

(optional) Set the TTL field. TTL stands for time to live. It's a number of minutes that indicate how long a channel can be cached before refreshing from the source. More info here: http://cyber.law.harvard.edu/rss/rss.html#ltttlgtSubelementOfLtchannelgt

func (*Channel) SetTunesImage

func (c *Channel) SetTunesImage(i *TunesImage)

Add an image struct to the feed

func (*Channel) SetWebMaster

func (c *Channel) SetWebMaster(WebMaster string)

(optional) Set the channel's webMaster field. The webmaster field should contain the email address of person responsible for technical issues relating to channel

func (*Channel) SetiTunesAuthor

func (c *Channel) SetiTunesAuthor(author string)

(optional) Set the channel's iTunes Author field.

func (*Channel) SetiTunesExplicit

func (c *Channel) SetiTunesExplicit(explicit string)

(optional) Set the channel's iTunes Explicit field.

func (*Channel) SetiTunesOwner

func (c *Channel) SetiTunesOwner(name string, email string)

(optional) Set the channel's iTunes Owner struct.

func (*Channel) SetiTunesSubtitle

func (c *Channel) SetiTunesSubtitle(subtitle string)

(optional) Set the channel's iTunes Subtitle field.

func (*Channel) SetiTunesSummary

func (c *Channel) SetiTunesSummary(summary string)

(optional) Set the channel's iTunes Summary field.

type Enclosure

type Enclosure struct {
	Url    string `xml:"url,attr"`
	Length string `xml:"length,attr"`
	Type   string `xml:"type,attr"`

	XMLName xml.Name `xml:"enclosure"`
}

type Item

type Item struct {
	//The URL of the item.
	Link string `xml:"link"`

	// The item synopsis.
	Description string `xml:"description"`

	// The title of the item.
	Title string `xml:"title,omitempty"`

	// Indicates when the item was published.
	// http://cyber.law.harvard.edu/rss/rss.html#ltpubdategtSubelementOfLtitemgt
	PubDate string `xml:"pubDate,omitempty"`

	// Email address of the author of the item.
	// http://cyber.law.harvard.edu/rss/rss.html#ltauthorgtSubelementOfLtitemgt
	Author string `xml:"author,omitempty"`

	// A string that uniquely identifies the item.
	// http://cyber.law.harvard.edu/rss/rss.html#ltguidgtSubelementOfLtitemgt
	Guid string `xml:"guid,omitempty"`

	// URL of a page for comments relating to the item.
	// http://cyber.law.harvard.edu/rss/rss.html#ltcommentsgtSubelementOfLtitemgt
	Comments string `xml:"comments,omitempty"`

	Creator       string `xml:"dc:creator,omitempty"`
	TunesAuthor   string `xml:"itunes:author,omitempty"`
	TunesSubtitle string `xml:"itunes:subtitle,omitempty"`
	TunesSummary  string `xml:"itunes:summary,omitempty"`
	TunesExplicit string `xml:"itunes:explicit,omitempty"`
	TunesDuration string `xml:"itunes:duration,omitempty"`

	Enclosure []*Enclosure

	// Stub member just for the xml generator.
	XMLName xml.Name `xml:"item"`
}

func (*Item) SetEnclosure

func (i *Item) SetEnclosure(url string, length string, eType string)

(optional) Set the item's iTunes Enclosure struct.

func (*Item) SetPubDate

func (i *Item) SetPubDate(t interface{})

(optional) Set the item's pubDate field. This method can take an instance of time.Time, a unix timestamp (int64) or a raw string to use for the date. The date should represent the publication date for the content in the channel. For example, the New York Times publishes on a daily basis, the publication date flips once every 24 hours. That's when the pubDate of the channel changes. All date-times in RSS conform to the Date and Time Specification of RFC 822, with the exception that the year may be expressed with two characters or four characters (four preferred).

type TunesImage

type TunesImage struct {
	Href string `xml:"href,attr"`

	XMLName xml.Name `xml:"itunes:image"`
}

type TunesOwner

type TunesOwner struct {
	Name  string `xml:"itunes:name,omitempty"`
	Email string `xml:"itunes:email,omitempty"`

	XMLName xml.Name `xml:"itunes:owner"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL