Commit 828c8956 authored by ale's avatar ale

Fix reading the "quality" parameter in the icecast JSON status

It's a float encoded as a string.
parent e32b64ec
......@@ -9,6 +9,7 @@ import (
"log"
"net/http"
"net/url"
"strconv"
"time"
"git.autistici.org/ale/autoradio"
......@@ -22,20 +23,20 @@ var (
// TODO: deserialize properly the time format used by Icecast.
type icecastMountStatus struct {
Artist string `json:"artist"`
BitRate int32 `json:"audio_bitrate"`
Channels int32 `json:"audio_channels"`
AudioInfo string `json:"audio_info"`
SampleRate int32 `json:"audio_samplerate"`
Genre string `json:"genre"`
Listeners int32 `json:"listeners"`
ListenURL string `json:"listenurl"`
Quality float32 `json:"quality"`
Description string `json:"server_description"`
Name string `json:"server_name"`
Type string `json:"server_type"`
Subtype string `json:"subtype"`
Title string `json:"title"`
Artist string `json:"artist"`
BitRate int32 `json:"audio_bitrate"`
Channels int32 `json:"audio_channels"`
AudioInfo string `json:"audio_info"`
SampleRate int32 `json:"audio_samplerate"`
Genre string `json:"genre"`
Listeners int32 `json:"listeners"`
ListenURL string `json:"listenurl"`
Quality string `json:"quality"`
Description string `json:"server_description"`
Name string `json:"server_name"`
Type string `json:"server_type"`
Subtype string `json:"subtype"`
Title string `json:"title"`
//StreamStart time.Time `json:"stream_start_iso8601"`
}
......@@ -99,13 +100,16 @@ func convertIcecastStatus(status []icecastMountStatus) []*pb.IcecastMount {
Listeners: m.Listeners,
BitRate: m.BitRate,
SampleRate: m.SampleRate,
Quality: m.Quality,
Channels: m.Channels,
Name: m.Name,
Description: m.Description,
Title: m.Title,
Artist: m.Artist,
}
// For whatever reason, quality is a string in Icecast's JSON.
if q, err := strconv.ParseFloat(m.Quality, 32); err == nil {
outm.Quality = float32(q)
}
out = append(out, &outm)
}
return out
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment