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)
|
log.Println("failed to get Icecast status:", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
songs, err := radio.IcecastLastSongs(h.icecastPlaylistPath)
|
songs := radio.IcecastLastSongs(h.icecastPlaylistPath)
|
||||||
if err != nil {
|
if songs != nil {
|
||||||
log.Println("cannot retrieve last songs:", err)
|
|
||||||
} else {
|
|
||||||
for i := 0; i < len(songs); i++ {
|
for i := 0; i < len(songs); i++ {
|
||||||
if tim, err := time.Parse(radio.SongTimeFormat, songs[i].Time); err == nil {
|
if tim, err := time.Parse(radio.SongTimeFormat, songs[i].Time); err == nil {
|
||||||
songs[i].Time = utils.ToClientTimezone(tim, r).Format("15:04")
|
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) {
|
func (h *Handlers) LastSong(w http.ResponseWriter, r *http.Request) {
|
||||||
song, err := radio.IcecastLastSong(h.icecastPlaylistPath)
|
song := radio.IcecastLastSong(h.icecastPlaylistPath)
|
||||||
if err != nil {
|
|
||||||
log.Println("cannot retrieve last songs:", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if song == nil {
|
if song == nil {
|
||||||
w.WriteHeader(http.StatusNotFound)
|
w.WriteHeader(http.StatusNotFound)
|
||||||
return
|
return
|
||||||
|
@ -76,25 +76,25 @@ func IcecastGetStatus(icecastURL string) (*IcecastStatus, error) {
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func IcecastLastSongs(playlistPath string) ([]Song, error) {
|
func IcecastLastSongs(playlistPath string) []Song {
|
||||||
lastPlayedCacheMutex.Lock()
|
lastPlayedCacheMutex.Lock()
|
||||||
defer lastPlayedCacheMutex.Unlock()
|
defer lastPlayedCacheMutex.Unlock()
|
||||||
if lpcLen := len(lastPlayedCache); lpcLen > 0 {
|
if lpcLen := len(lastPlayedCache); lpcLen > 0 {
|
||||||
ret := make([]Song, 0, lpcLen)
|
ret := make([]Song, 0, lpcLen)
|
||||||
ret = append(ret, lastPlayedCache...)
|
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()
|
lastPlayedCacheMutex.Lock()
|
||||||
defer lastPlayedCacheMutex.Unlock()
|
defer lastPlayedCacheMutex.Unlock()
|
||||||
if lpcLen := len(lastPlayedCache); lpcLen > 0 {
|
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) {
|
func icecastLastPlayedSongs(playlistPath string, n int) ([]Song, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user