-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathxmltv.go
49 lines (40 loc) · 1013 Bytes
/
xmltv.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
// Package xmltv provides structures for parsing XMLTV data.
package xmltv
import (
"encoding/xml"
"time"
)
type Time struct {
time.Time
}
func (t *Time) UnmarshalXMLAttr(attr xml.Attr) error {
t1, err := time.Parse("20060102150405 -0700", attr.Value)
if err != nil {
return err
}
*t = Time{t1}
return nil
}
// check interface
var _ xml.UnmarshalerAttr = &Time{}
type Tv struct {
Channels []Channel `xml:"channel"`
Programmes []Programme `xml:"programme"`
}
type Channel struct {
Id string `xml:"id,attr"`
DisplayNames []string `xml:"display-name"`
Icon Icon `xml:"icon"`
}
type Icon struct {
Src string `xml:"src,attr"`
}
type Programme struct {
Id string `xml:"id,attr"` // not defined by standard, but often present
ChannelId string `xml:"channel,attr"`
Start Time `xml:"start,attr"`
Stop Time `xml:"stop,attr"`
Title string `xml:"title"`
Desc string `xml:"desc"`
Categories []string `xml:"category"`
}