From c02442ebcdcaafb0f61f74c9ba9adf4b7b805d21 Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Mon, 13 Mar 2023 05:10:17 +0400 Subject: [PATCH] Okay, there is actually a new line at the end of file. Let's skip that. --- internal/radio/icecast.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/radio/icecast.go b/internal/radio/icecast.go index 9e9a07f..c908759 100644 --- a/internal/radio/icecast.go +++ b/internal/radio/icecast.go @@ -130,10 +130,12 @@ func icecastLastPlayedSongs(playlistPath string, n int) ([]Song, error) { lines := bytes.Split(buf, []byte("\n")) - if len(lines) < 1 { + if len(lines) < 2 { return nil, nil } + lines = lines[:len(lines)-1] + if len(lines) > n { lines = lines[len(lines)-n:] }