36 lines
805 B
Go
Raw Normal View History

2018-03-17 03:19:23 +00:00
package editor
import (
"sort"
"github.com/aerogo/aero"
"github.com/animenotifier/kitsu"
2019-06-07 01:03:16 +00:00
"github.com/animenotifier/notify.moe/arn"
2018-03-17 03:19:23 +00:00
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
// NewKitsuAnime ...
2019-06-01 04:55:49 +00:00
func NewKitsuAnime(ctx aero.Context) error {
2018-03-17 03:19:23 +00:00
user := utils.GetUser(ctx)
2018-04-04 13:21:52 +00:00
finder := arn.NewAnimeFinder("kitsu/anime")
2018-04-17 10:27:54 +00:00
deletedIDs, err := arn.GetIDList("deleted kitsu anime")
if err != nil {
deletedIDs = arn.IDList{}
}
2018-03-17 03:19:23 +00:00
animes := arn.FilterKitsuAnime(func(anime *kitsu.Anime) bool {
2018-04-17 10:27:54 +00:00
return finder.GetAnime(anime.ID) == nil && !arn.Contains(deletedIDs, anime.ID)
2018-03-17 03:19:23 +00:00
})
sort.Slice(animes, func(i, j int) bool {
a := animes[i]
b := animes[j]
return a.ID > b.ID
})
2019-06-01 04:55:49 +00:00
return ctx.HTML(components.NewKitsuAnime(animes, ctx.Path(), user))
2018-03-17 03:19:23 +00:00
}