github.com/slspeek/camlistore_namedsearch@v0.0.0-20140519202248-ed6f70f7721a/pkg/importer/feed/rss/rss.go (about)

     1  // Copyright 2012 Evan Farrer. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // Package rss defines XML data structures for an RSS feed.
     6  package rss
     7  
     8  type RSS struct {
     9  	XMLName       string  `xml:"rss"`
    10  	Title         string  `xml:"channel>title"`
    11  	Link          []Link  `xml:"channel>link"`
    12  	Description   string  `xml:"channel>description"`
    13  	PubDate       string  `xml:"channel>pubDate,omitempty"`
    14  	LastBuildDate string  `xml:"channel>lastBuildDate,omitempty"`
    15  	Items         []*Item `xml:"channel>item"`
    16  }
    17  
    18  func (r *RSS) BaseLink() string {
    19  	for _, l := range r.Link {
    20  		if l.Rel == "" && l.Type == "" && l.Href == "" && l.Chardata != "" {
    21  			return l.Chardata
    22  		}
    23  	}
    24  	return ""
    25  }
    26  
    27  type Link struct {
    28  	Rel      string `xml:"rel,attr"`
    29  	Href     string `xml:"href,attr"`
    30  	Type     string `xml:"type,attr"`
    31  	Chardata string `xml:",chardata"`
    32  }
    33  
    34  type Item struct {
    35  	Title       string        `xml:"title,omitempty"`
    36  	Link        string        `xml:"link,omitempty"`
    37  	Description string        `xml:"description,omitempty"`
    38  	Author      string        `xml:"author,omitempty"`
    39  	Enclosure   *Enclosure    `xml:"enclosure"`
    40  	Guid        *Guid         `xml:"guid"`
    41  	PubDate     string        `xml:"pubDate,omitempty"`
    42  	Source      *Source       `xml:"source"`
    43  	Content     string        `xml:"encoded,omitempty"`
    44  	Date        string        `xml:"date,omitempty"`
    45  	Published   string        `xml:"published,omitempty"`
    46  	Media       *MediaContent `xml:"content"`
    47  }
    48  
    49  type MediaContent struct {
    50  	XMLBase string `xml:"http://search.yahoo.com/mrss/ content"`
    51  	URL     string `xml:"url,attr"`
    52  	Type    string `xml:"type,attr"`
    53  }
    54  
    55  type Source struct {
    56  	Source string `xml:",chardata"`
    57  	Url    string `xml:"url,attr"`
    58  }
    59  
    60  type Guid struct {
    61  	Guid        string `xml:",chardata"`
    62  	IsPermaLink bool   `xml:"isPermaLink,attr,omitempty"`
    63  }
    64  
    65  type Enclosure struct {
    66  	Url    string `xml:"url,attr"`
    67  	Length string `xml:"length,attr,omitempty"`
    68  	Type   string `xml:"type,attr"`
    69  }