Return error for IcecastLastPlayedSongs.
This commit is contained in:
parent
306ddb2b53
commit
c68c99e528
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user