easyrss

package module
v0.0.0-...-27531a6 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2015 License: MIT Imports: 7 Imported by: 0

README

easyrss

A Go library designed from the ground up to handle the complete RSS 2.0 specification with Itunes and MediaRSS extensions.

It features a very simple but powerful API with helpful logic to determine what kind of feed you're looking at and whether each field is available. Easyrss will also decode podcast episode durations, publication dates, and many other fields into appropriate Go objects like Time.Time and map[string][string].

Instead of relying on encoding/xml (which won't work on many feeds that deviate from the spec), easyrss uses libxml by way of the gokogiri bindings. This ensures a high degree of robustness for feeds that include non-standard fields and have non-complaint XML. Performance is on-par or faster than using encoding/XML directly.

installation

First, install libxml and its development headers by way of your package manager. Usually this is something like:

Ubuntu:

sudo apt-get install libxml2-dev libxml2 pkg-config

Fedora/CentOS/RHEL:

sudo apt-get install libxml2-devel

ArchLinux:

sudo pacman -S libxml2

Then install this package:

go get https://github.com/iamthebot/easyrss.git

Easy! Refer to godoc for complete API documentation.

Documentation

Overview

A high performance, robust library for parsing RSS1.0/2.0 Including Itunes and MediaRSS Extensions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Channel

type Channel struct {
	// contains filtered or unexported fields
}

type GUIDField

type GUIDField struct {
	IsPermaLink bool
	Content     string
}

type Image

type Image struct {
	// contains filtered or unexported fields
}

func (*Image) Height

func (i *Image) Height() (int, error)

Returns the url image width in pixels, if available. If not, a width of 0 is returned along with an error.

func (i *Image) Link() (string, error)

Returns the url where the image links to, if available. If not, an empty string is returned along with an error.

func (*Image) Title

func (i *Image) Title() (string, error)

Returns image title, if available. If not, an empty string is returned along with an error.

func (*Image) URL

func (i *Image) URL() (string, error)

Returns the url where the image is located, if available. If not, an empty string is returned along with an error.

func (*Image) Width

func (i *Image) Width() (int, error)

Returns the url image width in pixels, if available. If not, a width of 0 is returned along with an error.

type Item

type Item struct {
	// contains filtered or unexported fields
}

func (Item) Date

func (i Item) Date() (*time.Time, error)

Returns the item date. If the item date is not populated, you'll get nil and an error.

func (Item) Description

func (i Item) Description() (string, error)

Returns the item . If the item title is not populated, you'll get an empty string and an error.

func (Item) EnclosureURL

func (i Item) EnclosureURL() string

The media enclosure url.

func (Item) HasEnclosure

func (i Item) HasEnclosure() bool

Whether or not the item has a media enclosure.

func (*Item) ItunesAuthor

func (i *Item) ItunesAuthor() (string, error)

Returns the Itunes "author" field for the item. If the item doesn't contain ITunes Extensions or hasn't populated the Itunes "author" field, will return an empty string and an error

func (Item) ItunesDuration

func (i Item) ItunesDuration() (*time.Duration, error)

Returns Itunes episode duration. If this information wasn't available or the item doesn't contain Itunes Extensions then we return nil and an error.

func (*Item) ItunesImage

func (i *Item) ItunesImage() (*Image, error)

Returns the Itunes "image" field for the item. If the item doesn't contain ITunes Extensions or hasn't populated the Itunes "image" field, will return nil and an error.

func (*Item) ItunesSubtitle

func (i *Item) ItunesSubtitle() (string, error)

Returns the Itunes "author" field for the item. If the item doesn't contain ITunes Extensions or hasn't populated the Itunes "subtitle" field, will return an empty string and an error

func (*Item) ItunesSummary

func (i *Item) ItunesSummary() (string, error)

Returns the Itunes "summary" field for the item. If the item doesn't contain ITunes Extensions or hasn't populated the Itunes "summary" field, will return an empty string and an error

func (i Item) Link() (string, error)

Returns the item link. If the item link is not populated, you'll get an empty string and an error.

func (Item) Title

func (i Item) Title() (string, error)

Returns the item title. If the item title is not populated, you'll get an empty string and an error.

type ItunesMeta

type ItunesMeta struct {
	// contains filtered or unexported fields
}

type MediaChannelMeta

type MediaChannelMeta struct {
	// contains filtered or unexported fields
}

MediaRSS Channel Metadata

type MediaMeta

type MediaMeta struct {
	// contains filtered or unexported fields
}

MediaRSS Item Metadata

type RSS

type RSS struct {
	// contains filtered or unexported fields
}

func Decode

func Decode(data []byte) (*RSS, error)

Pass in a byte slice containing the feed, get an *RSS back. You can then explore the feed easily.

func (*RSS) Categories

func (r *RSS) Categories() ([]string, error)

Returns the feed categories. If no category tags were found for the channel, you'll get a nil result with an accompanying error.

func (*RSS) Description

func (r *RSS) Description() (string, error)

Returns the feed description. If the field is not populated, will return an empty string and an error.

func (*RSS) Generator

func (r *RSS) Generator() (string, error)

Returns the feed generator. If the field is not populated, will return an empty string and an error.

func (*RSS) IsItunes

func (r *RSS) IsItunes() bool

Whether or not this feed implements ItunesRSS Extensions

func (*RSS) IsMRSS

func (r *RSS) IsMRSS() bool

Whether or not this feed implements MediaRSS Extensions

func (*RSS) Items

func (r *RSS) Items() ([]Item, error)

Returns available feed items. Will return an error if the feed is empty.

func (*RSS) ItunesAuthor

func (r *RSS) ItunesAuthor() (string, error)

Returns the Itunes "author" field for the channel. If the channel doesn't contain ITunes Extensions or hasn't populated the channel-wide Itunes "author" field, will return an empty string and an error

func (*RSS) ItunesExplicit

func (r *RSS) ItunesExplicit() (string, error)

Returns the Itunes "explicit" field for the channel. If the channel doesn't contain ITunes Extensions or hasn't populated the channel-wide Itunes "explicit" field, will return an empty string and an error func (r *RSS) ItunesExplicit() (string, error) {

func (*RSS) ItunesImage

func (r *RSS) ItunesImage() (*Image, error)

Returns the Itunes "image" field for the channel. If the channel doesn't contain ITunes Extensions or hasn't populated the channel-wide Itunes "image" field, will return nil and an error.

func (*RSS) ItunesSubtitle

func (r *RSS) ItunesSubtitle() (string, error)

Returns the Itunes "author" field for the channel. If the channel doesn't contain ITunes Extensions or hasn't populated the channel-wide Itunes "subtitle" field, will return an empty string and an error

func (*RSS) ItunesSummary

func (r *RSS) ItunesSummary() (string, error)

Returns the Itunes "summary" field for the channel. If the channel doesn't contain ITunes Extensions or hasn't populated the channel-wide Itunes "summary" field, will return an empty string and an error

func (*RSS) Keywords

func (r *RSS) Keywords() ([]string, error)

MediaRSS Feed keywords. If the MRSS feed "keywords" field is not populated or if the feed doesn't implement MediaRSS extensions, this will return nil and an error.

func (*RSS) Language

func (r *RSS) Language() (string, error)

Returns the feed language. This isn't always that standardized so be careful while parsing the field. An empty string and error will be returned if the field is not populated.

func (*RSS) MRSSCategories

func (r *RSS) MRSSCategories() ([]string, error)

MediaRSS Feed categories. If the MRSS feed "categories" field is not populated or if the feed doesn't implement MediaRSS extensions, this will return nil and an error.

func (*RSS) MRSSCopyright

func (r *RSS) MRSSCopyright() (string, error)

MediaRSS Feed Copyright. If the MRSS feed "copyright" field is not populated or if the feed doesn't implement MediaRSS extensions, you'll receive an empty string and an error.

func (*RSS) MRSSRating

func (r *RSS) MRSSRating() (string, error)

MediaRSS Feed Rating. If the MRSS feed "rating" field is not populated or if the feed doesn't implement MediaRSS extensions, you'll receive an empty string and an error.

func (*RSS) Thumbnail

func (r *RSS) Thumbnail() (*Image, error)

Returns the Itunes "image" field for the channel. If the channel doesn't contain ITunes Extensions or hasn't populated the channel-wide Itunes "image" field, will return nil and an error.

func (*RSS) Title

func (r *RSS) Title() (string, error)

Returns the feed title. If the field is not populated, will return an empty string and an error.

type RSSEnclosure

type RSSEnclosure struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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