Episode extrapolation

This commit is contained in:
Eduard Urbach 2017-07-10 20:35:45 +02:00
parent 8037edcb67
commit 1da3e3f2f8

View File

@ -13,6 +13,7 @@ func main() {
color.Yellow("Refreshing episode information for each anime.") color.Yellow("Refreshing episode information for each anime.")
highPriority := []*arn.Anime{} highPriority := []*arn.Anime{}
mediumPriority := []*arn.Anime{}
lowPriority := []*arn.Anime{} lowPriority := []*arn.Anime{}
for anime := range arn.MustStreamAnime() { for anime := range arn.MustStreamAnime() {
@ -20,9 +21,12 @@ func main() {
continue continue
} }
if anime.Status == "current" || anime.Status == "upcoming" { switch anime.Status {
case "current":
highPriority = append(highPriority, anime) highPriority = append(highPriority, anime)
} else { case "upcoming":
mediumPriority = append(mediumPriority, anime)
default:
lowPriority = append(lowPriority, anime) lowPriority = append(lowPriority, anime)
} }
} }
@ -30,6 +34,9 @@ func main() {
color.Cyan("High priority queue:") color.Cyan("High priority queue:")
refresh(highPriority) refresh(highPriority)
color.Cyan("Medium priority queue:")
refresh(mediumPriority)
color.Cyan("Low priority queue:") color.Cyan("Low priority queue:")
refresh(lowPriority) refresh(lowPriority)
@ -38,7 +45,8 @@ func main() {
func refresh(queue []*arn.Anime) { func refresh(queue []*arn.Anime) {
for _, anime := range queue { for _, anime := range queue {
episodeCount := len(anime.Episodes) episodeCount := len(anime.Episodes().Items)
availableEpisodeCount := anime.Episodes().AvailableCount()
err := anime.RefreshEpisodes() err := anime.RefreshEpisodes()
@ -49,7 +57,7 @@ func refresh(queue []*arn.Anime) {
color.Red(err.Error()) color.Red(err.Error())
} else { } else {
fmt.Println(anime.ID, "|", anime.Title.Canonical, "+"+strconv.Itoa(len(anime.Episodes)-episodeCount)) fmt.Println(anime.ID, "|", anime.Title.Canonical, "|", "+"+strconv.Itoa(len(anime.Episodes().Items)-episodeCount)+" airing", "|", "+"+strconv.Itoa(anime.Episodes().AvailableCount()-availableEpisodeCount)+" available")
} }
} }
} }