61 lines
1.1 KiB
Go
Raw Normal View History

2017-06-30 23:16:25 +00:00
package explore
2017-06-20 20:54:45 +00:00
import (
"github.com/aerogo/aero"
2017-10-28 01:53:12 +00:00
"github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components"
2017-11-12 10:18:16 +00:00
"github.com/animenotifier/notify.moe/utils"
"time"
"strconv"
2017-10-28 01:53:12 +00:00
)
2017-07-01 00:14:14 +00:00
// Get ...
2017-06-20 20:54:45 +00:00
func Get(ctx *aero.Context) string {
year := strconv.Itoa(time.Now().Year())
2017-11-07 16:46:39 +00:00
status := "current"
typ := "tv"
results := filterAnime(year, status, typ)
2017-11-12 10:18:16 +00:00
user := utils.GetUser(ctx)
2017-10-28 01:53:12 +00:00
2017-11-12 10:18:16 +00:00
return ctx.HTML(components.ExploreAnime(results, year, status, typ, user))
2017-11-07 16:46:39 +00:00
}
// Filter ...
func Filter(ctx *aero.Context) string {
year := ctx.Get("year")
status := ctx.Get("status")
typ := ctx.Get("type")
2017-11-12 10:18:16 +00:00
user := utils.GetUser(ctx)
2017-11-07 16:46:39 +00:00
results := filterAnime(year, status, typ)
2017-11-12 10:18:16 +00:00
return ctx.HTML(components.ExploreAnime(results, year, status, typ, user))
2017-11-07 16:46:39 +00:00
}
func filterAnime(year, status, typ string) []*arn.Anime {
var results []*arn.Anime
for anime := range arn.StreamAnime() {
if len(anime.StartDate) < 4 {
continue
}
if anime.StartDate[:4] != year {
continue
}
if anime.Status != status {
continue
}
if anime.Type != typ {
continue
}
results = append(results, anime)
}
arn.SortAnimeByQuality(results, status)
2017-11-07 16:46:39 +00:00
return results
}