aboutsummaryrefslogtreecommitdiffstats
path: root/web.go
diff options
context:
space:
mode:
authorThibaut Horel <thibaut.horel@gmail.com>2017-06-14 00:45:42 -0400
committerThibaut Horel <thibaut.horel@gmail.com>2017-06-14 00:57:04 -0400
commit060b315f74f437fe36175c4ddb52379d29808d64 (patch)
treef3e0bd83433f3d918927771e60a9369fbcc320a2 /web.go
parent2e190b1af96b0836684339bfb4353a17cf28f0b9 (diff)
downloadlastfm-api-060b315f74f437fe36175c4ddb52379d29808d64.tar.gz
Now Playing feature
Diffstat (limited to 'web.go')
-rw-r--r--web.go13
1 files changed, 10 insertions, 3 deletions
diff --git a/web.go b/web.go
index 31a8317..371ae9f 100644
--- a/web.go
+++ b/web.go
@@ -7,6 +7,7 @@ import (
"io/ioutil"
"log"
"net/http"
+ "time"
_ "github.com/lib/pq"
)
@@ -49,11 +50,17 @@ func (app *App) root(w http.ResponseWriter, r *http.Request) {
}
scrobbles := app.RecentScrobbles(se.UserId)
+ np := app.NowPlaying(se.UserId)
+ np.Image = "static/np2.gif"
+ if time.Since(np.Time) > time.Duration(np.Duration)*time.Second {
+ np = nil
+ }
app.Template.ExecuteTemplate(w, "index.tmpl", struct {
- Session *UserSession
- Scrobbles []*Scrobble
- }{se, scrobbles})
+ Session *UserSession
+ Scrobbles []*Scrobble
+ NowPlaying *Scrobble
+ }{se, scrobbles, np})
}
func (app *App) callback(w http.ResponseWriter, r *http.Request) {