This repository was archived by the owner on Nov 27, 2021. It is now read-only.
This repository was archived by the owner on Nov 27, 2021. It is now read-only.
Open
Description
Hi I have a problem when loading the channel list:
2021/09/09 11:23:45 main.go:34: Retrieving channels list from Stalker middleware...
panic: runtime error: index out of range [0] with length 0
goroutine 1 [running]:
github.com/erkexzcx/stalkerhek/stalker.(*Portal).RetrieveChannels(0xc0000d82c0)
/home/username/stalkerhek/stalker/channels.go:121 +0x4c5
main.main()
/home/username/stalkerhek/cmd/stalkerhek/main.go:35 +0x15c
I added an extra debug line in loop:
log.Println("parsing channel", v)
2021/09/09 11:23:45 channels.go:113: parsing channel {CHANNELNAME ffmpeg http:///ch/1111/1/ http://logo4tv.com/logos/channel.png 1 []}
So my understanding is that is crashing because the CMDs
struct is empty [] and cannot get v.CMDs[0].ID
is it expecting a different structure for channels list ?
All channels appear like this in my case "cmds": [],
I can see the fields populated on the channel level
"id": "1"
"ch_id": "1111",
So changed
type tmpStruct struct {
Js struct {
Data []struct {
Name string `json:"name"` // Title of channel
Cmd string `json:"cmd"` // Some sort of URL used to request channel real URL
Logo string `json:"logo"` // Link to logo
GenreID string `json:"tv_genre_id"` // Genre ID
ID string `json:"id"` // Used for Proxy service to generate fake response to new URL request
CH_ID string `json:"ch_id"` // Used for Proxy service to generate fake response to new URL request
} `json:"data"`
} `json:"js"`
}
And
// Build channels list and return
channels := make(map[string]*Channel, len(tmp.Js.Data))
for _, v := range tmp.Js.Data {
log.Println("parsing channel", v)
channels[v.Name] = &Channel{
Title: v.Name,
CMD: v.Cmd,
LogoLink: v.Logo,
Portal: p,
GenreID: v.GenreID,
Genres: &genres,
CMD_CH_ID: v.ID,
CMD_ID: v.CH_ID,
}
It seems to be working but I am not sure what the expected structure is.
Metadata
Metadata
Assignees
Labels
No labels