feed

package
v1.0.1-0...-a7812af Latest Latest
Warning

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

Go to latest
Published: May 11, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package feed describes RSS format and provides parsing

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Atom1

type Atom1 struct {
	XMLName   xml.Name `xml:"http://www.w3.org/2005/Atom feed"`
	Title     string   `xml:"title"`
	Subtitle  string   `xml:"subtitle"`
	ID        string   `xml:"id"`
	Updated   string   `xml:"updated"`
	Rights    string   `xml:"rights"`
	Link      Link     `xml:"link"`
	Author    Author   `xml:"author"`
	EntryList []Entry  `xml:"entry"`
}

Atom1 is atom feed

type Author

type Author struct {
	Name  string `xml:"name"`
	Email string `xml:"email"`
}

Author element for xml

type Enclosure

type Enclosure struct {
	URL    string `xml:"url,attr"`
	Length int    `xml:"length,attr"`
	Type   string `xml:"type,attr"`
}

Enclosure element from item

type Entry

type Entry struct {
	Title     string    `xml:"title"`
	Summary   string    `xml:"summary"`
	Content   string    `xml:"content"`
	ID        string    `xml:"id"`
	Updated   string    `xml:"updated"`
	Link      Link      `xml:"link"`
	Author    Author    `xml:"author"`
	Enclosure Enclosure `xml:"enclosure"`
}

Entry from atom

type Item

type Item struct {
	// Required
	Title       string        `xml:"title"`
	Link        string        `xml:"link"`
	Description template.HTML `xml:"description"`
	Enclosure   Enclosure     `xml:"enclosure"`
	GUID        string        `xml:"guid"`
	// Optional
	Content  template.HTML `xml:"encoded,omitempty"`
	PubDate  string        `xml:"pubDate,omitempty"`
	Comments string        `xml:"comments,omitempty"`
	Author   string        `xml:"author,omitempty"`
	Duration string        `xml:"duration,omitempty"`
	// Internal
	DT          time.Time `xml:"-"`
	Junk        bool      `xml:"-"`
	DurationFmt string    `xml:"-"` // used for ui only in
}

Item for rss

func (Item) DownloadAudio

func (item Item) DownloadAudio(timeout time.Duration) (res io.ReadCloser, err error)

DownloadAudio return httpBody for Item's Enclosure.URL

func (Item) GetFilename

func (item Item) GetFilename() string

GetFilename returns the filename for Item's Enclosure.URL

type ItunesImg

type ItunesImg struct {
	XMLName xml.Name `xml:"itunes:image,omitempty"`
	URL     string   `xml:"href,attr"`
}

ItunesImg image element for iTunes

type ItunesOwner

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

ItunesOwner owner element for iTunes

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

Link element for xml

type MediaThumbnail

type MediaThumbnail struct {
	XMLName xml.Name `xml:"media:thumbnail,omitempty"`
	URL     string   `xml:"url,attr"`
}

MediaThumbnail image element for media

type Rss2

type Rss2 struct {
	XMLName        xml.Name        `xml:"rss"`
	Version        string          `xml:"version,attr"`
	NsItunes       string          `xml:"xmlns:itunes,attr"`
	NsMedia        string          `xml:"xmlns:media,attr"`
	Title          string          `xml:"channel>title"`
	Language       string          `xml:"channel>language"`
	Link           string          `xml:"channel>link"`
	Description    string          `xml:"channel>description"`
	PubDate        string          `xml:"channel>pubDate"`
	LastBuildDate  string          `xml:"channel>lastBuildDate"`
	ItunesImage    *ItunesImg      `xml:"channel>itunes:image"`
	MediaThumbnail *MediaThumbnail `xml:"channel>media:thumbnail"`
	ItunesAuthor   string          `xml:"channel>itunes:author"`
	ItunesExplicit string          `xml:"channel>itunes:explicit"`
	ItunesOwner    *ItunesOwner    `xml:"channel>itunes:owner"`
	ItemList       []Item          `xml:"channel>item"`
}

Rss2 feed

func Parse

func Parse(uri string) (result Rss2, err error)

Parse gets url to rss feed and returns Rss2 items

func (*Rss2) Normalize

func (rss *Rss2) Normalize() (Rss2, error)

Normalize converts to RFC822 = "02 Jan 06 15:04 MST"

Jump to

Keyboard shortcuts

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