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