...

Package rss

import "simonwaldherr.de/go/golibs/rss"
Overview
Index

Overview ▾

Package rss provides a RSS parser

type Client

Client is a http client to crawl the feed from (#)

type Client interface {
    Get(url string) (resp *http.Response, err error)
}

type Image

Image contains the URL and title of the podcast logo

type Image struct {
    URL   string `xml:"url"`
    Title string `xml:"title"`
}

type Item

Item represents an episode with all of its content

type Item struct {
    Title       string          `xml:"title"`
    Link        string          `xml:"link"`
    Comments    string          `xml:"comments"`
    PubDate     string          `xml:"pubDate"`
    GUID        string          `xml:"guid"`
    Category    []string        `xml:"category"`
    Enclosure   []ItemEnclosure `xml:"enclosure"`
    Description string          `xml:"description"`
    Content     string          `xml:"content"`
}

func (*Item) Time

func (episode *Item) Time() time.Time

Time returns the specified publication date as time.Time

type ItemEnclosure

ItemEnclosure contains an URL and its MIME-Type of an episode file

type ItemEnclosure struct {
    URL  string `xml:"url,attr"`
    Type string `xml:"type,attr"`
}

type Main

Main struct represents the root of the RSS feed

type Main struct {
    Title         string `xml:"title"`
    Link          string `xml:"link"`
    Copyright     string `xml:"copyright"`
    Description   string `xml:"description"`
    Generator     string `xml:"generator"`
    Language      string `xml:"language"`
    LastBuildDate string `xml:"lastBuildDate"`
    Items         []Item `xml:"item"`
    Image         Image  `xml:"image"`
}

func Read

func Read(url string) (*Main, error)

Read reads from an URL with the Golang default http client and returns rss.Main

func ReadCustomClient

func ReadCustomClient(url string, client Client) (*Main, error)

ReadCustomClient allows to read with an custom http client

func (*Main) Len

func (rss *Main) Len() int

Len returns the episode count

func (*Main) Time

func (rss *Main) Time() time.Time

Time returns the specified last build date as time.Time