2017-07-02 12:03:56 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2017-07-02 12:08:25 +00:00
|
|
|
"fmt"
|
|
|
|
"strconv"
|
|
|
|
"strings"
|
|
|
|
|
2017-07-02 12:03:56 +00:00
|
|
|
"github.com/animenotifier/arn"
|
|
|
|
"github.com/fatih/color"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
color.Yellow("Refreshing episode information for each anime.")
|
|
|
|
|
2017-07-06 15:51:44 +00:00
|
|
|
highPriority := []*arn.Anime{}
|
2017-07-10 18:35:45 +00:00
|
|
|
mediumPriority := []*arn.Anime{}
|
2017-07-06 15:51:44 +00:00
|
|
|
lowPriority := []*arn.Anime{}
|
|
|
|
|
2017-07-02 12:03:56 +00:00
|
|
|
for anime := range arn.MustStreamAnime() {
|
2017-07-06 15:51:44 +00:00
|
|
|
if anime.GetMapping("shoboi/anime") == "" {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2017-07-10 18:35:45 +00:00
|
|
|
switch anime.Status {
|
|
|
|
case "current":
|
2017-07-06 15:51:44 +00:00
|
|
|
highPriority = append(highPriority, anime)
|
2017-07-10 18:35:45 +00:00
|
|
|
case "upcoming":
|
|
|
|
mediumPriority = append(mediumPriority, anime)
|
|
|
|
default:
|
2017-07-06 15:51:44 +00:00
|
|
|
lowPriority = append(lowPriority, anime)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
color.Cyan("High priority queue:")
|
|
|
|
refresh(highPriority)
|
|
|
|
|
2017-07-10 18:35:45 +00:00
|
|
|
color.Cyan("Medium priority queue:")
|
|
|
|
refresh(mediumPriority)
|
|
|
|
|
2017-07-06 15:51:44 +00:00
|
|
|
color.Cyan("Low priority queue:")
|
|
|
|
refresh(lowPriority)
|
|
|
|
|
|
|
|
color.Green("Finished.")
|
|
|
|
}
|
|
|
|
|
|
|
|
func refresh(queue []*arn.Anime) {
|
|
|
|
for _, anime := range queue {
|
2017-07-10 18:35:45 +00:00
|
|
|
episodeCount := len(anime.Episodes().Items)
|
|
|
|
availableEpisodeCount := anime.Episodes().AvailableCount()
|
2017-07-02 12:08:25 +00:00
|
|
|
|
2017-07-02 12:03:56 +00:00
|
|
|
err := anime.RefreshEpisodes()
|
|
|
|
|
|
|
|
if err != nil {
|
2017-07-02 12:08:25 +00:00
|
|
|
if strings.Contains(err.Error(), "missing a Shoboi ID") {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2017-07-02 12:03:56 +00:00
|
|
|
color.Red(err.Error())
|
2017-07-02 12:08:25 +00:00
|
|
|
} else {
|
2017-07-10 18:35:45 +00:00
|
|
|
fmt.Println(anime.ID, "|", anime.Title.Canonical, "|", "+"+strconv.Itoa(len(anime.Episodes().Items)-episodeCount)+" airing", "|", "+"+strconv.Itoa(anime.Episodes().AvailableCount()-availableEpisodeCount)+" available")
|
2017-07-02 12:03:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|