Show viewer counts for streams

This commit is contained in:
Salastil
2025-11-23 00:26:12 -05:00
parent 4cb7bd5945
commit feafdfe4cc
2 changed files with 21 additions and 1 deletions

View File

@@ -79,6 +79,24 @@ const (
viewHelp
)
func formatViewerCount(count int) string {
if count >= 1_000_000 {
value := float64(count) / 1_000_000
formatted := fmt.Sprintf("%.1f", value)
formatted = strings.TrimSuffix(formatted, ".0")
return formatted + "m"
}
if count >= 1000 {
value := float64(count) / 1000
formatted := fmt.Sprintf("%.1f", value)
formatted = strings.TrimSuffix(formatted, ".0")
return formatted + "k"
}
return fmt.Sprintf("%d", count)
}
// ────────────────────────────────
// MODEL
// ────────────────────────────────
@@ -144,7 +162,8 @@ func New(debug bool) Model {
if st.HD {
quality = "HD"
}
return fmt.Sprintf("#%d %s (%s) %s", st.StreamNo, st.Language, quality, st.Source)
viewers := formatViewerCount(st.Viewers)
return fmt.Sprintf("#%d %s (%s) %s — (%s viewers)", st.StreamNo, st.Language, quality, st.Source, viewers)
})
m.status = fmt.Sprintf("Using API %s | Loading sports and matches…", base)

View File

@@ -71,6 +71,7 @@ type Stream struct {
HD bool `json:"hd"`
EmbedURL string `json:"embedUrl"`
Source string `json:"source"`
Viewers int `json:"viewers"`
}
// ────────────────────────────────