diff options
| author | Thibaut Horel <thibaut.horel@gmail.com> | 2017-06-14 00:45:42 -0400 |
|---|---|---|
| committer | Thibaut Horel <thibaut.horel@gmail.com> | 2017-06-14 00:57:04 -0400 |
| commit | 060b315f74f437fe36175c4ddb52379d29808d64 (patch) | |
| tree | f3e0bd83433f3d918927771e60a9369fbcc320a2 /web.go | |
| parent | 2e190b1af96b0836684339bfb4353a17cf28f0b9 (diff) | |
| download | lastfm-api-060b315f74f437fe36175c4ddb52379d29808d64.tar.gz | |
Now Playing feature
Diffstat (limited to 'web.go')
| -rw-r--r-- | web.go | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -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) { |
