Fixed twist updater

This commit is contained in:
Eduard Urbach 2018-04-04 21:05:07 +02:00
parent 9d33cedec2
commit 383a1545e2

View File

@ -21,16 +21,19 @@ func main() {
arn.PanicOnError(err) arn.PanicOnError(err)
idList := arn.IDList(twistAnime.KitsuIDs()) idList := arn.IDList(twistAnime.KitsuIDs())
// Kitsu finder
finder := arn.NewAnimeFinder("kitsu/anime")
// Save index in cache // Save index in cache
arn.DB.Set("IDList", "animetwist index", &idList) arn.DB.Set("IDList", "animetwist index", &idList)
color.Yellow("Refreshing twist.moe links for %d anime", len(idList)) color.Yellow("Refreshing twist.moe links for %d anime", len(idList))
for count, animeID := range idList { for count, kitsuID := range idList {
anime, animeErr := arn.GetAnime(animeID) anime := finder.GetAnime(kitsuID)
if animeErr != nil { if anime == nil {
color.Red("Error fetching anime from the database with ID %s: %v", animeID, animeErr) color.Red("Error fetching anime from the database with Kitsu ID %s", kitsuID)
continue continue
} }
@ -46,7 +49,7 @@ func main() {
anime.RefreshEpisodes() anime.RefreshEpisodes()
// Ok // Ok
color.Green("Found %d episodes for anime %s", len(anime.Episodes().Items), animeID) color.Green("Found %d episodes for anime %s (Kitsu: %s)", len(anime.Episodes().Items), anime.ID, kitsuID)
// Wait for rate limiter // Wait for rate limiter
<-rateLimiter.C <-rateLimiter.C