-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnamespace_rss.go
52 lines (45 loc) · 1.27 KB
/
namespace_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
package types
import (
"encoding/xml"
)
// RSSVersion denotes the RSS version.
type RSSVersion string
func (rssVersion RSSVersion) MarshalXMLAttr(name xml.Name) (xml.Attr, error) {
if rssVersion != "" {
return xml.Attr{Name: xml.Name{Local: "version"}, Value: string(rssVersion)}, nil
}
return xml.Attr{Name: xml.Name{Local: "version"}, Value: "2.0"}, nil
}
// Description is used for podcast's or episode's description.
type Description struct {
XMLName xml.Name `xml:"description"`
Description string
IsCDATA bool
}
func (d Description) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
if d.IsCDATA {
return e.EncodeElement(struct {
Description string `xml:",cdata"`
}{
Description: d.Description,
}, start)
}
return e.EncodeElement(struct {
Description string `xml:",chardata"`
}{
Description: d.Description,
}, start)
}
// Enclosure is used to link to the episode's media file.
type Enclosure struct {
XMLName xml.Name `xml:"enclosure"`
URL string `xml:"url,attr"`
Length int64 `xml:"length,attr"`
Mimetype string `xml:"type,attr"`
}
// GUID is a unique identifier for an episode.
type GUID struct {
XMLName xml.Name `xml:"guid"`
GUID string `xml:",chardata"`
IsPermaLink *bool `xml:"isPermaLink,attr"`
}