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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
// SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
package rss // import "miniflux.app/v2/internal/reader/rss"
import (
"encoding/xml"
"strconv"
"strings"
"miniflux.app/v2/internal/reader/dublincore"
"miniflux.app/v2/internal/reader/googleplay"
"miniflux.app/v2/internal/reader/itunes"
"miniflux.app/v2/internal/reader/media"
)
// Specs: https://www.rssboard.org/rss-specification
type RSS struct {
Version string `xml:"rss version,attr"`
Channel RSSChannel `xml:"rss channel"`
}
type RSSChannel struct {
Title string `xml:"rss title"`
Link string `xml:"rss link"`
Description string `xml:"rss description"`
Language string `xml:"rss language"`
Copyright string `xml:"rss copyRight"`
ManagingEditor string `xml:"rss managingEditor"`
Webmaster string `xml:"rss webMaster"`
PubDate string `xml:"rss pubDate"`
LastBuildDate string `xml:"rss lastBuildDate"`
Categories []string `xml:"rss category"`
Generator string `xml:"rss generator"`
Docs string `xml:"rss docs"`
Cloud *RSSCloud `xml:"rss cloud"`
Image *RSSImage `xml:"rss image"`
TTL string `xml:"rss ttl"`
SkipHours []string `xml:"rss skipHours>hour"`
SkipDays []string `xml:"rss skipDays>day"`
Items []RSSItem `xml:"rss item"`
AtomLinks
itunes.ItunesChannelElement
googleplay.GooglePlayChannelElement
}
type RSSCloud struct {
Domain string `xml:"domain,attr"`
Port string `xml:"port,attr"`
Path string `xml:"path,attr"`
RegisterProcedure string `xml:"registerProcedure,attr"`
Protocol string `xml:"protocol,attr"`
}
type RSSImage struct {
// URL is the URL of a GIF, JPEG or PNG image that represents the channel.
URL string `xml:"url"`
// Title describes the image, it's used in the ALT attribute of the HTML <img> tag when the channel is rendered in HTML.
Title string `xml:"title"`
// Link is the URL of the site, when the channel is rendered, the image is a link to the site.
Link string `xml:"link"`
}
type RSSItem struct {
Title string `xml:"rss title"`
Link string `xml:"rss link"`
Description string `xml:"rss description"`
Author RSSAuthor `xml:"rss author"`
Categories []string `xml:"rss category"`
CommentsURL string `xml:"rss comments"`
Enclosures []RSSEnclosure `xml:"rss enclosure"`
GUID RSSGUID `xml:"rss guid"`
PubDate string `xml:"rss pubDate"`
Source RSSSource `xml:"rss source"`
dublincore.DublinCoreItemElement
FeedBurnerItemElement
media.MediaItemElement
AtomAuthor
AtomLinks
itunes.ItunesItemElement
googleplay.GooglePlayItemElement
}
type RSSAuthor struct {
XMLName xml.Name
Data string `xml:",chardata"`
Inner string `xml:",innerxml"`
}
type RSSEnclosure struct {
URL string `xml:"url,attr"`
Type string `xml:"type,attr"`
Length string `xml:"length,attr"`
}
func (enclosure *RSSEnclosure) Size() int64 {
if strings.TrimSpace(enclosure.Length) == "" {
return 0
}
size, _ := strconv.ParseInt(enclosure.Length, 10, 0)
return size
}
type RSSGUID struct {
Data string `xml:",chardata"`
IsPermaLink string `xml:"isPermaLink,attr"`
}
type RSSSource struct {
URL string `xml:"url,attr"`
Name string `xml:",chardata"`
}
|