Improved episode refresh

This commit is contained in:
Eduard Urbach 2017-09-24 05:01:15 +02:00
parent eb4b4c7b54
commit bd38aca4c0
2 changed files with 13 additions and 3 deletions

View File

@ -2,8 +2,8 @@ package main
import (
"fmt"
"strconv"
"strings"
"time"
"github.com/animenotifier/arn"
"github.com/fatih/color"
@ -50,6 +50,9 @@ func main() {
func refreshQueue(queue []*arn.Anime) {
for _, anime := range queue {
refresh(anime)
// Lower the request interval
time.Sleep(5 * time.Second)
}
}
@ -68,6 +71,11 @@ func refresh(anime *arn.Anime) {
color.Red(err.Error())
} else {
fmt.Println("+"+strconv.Itoa(len(anime.Episodes().Items)-episodeCount)+" airing", "|", "+"+strconv.Itoa(anime.Episodes().AvailableCount()-availableEpisodeCount)+" available")
faint := color.New(color.Faint).SprintFunc()
episodes := anime.Episodes()
fmt.Println(faint(episodes))
fmt.Printf("+%d airing | +%d available (%d total)\n", len(episodes.Items), len(episodes.Items)-episodeCount, episodes.AvailableCount()-availableEpisodeCount)
println()
}
}

View File

@ -20,6 +20,9 @@ func main() {
if sync(anime) {
count++
}
// Lower the request interval
time.Sleep(2 * time.Second)
}
// Log
@ -53,7 +56,6 @@ func sync(anime *arn.Anime) bool {
// Did we get the ID?
if anime.GetMapping("shoboi/anime") != "" {
println(color.GreenString("✔"))
time.Sleep(2 * time.Second)
return true
}