jsonfeed

package
v0.0.0-...-9b45353 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2018 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

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

This section is empty.

Variables

View Source
var Plugin = &dc.Plugin{
	Name: "jsonfeed",
	ConfigCreator: func(url string, ho *dc.HandlerOpts) (string, *dc.Config, error) {
		f, err := getFeed(context.TODO(), ho.Client, url)
		if err != nil {
			return "", nil, err
		}

		return f.Title, &dc.Config{
			Type:        dc.FullScrape,
			Entrypoints: []string{url},
		}, nil
	},
	Entrypoints: []string{".*"},
	Scheduler:   dc.DefaultScheduler,
	Routes: map[string]dc.Handler{
		`(.*)`: jsonFeed,
	},
}

Plugin is a plugin that can scrape rss feeds TODO: - [ ] strip images that don't matter

Functions

This section is empty.

Types

type JSONAttachment

type JSONAttachment struct {
	URL      string        `json:"url,omitempty"`
	MIMEType string        `json:"mime_type,omitempty"`
	Title    string        `json:"title,omitempty"`
	Size     int32         `json:"size,omitempty"`
	Duration time.Duration `json:"duration_in_seconds,omitempty"`
}

JSONAttachment represents a related resource. Podcasts, for instance, would include an attachment that’s an audio or video file.

func (*JSONAttachment) MarshalJSON

func (a *JSONAttachment) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface. The Duration field is marshaled in seconds, all other fields are marshaled based upon the definitions in struct tags.

func (*JSONAttachment) UnmarshalJSON

func (a *JSONAttachment) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface. The Duration field is expected to be in seconds, all other field types match the struct definition.

type JSONAuthor

type JSONAuthor struct {
	Name   string `json:"name,omitempty"`
	URL    string `json:"url,omitempty"`
	Avatar string `json:"avatar,omitempty"`
}

JSONAuthor represents the author of the feed or of an individual item in the feed

type JSONFeed

type JSONFeed struct {
	Version     string      `json:"version"`
	Title       string      `json:"title"`
	HomePageURL string      `json:"home_page_url,omitempty"`
	FeedURL     string      `json:"feed_url,omitempty"`
	Description string      `json:"description,omitempty"`
	UserComment string      `json:"user_comment,omitempty"`
	NextURL     string      `json:"next_url,omitempty"`
	Icon        string      `json:"icon,omitempty"`
	Favicon     string      `json:"favicon,omitempty"`
	Author      *JSONAuthor `json:"author,omitempty"`
	Expired     *bool       `json:"expired,omitempty"`
	Hubs        []*JSONItem `json:"hubs,omitempty"`
	Items       []*JSONItem `json:"items,omitempty"`
}

JSONFeed represents a syndication feed in the JSON Feed Version 1 format. Matching the specification found here: https://jsonfeed.org/version/1.

type JSONHub

type JSONHub struct {
	Type string `json:"type"`
	URL  string `json:"url"`
}

JSONHub describes an endpoint that can be used to subscribe to real-time notifications from the publisher of this feed.

type JSONItem

type JSONItem struct {
	ID            string           `json:"id"`
	URL           string           `json:"url,omitempty"`
	ExternalURL   string           `json:"external_url,omitempty"`
	Title         string           `json:"title,omitempty"`
	ContentHTML   string           `json:"content_html,omitempty"`
	ContentText   string           `json:"content_text,omitempty"`
	Summary       string           `json:"summary,omitempty"`
	Image         string           `json:"image,omitempty"`
	BannerImage   string           `json:"banner_,omitempty"`
	PublishedDate *time.Time       `json:"date_published,omitempty"`
	ModifiedDate  *time.Time       `json:"date_modified,omitempty"`
	Author        *JSONAuthor      `json:"author,omitempty"`
	Tags          []string         `json:"tags,omitempty"`
	Attachments   []JSONAttachment `json:"attachments,omitempty"`
}

JSONItem represents a single entry/post for the feed.

Jump to

Keyboard shortcuts

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