rss2

package module
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: May 26, 2020 License: BSD-3-Clause Imports: 5 Imported by: 2

README

rss2

A Golang package for working with RSS 2 feeds and documents. It includes a single cli proof of concept program called rss2json.

Documentation

Overview

rss2 is a golang package for working with RSS 2 feeds and documents.

@author R. S. Doiel, <rsdoiel@caltech.edu>

Copyright (c) 2018, Caltech All rights not granted herein are expressly reserved by Caltech.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Index

Constants

View Source
const Version = `v0.0.6`

Variables

This section is empty.

Functions

This section is empty.

Types

type CData added in v0.0.6

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

func (*CData) Set added in v0.0.6

func (cdata *CData) Set(src string)

func (*CData) String added in v0.0.6

func (cdata *CData) String() string

func (*CData) ToJSON added in v0.0.6

func (cdata *CData) ToJSON() string

type CustomAttrs

type CustomAttrs []xml.Attr

func (CustomAttrs) MarshalJSON

func (cattr CustomAttrs) MarshalJSON() ([]byte, error)

MarshalJSON() marshals the custom attributes that might be included in an RSS feed.

type Item

type Item struct {
	XMLName xml.Name `xml:"item,omitempty" json:"-"`
	// Optional according to Dave Winer
	Title string `xml:"title" json:"title,omitempty"`

	// Required
	Link string `xml:"link" json:"link"`

	// Optional
	Author      string      `xml:"author,omitempty" json:"author,omitempty"`
	Description string      `xml:"description,omitempty" json:"description,omitempty"`
	Category    string      `xml:"category,omitempty" json:"category,omitempty"`
	Content     string      `xml:"encoded,omitempty" json:"encoded,omitempty"`
	PubDate     string      `xml:"pubDate,omitempty" json:"pubDate,omitempty"`
	Comments    string      `xml:"comments,omitempty" json:"comments,omitempty"`
	Enclosure   string      `xml:"enclosure,omitempty" json:"enclosure,omitempty"`
	GUID        string      `xml:"guid,omitempty" json:"guid,omitempty"`
	Source      string      `xml:"source,omitempty" json:"source,omitempty"`
	OtherAttr   CustomAttrs `xml:",any,attr" json:"other_attrs,omitempty"`
}

type RSS2

type RSS2 struct {
	XMLName xml.Name `xml:"rss" json:"-"`
	Version string   `xml:"version,attr" json:"version"`

	// Required
	Title       string `xml:"channel>title" json:"title"`
	Link        string `xml:"channel>link" json:"link"`
	Description string `xml:"channel>description" json:"description"`

	// Optional
	Language       string `xml:"channel>language,omitempty" json:"language,omitempty"`
	Copyright      string `xml:"channel>copyright,omitempty" json:"copyright,omitempty"`
	ManagingEditor string `xml:"channel>managingEditor,omitempty" json:"managingEditor,omitempty"`
	WebMaster      string `xml:"channel>webMaster,omitempty" json:"webMaster,omitempty"`
	PubDate        string `xml:"channel>pubDate,omitempty" json:"pubDate,omitempty"`
	LastBuildDate  string `xml:"channel>lastBuildDate,omitempty" json:"lastBuildDate,omitempty"`
	Category       string `xml:"channel>category,omitempty" json:"category,omitempty"`
	Generator      string `xml:"channel>generator,omitempty" json:"generator,omitempty"`
	Docs           string `xml:"channel>docs,omitempty" json:"docs,omitempty"`
	Cloud          string `xml:"channel>cloud,omitempty" json:"cloud,omitempty"`
	TTL            string `xml:"channel>ttl,omitempty" json:"ttl,omitempty"`
	Image          string `xml:"channel>image,omitempty" json:"image,omitempty"`
	Rating         string `xml:"channel>rating,omitempty" json:"rating,omitempty"`
	SkipHours      string `xml:"channel>skipHours,omitempty" json:"skipHours,omitempty"`
	SkipDays       string `xml:"channel>skipDays,omitempty" json:"skipDays,omitempty"`
	ItemList       []Item `xml:"channel>item,omitempty" json:"item,omitempty"`
}

func Parse

func Parse(buf []byte) (*RSS2, error)

Parse return an RSS2 document as a RSS2 structure.

func (*RSS2) Filter

func (r *RSS2) Filter(dataPaths []string) (map[string]interface{}, error)

Filter given an RSS2 document return all the entries matching so we can apply return each of the data paths requested. e.g. .version, .channel.title, .channel.link, .item[].link, .item[].guid, .item[].title, .item[].description

Directories

Path Synopsis
cmd
rss2json
rss2json is a command line utility that can read in an RSS 2 file and return it in JSON format.
rss2json is a command line utility that can read in an RSS 2 file and return it in JSON format.

Jump to

Keyboard shortcuts

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