Now Index page will be shown even if Icecast status cannot be retrieved.
This commit is contained in:
parent
630c703c12
commit
3ec15fbd2a
@ -62,16 +62,7 @@ func (h *RadioHandlers) Index(w http.ResponseWriter, r *http.Request) {
|
||||
status, err := radio.IcecastGetStatus(h.conf.Icecast.URL)
|
||||
if err != nil {
|
||||
h.logErr.Println("failed to get Icecast status:", err)
|
||||
status = &radio.IcecastStatus{}
|
||||
return
|
||||
}
|
||||
|
||||
songs, err := radio.IcecastLastPlayedSongs(h.conf.ListLastNSongs,
|
||||
h.conf.Icecast.Playlist)
|
||||
if err != nil {
|
||||
h.logErr.Println("cannot retrieve last songs:", err)
|
||||
}
|
||||
|
||||
} else {
|
||||
if tim, err := time.Parse(time.RFC1123Z, status.ServerStartDate); err == nil {
|
||||
status.ServerStartDate = utils.ToClientTimezone(tim, r).Format(time.RFC1123)
|
||||
}
|
||||
@ -79,14 +70,21 @@ func (h *RadioHandlers) Index(w http.ResponseWriter, r *http.Request) {
|
||||
if tim, err := time.Parse(FormatISO8601, status.ServerStartISO8601); err == nil {
|
||||
status.ServerStartISO8601 = utils.ToClientTimezone(tim, r).Format(FormatISO8601)
|
||||
}
|
||||
}
|
||||
|
||||
songs, err := radio.IcecastLastPlayedSongs(h.conf.ListLastNSongs,
|
||||
h.conf.Icecast.Playlist)
|
||||
if err != nil {
|
||||
h.logErr.Println("cannot retrieve last songs:", err)
|
||||
} else {
|
||||
for i := 0; i < len(songs); i++ {
|
||||
if tim, err := time.Parse(radio.SongTimeFormat, songs[i].Time); err == nil {
|
||||
songs[i].Time = utils.ToClientTimezone(tim, r).Format("15:04")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if err := compiledTemplates["index"].Execute(w, &IndexData{
|
||||
if err := web.Template("index").Execute(w, &IndexData{
|
||||
MainSite: utils.MainSite(r.Host),
|
||||
Status: status,
|
||||
Songs: songs,
|
||||
|
Loading…
Reference in New Issue
Block a user