Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save categories while generating epg #359

Merged
merged 1 commit into from
Aug 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading