44 lines
767 B
Go
Raw Normal View History

2017-06-06 22:08:43 +02:00
package main
import (
2017-06-07 21:12:59 +02:00
"sort"
2017-06-06 22:08:43 +02:00
"github.com/animenotifier/arn"
"github.com/fatih/color"
)
func main() {
color.Yellow("Caching airing anime")
animeList, err := arn.GetAiringAnime()
if err != nil {
color.Red("Failed fetching airing anime")
color.Red(err.Error())
return
}
2017-06-07 21:12:59 +02:00
sort.Slice(animeList, func(i, j int) bool {
2017-06-08 11:51:34 +02:00
return animeList[i].Rating.Overall > animeList[j].Rating.Overall
2017-06-07 21:12:59 +02:00
})
2017-06-06 22:08:43 +02:00
// Convert to small anime list
cache := &arn.ListOfIDs{}
for _, anime := range animeList {
cache.IDList = append(cache.IDList, anime.ID)
}
println(len(cache.IDList))
2017-06-14 17:16:03 +02:00
saveErr := arn.DB.Set("Cache", "airing anime", cache)
2017-06-06 22:08:43 +02:00
if saveErr != nil {
color.Red("Error saving airing anime")
color.Red(saveErr.Error())
return
}
color.Green("Finished.")
}