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{}
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
if anime.Status == "current" || anime.Status == "upcoming" {
|
|
|
|
highPriority = append(highPriority, anime)
|
|
|
|
} else {
|
|
|
|
lowPriority = append(lowPriority, anime)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
color.Cyan("High priority queue:")
|
|
|
|
refresh(highPriority)
|
|
|
|
|
|
|
|
color.Cyan("Low priority queue:")
|
|
|
|
refresh(lowPriority)
|
|
|
|
|
|
|
|
color.Green("Finished.")
|
|
|
|
}
|
|
|
|
|
|
|
|
func refresh(queue []*arn.Anime) {
|
|
|
|
for _, anime := range queue {
|
2017-07-02 12:08:25 +00:00
|
|
|
episodeCount := len(anime.Episodes)
|
|
|
|
|
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 {
|
|
|
|
fmt.Println(anime.ID, "|", anime.Title.Canonical, "+"+strconv.Itoa(len(anime.Episodes)-episodeCount))
|
2017-07-02 12:03:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|