Removed unused error returning (error is always nil).
This commit is contained in:
parent
a6f92b56da
commit
978b4c6454
@ -32,10 +32,8 @@ func (h *Handlers) Index(w http.ResponseWriter, r *http.Request) {
|
||||
log.Println("failed to get Icecast status:", err)
|
||||
}
|
||||
|
||||
songs, err := radio.IcecastLastSongs(h.icecastPlaylistPath)
|
||||
if err != nil {
|
||||
log.Println("cannot retrieve last songs:", err)
|
||||
} else {
|
||||
songs := radio.IcecastLastSongs(h.icecastPlaylistPath)
|
||||
if songs != nil {
|
||||
for i := 0; i < len(songs); i++ {
|
||||
if tim, err := time.Parse(radio.SongTimeFormat, songs[i].Time); err == nil {
|
||||
songs[i].Time = utils.ToClientTimezone(tim, r).Format("15:04")
|
||||
@ -59,11 +57,7 @@ func (h *Handlers) Status(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func (h *Handlers) LastSong(w http.ResponseWriter, r *http.Request) {
|
||||
song, err := radio.IcecastLastSong(h.icecastPlaylistPath)
|
||||
if err != nil {
|
||||
log.Println("cannot retrieve last songs:", err)
|
||||
}
|
||||
|
||||
song := radio.IcecastLastSong(h.icecastPlaylistPath)
|
||||
if song == nil {
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
return
|
||||
|
@ -76,25 +76,25 @@ func IcecastGetStatus(icecastURL string) (*IcecastStatus, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func IcecastLastSongs(playlistPath string) ([]Song, error) {
|
||||
func IcecastLastSongs(playlistPath string) []Song {
|
||||
lastPlayedCacheMutex.Lock()
|
||||
defer lastPlayedCacheMutex.Unlock()
|
||||
if lpcLen := len(lastPlayedCache); lpcLen > 0 {
|
||||
ret := make([]Song, 0, lpcLen)
|
||||
ret = append(ret, lastPlayedCache...)
|
||||
return ret, nil
|
||||
return ret
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
return nil
|
||||
}
|
||||
|
||||
func IcecastLastSong(playlistPath string) (*Song, error) {
|
||||
func IcecastLastSong(playlistPath string) *Song {
|
||||
lastPlayedCacheMutex.Lock()
|
||||
defer lastPlayedCacheMutex.Unlock()
|
||||
if lpcLen := len(lastPlayedCache); lpcLen > 0 {
|
||||
return &lastPlayedCache[lpcLen-1], nil
|
||||
return &lastPlayedCache[lpcLen-1]
|
||||
}
|
||||
return nil, nil
|
||||
return nil
|
||||
}
|
||||
|
||||
func icecastLastPlayedSongs(playlistPath string, n int) ([]Song, error) {
|
||||
|
Loading…
Reference in New Issue
Block a user