1
0

Don't show server start date and time on a page.

This commit is contained in:
Alexander Andreev 2023-08-21 18:30:21 +04:00
parent 5c16576fa4
commit 9ac60e9f28
Signed by: Arav
GPG Key ID: D22A817D95815393
3 changed files with 6 additions and 31 deletions

View File

@ -32,14 +32,6 @@ func (h *Handlers) Index(w http.ResponseWriter, r *http.Request) {
status, err := radio.IcecastGetStatus(h.icecastUrl) status, err := radio.IcecastGetStatus(h.icecastUrl)
if err != nil { if err != nil {
log.Println("failed to get Icecast status:", err) log.Println("failed to get Icecast status:", err)
} else {
if tim, err := time.Parse(time.RFC1123Z, status.ServerStartDate); err == nil {
status.ServerStartDate = utils.ToClientTimezone(tim, r).Format(time.RFC1123)
}
if tim, err := time.Parse(FormatISO8601, status.ServerStartISO8601); err == nil {
status.ServerStartISO8601 = utils.ToClientTimezone(tim, r).Format(FormatISO8601)
}
} }
songs, err := radio.IcecastLastSongs(h.icecastPlaylistPath) songs, err := radio.IcecastLastSongs(h.icecastPlaylistPath)
@ -64,14 +56,6 @@ func (h *Handlers) Status(w http.ResponseWriter, r *http.Request) {
return return
} }
if tim, err := time.Parse(time.RFC1123Z, status.ServerStartDate); err == nil {
status.ServerStartDate = utils.ToClientTimezone(tim, r).Format(time.RFC1123)
}
if tim, err := time.Parse(FormatISO8601, status.ServerStartISO8601); err == nil {
status.ServerStartISO8601 = utils.ToClientTimezone(tim, r).Format(FormatISO8601)
}
w.Header().Add("Content-Type", "application/json") w.Header().Add("Content-Type", "application/json")
json.NewEncoder(w).Encode(status) json.NewEncoder(w).Encode(status)
} }

View File

@ -46,11 +46,9 @@ func (is *IcecastStatusDTO) SongName() string {
} }
type IcecastStatus struct { type IcecastStatus struct {
ServerStartISO8601 string `json:"server_start_iso8601"` SongName string `json:"song"`
ServerStartDate string `json:"server_start_date"` ListenerPeak int `json:"listener_peak"`
SongName string `json:"song"` Listeners int `json:"listeners"`
ListenerPeak int `json:"listener_peak"`
Listeners int `json:"listeners"`
} }
type Song struct { type Song struct {
@ -72,11 +70,9 @@ func IcecastGetStatus(icecastURL string) (*IcecastStatus, error) {
} }
return &IcecastStatus{ return &IcecastStatus{
ServerStartISO8601: iceStatDTO.Icestats.ServerStartISO8601, SongName: iceStatDTO.SongName(),
ServerStartDate: iceStatDTO.Icestats.ServerStartDate, ListenerPeak: iceStatDTO.Icestats.Source.ListenerPeak,
SongName: iceStatDTO.SongName(), Listeners: iceStatDTO.Icestats.Source.Listeners,
ListenerPeak: iceStatDTO.Icestats.Source.ListenerPeak,
Listeners: iceStatDTO.Icestats.Source.Listeners,
}, nil }, nil
} }

View File

@ -45,11 +45,6 @@ html(lang='en')
source(src='/live/stream.ogg' type='audio/ogg') source(src='/live/stream.ogg' type='audio/ogg')
| Your browser doesn't support an audio element, it's sad... But you always can take the #[a(href='/playlist') playlist]! | Your browser doesn't support an audio element, it's sad... But you always can take the #[a(href='/playlist') playlist]!
div div
if status.ServerStartDate != ""
p#radio-status On-air since
time(datetime=status.ServerStartISO8601)= status.ServerStartDate
else
p#radio-status Radio is offline.
p Now playing: #[span#radio-song #{status.SongName}] p Now playing: #[span#radio-song #{status.SongName}]
p Current/peak listeners: #[span#radio-listeners #{status.Listeners}] / #[span#radio-listener-peak #{status.ListenerPeak}] p Current/peak listeners: #[span#radio-listeners #{status.Listeners}] / #[span#radio-listener-peak #{status.ListenerPeak}]
p p