-
Notifications
You must be signed in to change notification settings - Fork 1
/
namespace_itunes.go
54 lines (44 loc) · 1.39 KB
/
namespace_itunes.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
package types
import (
"encoding/xml"
"strconv"
"time"
)
// NamespaceITunes is the iTunes namespace.
const NamespaceITunes string = "http://www.itunes.com/dtds/podcast-1.0.dtd"
// ITunesOwner is used for owner's contact information.
type ITunesOwner struct {
XMLName xml.Name `xml:"itunes:owner"`
Name string `xml:"itunes:name"`
Email string `xml:"itunes:email"`
}
// ITunesCategory denotes podcast's category information.
type ITunesCategory struct {
XMLName xml.Name `xml:"itunes:category"`
Category string `xml:"text,attr"`
Subcategory *ITunesSubcategory `xml:"itunes:category"`
}
// ITunesSubcategory is more granural; it is a subset of Category.
type ITunesSubcategory string
func (s ITunesSubcategory) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
return e.EncodeElement(struct {
Category string `xml:"text,attr"`
}{
Category: string(s),
}, start)
}
// ITunesImage is podcast's or episode's artwork.
type ITunesImage struct {
XMLName xml.Name `xml:"itunes:image"`
URL string `xml:"href,attr"`
}
// ITunesDuration denotesthe duration of an episode.
type ITunesDuration time.Duration
func (d ITunesDuration) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
numSeconds := int(time.Duration(d).Seconds())
return e.EncodeElement(struct {
Duration string `xml:",chardata"`
}{
Duration: strconv.Itoa(numSeconds),
}, start)
}