2017-06-27 10:39:41 +00:00
|
|
|
package music
|
|
|
|
|
2017-06-27 12:01:32 +00:00
|
|
|
import (
|
|
|
|
"sort"
|
|
|
|
|
|
|
|
"github.com/aerogo/aero"
|
|
|
|
"github.com/animenotifier/arn"
|
|
|
|
"github.com/animenotifier/notify.moe/components"
|
|
|
|
)
|
2017-06-27 10:39:41 +00:00
|
|
|
|
2017-06-27 12:04:25 +00:00
|
|
|
const maxTracks = 10
|
|
|
|
|
2017-06-27 10:39:41 +00:00
|
|
|
// Get renders the music page.
|
|
|
|
func Get(ctx *aero.Context) string {
|
2017-06-27 11:46:29 +00:00
|
|
|
tracks := []*arn.SoundTrack{}
|
|
|
|
|
2017-06-27 12:38:36 +00:00
|
|
|
tracks = append(tracks, &arn.SoundTrack{
|
2017-06-27 12:56:22 +00:00
|
|
|
ID: arn.GenerateID("SoundTrack"),
|
2017-06-27 12:38:36 +00:00
|
|
|
Media: []arn.ExternalMedia{
|
|
|
|
arn.ExternalMedia{
|
|
|
|
Service: "Soundcloud",
|
|
|
|
ServiceID: "145918628",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Tags: []string{
|
|
|
|
"anime:2357",
|
|
|
|
},
|
|
|
|
Created: arn.DateTimeUTC(),
|
|
|
|
CreatedBy: "4J6qpK1ve",
|
|
|
|
})
|
|
|
|
|
2017-06-27 11:46:29 +00:00
|
|
|
tracks = append(tracks, &arn.SoundTrack{
|
2017-06-27 12:56:22 +00:00
|
|
|
ID: arn.GenerateID("SoundTrack"),
|
2017-06-27 11:46:29 +00:00
|
|
|
Media: []arn.ExternalMedia{
|
|
|
|
arn.ExternalMedia{
|
|
|
|
Service: "Soundcloud",
|
|
|
|
ServiceID: "127672476",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Tags: []string{
|
|
|
|
"anime:7622",
|
|
|
|
},
|
2017-06-27 12:01:32 +00:00
|
|
|
Created: arn.DateTimeUTC(),
|
|
|
|
CreatedBy: "4J6qpK1ve",
|
2017-06-27 11:46:29 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
tracks = append(tracks, &arn.SoundTrack{
|
2017-06-27 12:56:22 +00:00
|
|
|
ID: arn.GenerateID("SoundTrack"),
|
2017-06-27 11:46:29 +00:00
|
|
|
Media: []arn.ExternalMedia{
|
|
|
|
arn.ExternalMedia{
|
|
|
|
Service: "Soundcloud",
|
|
|
|
ServiceID: "270777538",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Tags: []string{
|
|
|
|
"anime:11469",
|
|
|
|
},
|
2017-06-27 12:01:32 +00:00
|
|
|
Created: arn.DateTimeUTC(),
|
|
|
|
CreatedBy: "4J6qpK1ve",
|
|
|
|
})
|
|
|
|
|
2017-06-27 12:38:36 +00:00
|
|
|
tracks = append(tracks, &arn.SoundTrack{
|
2017-06-27 12:56:22 +00:00
|
|
|
ID: arn.GenerateID("SoundTrack"),
|
2017-06-27 12:38:36 +00:00
|
|
|
Media: []arn.ExternalMedia{
|
|
|
|
arn.ExternalMedia{
|
|
|
|
Service: "Soundcloud",
|
|
|
|
ServiceID: "243839100",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Tags: []string{
|
|
|
|
"anime:9962",
|
|
|
|
},
|
|
|
|
Created: arn.DateTimeUTC(),
|
|
|
|
CreatedBy: "4J6qpK1ve",
|
|
|
|
})
|
|
|
|
|
|
|
|
tracks = append(tracks, &arn.SoundTrack{
|
2017-06-27 12:56:22 +00:00
|
|
|
ID: arn.GenerateID("SoundTrack"),
|
2017-06-27 12:38:36 +00:00
|
|
|
Media: []arn.ExternalMedia{
|
|
|
|
arn.ExternalMedia{
|
|
|
|
Service: "Soundcloud",
|
|
|
|
ServiceID: "207355237",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Tags: []string{
|
|
|
|
"anime:6589",
|
|
|
|
},
|
|
|
|
Created: arn.DateTimeUTC(),
|
|
|
|
CreatedBy: "4J6qpK1ve",
|
|
|
|
})
|
|
|
|
|
|
|
|
tracks = append(tracks, &arn.SoundTrack{
|
2017-06-27 12:56:22 +00:00
|
|
|
ID: arn.GenerateID("SoundTrack"),
|
2017-06-27 12:38:36 +00:00
|
|
|
Media: []arn.ExternalMedia{
|
|
|
|
arn.ExternalMedia{
|
|
|
|
Service: "Soundcloud",
|
|
|
|
ServiceID: "242172944",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Tags: []string{
|
|
|
|
"anime:10740",
|
|
|
|
},
|
|
|
|
Created: arn.DateTimeUTC(),
|
|
|
|
CreatedBy: "4J6qpK1ve",
|
|
|
|
})
|
|
|
|
|
2017-06-27 12:04:25 +00:00
|
|
|
if len(tracks) > maxTracks {
|
|
|
|
tracks = tracks[:maxTracks]
|
|
|
|
}
|
|
|
|
|
2017-06-27 12:01:32 +00:00
|
|
|
sort.Slice(tracks, func(i, j int) bool {
|
|
|
|
return tracks[i].Created > tracks[j].Created
|
2017-06-27 11:46:29 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
return ctx.HTML(components.Music(tracks))
|
2017-06-27 10:39:41 +00:00
|
|
|
}
|