Skip to content

Commit

Permalink
add lang support
Browse files Browse the repository at this point in the history
  • Loading branch information
sjurtf committed Mar 15, 2021
1 parent dd4a7a2 commit 8505a11
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 29 deletions.
41 changes: 20 additions & 21 deletions xmltv/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,31 @@ type Channel struct {
}

type Programme struct {
XMLName xml.Name `xml:"programme"`
Channel string `xml:"channel,attr"`
Start string `xml:"start,attr"`
Stop string `xml:"stop,attr"`
Title string `xml:"title"`
SubTitle string `xml:"sub-title,omitempty"`
Description string `xml:"desc,omitempty"`
EpisodeNum EpisodeNum `xml:"episode-num,omitempty"`
Credits string `xml:"credits,omitempty"`
Date string `xml:"date,omitempty"`
Categories []Category `xml:"category,omitempty"`
Rating []Rating `xml:"rating,omitempty"`
XMLName xml.Name `xml:"programme"`
Channel string `xml:"channel,attr"`
Start string `xml:"start,attr"`
Stop string `xml:"stop,attr"`
Titles []CommonElement `xml:"title"`
SubTitles []CommonElement `xml:"sub-title,omitempty"`
Descriptions []CommonElement `xml:"desc,omitempty"`
Categories []CommonElement `xml:"category,omitempty"`
EpisodeNums []EpisodeNum `xml:"episode-num,omitempty"`
Credits string `xml:"credits,omitempty"`
Date string `xml:"date,omitempty"`
Ratings []Rating `xml:"rating,omitempty"`
}

type CommonElement struct {
Lang string `xml:"lang,attr,omitempty"`
Value string `xml:",chardata"`
}

type EpisodeNum struct {
XMLName xml.Name `xml:"episode-num"`
System string `xml:"system,attr"`
EpisodeNum string `xml:",chardata"`
System string `xml:"system,attr"`
EpisodeNum string `xml:",chardata"`
}

type Rating struct {
System string `xml:"system,attr"`
Value string `xml:"value"`
}

type Category struct {
Value string `xml:",chardata"`
Lang string `xml:"lang,attr"`
System string `xml:"system,attr,omitempty"`
}
31 changes: 23 additions & 8 deletions xmltv/xmltv.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,17 @@ func getProgramsForChannel(channelId string, date time.Time) []Programme {
var programs []Programme
for _, p := range guide {

ep := EpisodeNum{
titles := CommonElement{
Lang: "nb",
Value: p.Title,
}

subtitle := CommonElement{
Lang: "nb",
Value: p.Title,
}

episode := EpisodeNum{
System: XmltvEpisodeStd,
EpisodeNum: formatEpisode(p.Season, p.Episode, p.EpisodeTotal),
}
Expand All @@ -89,14 +99,19 @@ func getProgramsForChannel(channelId string, date time.Time) []Programme {
desc = p.SeriesSynopsis
}

description := CommonElement{
Lang: "nb",
Value: desc,
}

programme := Programme{
Channel: channelId,
Start: formatTime(p.Start),
Stop: formatTime(p.Stop),
Title: p.Title,
SubTitle: p.Title,
Description: desc,
EpisodeNum: ep,
Channel: channelId,
Start: formatTime(p.Start),
Stop: formatTime(p.Stop),
Titles: []CommonElement{titles},
SubTitles: []CommonElement{subtitle},
Descriptions: []CommonElement{description},
EpisodeNums: []EpisodeNum{episode},
}
programs = append(programs, programme)
}
Expand Down

0 comments on commit 8505a11

Please sign in to comment.