Added priority queues to episode refresh
This commit is contained in:
parent
5070600964
commit
598b365a33
@ -12,7 +12,32 @@ import (
|
|||||||
func main() {
|
func main() {
|
||||||
color.Yellow("Refreshing episode information for each anime.")
|
color.Yellow("Refreshing episode information for each anime.")
|
||||||
|
|
||||||
|
highPriority := []*arn.Anime{}
|
||||||
|
lowPriority := []*arn.Anime{}
|
||||||
|
|
||||||
for anime := range arn.MustStreamAnime() {
|
for anime := range arn.MustStreamAnime() {
|
||||||
|
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 {
|
||||||
episodeCount := len(anime.Episodes)
|
episodeCount := len(anime.Episodes)
|
||||||
|
|
||||||
err := anime.RefreshEpisodes()
|
err := anime.RefreshEpisodes()
|
||||||
@ -27,6 +52,4 @@ func main() {
|
|||||||
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)-episodeCount))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
color.Green("Finished.")
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user