2017-10-02 04:29:58 +00:00
|
|
|
package soundtrack
|
2017-06-27 22:16:45 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/aerogo/aero"
|
|
|
|
"github.com/animenotifier/arn"
|
|
|
|
"github.com/animenotifier/notify.moe/components"
|
|
|
|
)
|
|
|
|
|
2017-07-13 06:23:20 +00:00
|
|
|
// Get track.
|
2017-06-27 22:16:45 +00:00
|
|
|
func Get(ctx *aero.Context) string {
|
|
|
|
id := ctx.Get("id")
|
|
|
|
track, err := arn.GetSoundTrack(id)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return ctx.Error(http.StatusNotFound, "Track not found", err)
|
|
|
|
}
|
|
|
|
|
2017-07-21 14:33:29 +00:00
|
|
|
ctx.Data = &arn.OpenGraph{
|
|
|
|
Tags: map[string]string{
|
|
|
|
"og:title": track.Media[0].Title,
|
|
|
|
"og:image": track.Anime()[0].Image.Large,
|
|
|
|
"og:url": "https://" + ctx.App.Config.Domain + track.Link(),
|
|
|
|
"og:site_name": "notify.moe",
|
|
|
|
"og:type": "music.song",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2017-06-27 22:16:45 +00:00
|
|
|
return ctx.HTML(components.Track(track))
|
|
|
|
}
|