-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathepisode.go
53 lines (42 loc) · 1.37 KB
/
episode.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
package tvrage
import (
"encoding/xml"
)
type EpisodeList struct {
XMLName xml.Name `xml:"Show"`
Name string `xml:"name"`
Seasons []Season `xml:"Episodelist>Season"`
//TotalSeasons int `xml:"totalseasons"` // why does this panic?
}
type Season struct {
No int `xml:"no,attr"`
Episodes []Episode `xml:"episode"`
}
type Episode struct {
// This doesn't reset to 1 at the start of each season.
EpNum int `xml:"epnum"`
// This is the episode number for the current season. This one resets to 1 each season.
SeasonNum int `xml:"seasonnum"`
// This isn't a tvrage attribute, but I'm adding it as a convenience. This attribute
// is what I expected the seasonnum to be.
// error: xml: Season>no chain not valid with attr flag2015/05/24 18:58:32 52 <nil>
Season int
// This is the production code. It's poorly named since it can contain non-numbers.
ProdNum string `xml:"prodnum"`
AirDate string `xml:"airdate"`
// This is a link to the tvrage site with info on the episode.
Link string `xml:"link"`
// This is the episode's title.
Title string `xml:"title"`
}
func NewEpisode(season int, epnum int, seasonnum int, prodnum string, airdate string, link string, title string) *Episode {
return &Episode{
Season: season,
EpNum: epnum,
SeasonNum: seasonnum,
ProdNum: prodnum,
AirDate: airdate,
Link: link,
Title: title,
}
}