Skip to content

Commit

Permalink
Save categories while generating epg (#359)
Browse files Browse the repository at this point in the history
  • Loading branch information
sainak authored Aug 4, 2024
1 parent 59cded4 commit a521dac
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
8 changes: 6 additions & 2 deletions pkg/epg/epg.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func Init() {
}

// NewProgramme creates a new Programme with the given parameters.
func NewProgramme(channelID int, start, stop, title, desc, iconSrc string) Programme {
func NewProgramme(channelID int, start, stop, title, desc, category, iconSrc string) Programme {
iconURL := fmt.Sprintf("/jtvposter/%s", iconSrc)
return Programme{
Channel: fmt.Sprint(channelID),
Expand All @@ -94,6 +94,10 @@ func NewProgramme(channelID int, start, stop, title, desc, iconSrc string) Progr
Value: desc,
Lang: "en",
},
Category: Category{
Value: category,
Lang: "en",
},
Icon: Icon{
Src: iconURL,
},
Expand Down Expand Up @@ -139,7 +143,7 @@ func genXML() ([]byte, error) {
for _, programme := range epgResponse.EPG {
startTime := formatTime(time.UnixMilli(programme.StartEpoch))
endTime := formatTime(time.UnixMilli(programme.EndEpoch))
programmes = append(programmes, NewProgramme(channel.ID, startTime, endTime, programme.Title, programme.Description, programme.Poster))
programmes = append(programmes, NewProgramme(channel.ID, startTime, endTime, programme.Title, programme.Description, programme.ShowCategory, programme.Poster))
}
}
bar.Add(1)
Expand Down
23 changes: 16 additions & 7 deletions pkg/epg/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ type Title struct {
Lang string `xml:"lang,attr"` // Language of the title
}

// Category XML tag for Programme XML tag in EPG
// Category is the type of the programme or show being aired on the channel
type Category struct {
XMLName xml.Name `xml:"category"`
Value string `xml:",chardata"` // Category of the programme
Lang string `xml:"lang,attr"` // Language of the category
}

// Desc represents Description XML tag for Programme XML tag in EPG
type Desc struct {
XMLName xml.Name `xml:"desc"`
Expand All @@ -37,13 +45,14 @@ type Desc struct {
// Programme XML tag structure for EPG
// Each programme tag represents a show being aired on a channel
type Programme struct {
XMLName xml.Name `xml:"programme"` // XML tag name
Channel string `xml:"channel,attr"` // Channel is attribute of programme tag
Start string `xml:"start,attr"` // Start time of the programme
Stop string `xml:"stop,attr"` // Stop time of the programme
Title Title `xml:"title"` // Title of the programme
Desc Desc `xml:"desc"` // Description of the programme
Icon Icon `xml:"icon"` // Icon of the programme
XMLName xml.Name `xml:"programme"` // XML tag name
Channel string `xml:"channel,attr"` // Channel is attribute of programme tag
Start string `xml:"start,attr"` // Start time of the programme
Stop string `xml:"stop,attr"` // Stop time of the programme
Title Title `xml:"title"` // Title of the programme
Desc Desc `xml:"desc"` // Description of the programme
Category Category `xml:"category"` // Category of the programme
Icon Icon `xml:"icon"` // Icon of the programme
}

// EPG XML tag structure
Expand Down

0 comments on commit a521dac

Please sign in to comment.