1
0

Return error for IcecastLastPlayedSongs.

This commit is contained in:
Alexander Andreev 2022-03-30 20:21:18 +04:00
parent 306ddb2b53
commit c68c99e528
Signed by: Arav
GPG Key ID: 1327FE8A374CC86F

View File

@ -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
}