Skip to content

Commit f71ce7e

Browse files
committed
fix(yp): send Icecast2-canonical fields (st, listeners, bitrate) so dir.xiph.org displays current song and listener count
dir.xiph.org reads the standard Icecast2 YP keys: `st` for the current stream title (we were sending `title`, which it ignores), `listeners` for the live count (we weren\x27t sending it at all), and `bitrate` for the audio bitrate (we were sending `cps`, a tinyice-specific name). Send all three keys; keep the legacy aliases (`title`, `cps`) so we do not regress YP servers that read those instead. `listeners` comes from the live StreamStats snapshot, so the post-rebuild count (transcoders excluded) is the value advertised.
1 parent 74c03e7 commit f71ce7e

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

server/tasks.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"net"
55
"net/http"
66
"net/url"
7+
"strconv"
78
"strings"
89
"time"
910

@@ -127,18 +128,28 @@ func (s *Server) reportToDirectoryAction(st relay.StreamStats, action, sid strin
127128
}
128129
data.Set("sn", st.Name)
129130
data.Set("genre", normaliseYPGenre(st.Genre))
131+
// Bitrate: send under both `cps` (legacy tinyice) and `bitrate`
132+
// (Icecast2 / dir.xiph.org canonical name) so whichever the YP
133+
// server reads gets a value.
130134
data.Set("cps", st.Bitrate)
135+
if st.Bitrate != "" {
136+
data.Set("bitrate", st.Bitrate)
137+
}
131138
data.Set("url", st.URL)
132139
data.Set("desc", st.Description)
133140
data.Set("listenurl", listenURL)
134141
data.Set("type", mime)
135142
data.Set("stype", "Icecast2")
136-
// Current-song title: lets the public directory show "On Air:" /
137-
// "Now playing:" without the operator having to use the admin
138-
// metadata API. Updated on every touch.
143+
// Current-song title: Icecast2's reference YP client sends `st`,
144+
// so dir.xiph.org reads that key. Send `title` too (legacy tinyice
145+
// + some forks expect it) so we cover both shapes.
139146
if st.CurrentSong != "" {
147+
data.Set("st", st.CurrentSong)
140148
data.Set("title", st.CurrentSong)
141149
}
150+
// Listener count: lets the directory display "X listeners" and
151+
// rank stations. Sent on every touch from the live snapshot.
152+
data.Set("listeners", strconv.Itoa(st.ListenersCount))
142153

143154
resp, err := http.PostForm(s.Config.DirectoryServer, data)
144155
if err != nil {

0 commit comments

Comments
 (0)