diff --git a/internal/radio/icecast.go b/internal/radio/icecast.go index 566d893..c58fa85 100644 --- a/internal/radio/icecast.go +++ b/internal/radio/icecast.go @@ -63,15 +63,17 @@ func IcecastGetStatus(icecastURL string) (*IcecastStatus, error) { return iceStat, nil } -func IcecastLastPlayedSongs(lastNSongs int, playlistPath string) []Song { +func IcecastLastPlayedSongs(lastNSongs int, playlistPath string) ([]Song, error) { songs := make([]Song, 0) - cmd := fmt.Sprintf("tail -n%d %s | head -n-1 | cut -d\"|\" -f1,4", lastNSongs+1, playlistPath) - o := exec.Command("bash", "-c", cmd) - out, _ := o.CombinedOutput() + cmd := fmt.Sprintf("tail -n%d %s | head -n-1 | cut -d'|' -f1,4", lastNSongs+1, playlistPath) + out, err := exec.Command("bash", "-c", cmd).CombinedOutput() + if err != nil { + return songs, err + } if len(out) == 0 { - return songs + return songs, nil } songs_ := strings.Split(string(out), "\n") @@ -89,5 +91,5 @@ func IcecastLastPlayedSongs(lastNSongs int, playlistPath string) []Song { Title: at[1]}) } - return songs + return songs, nil }