Can now refresh a single anime in refresh-episodes
This commit is contained in:
parent
7bce362eeb
commit
eb4b4c7b54
@ -12,6 +12,10 @@ import (
|
||||
func main() {
|
||||
color.Yellow("Refreshing episode information for each anime.")
|
||||
|
||||
if InvokeShellArgs() {
|
||||
return
|
||||
}
|
||||
|
||||
highPriority := []*arn.Anime{}
|
||||
mediumPriority := []*arn.Anime{}
|
||||
lowPriority := []*arn.Anime{}
|
||||
@ -32,34 +36,38 @@ func main() {
|
||||
}
|
||||
|
||||
color.Cyan("High priority queue (%d):", len(highPriority))
|
||||
refresh(highPriority)
|
||||
refreshQueue(highPriority)
|
||||
|
||||
color.Cyan("Medium priority queue (%d):", len(mediumPriority))
|
||||
refresh(mediumPriority)
|
||||
refreshQueue(mediumPriority)
|
||||
|
||||
color.Cyan("Low priority queue (%d):", len(lowPriority))
|
||||
refresh(lowPriority)
|
||||
refreshQueue(lowPriority)
|
||||
|
||||
color.Green("Finished.")
|
||||
}
|
||||
|
||||
func refresh(queue []*arn.Anime) {
|
||||
func refreshQueue(queue []*arn.Anime) {
|
||||
for _, anime := range queue {
|
||||
fmt.Println(anime.ID, "|", anime.Title.Canonical, "|", anime.GetMapping("shoboi/anime"))
|
||||
|
||||
episodeCount := len(anime.Episodes().Items)
|
||||
availableEpisodeCount := anime.Episodes().AvailableCount()
|
||||
|
||||
err := anime.RefreshEpisodes()
|
||||
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "missing a Shoboi ID") {
|
||||
continue
|
||||
}
|
||||
|
||||
color.Red(err.Error())
|
||||
} else {
|
||||
fmt.Println("+"+strconv.Itoa(len(anime.Episodes().Items)-episodeCount)+" airing", "|", "+"+strconv.Itoa(anime.Episodes().AvailableCount()-availableEpisodeCount)+" available")
|
||||
}
|
||||
refresh(anime)
|
||||
}
|
||||
}
|
||||
|
||||
func refresh(anime *arn.Anime) {
|
||||
fmt.Println(anime.ID, "|", anime.Title.Canonical, "|", anime.GetMapping("shoboi/anime"))
|
||||
|
||||
episodeCount := len(anime.Episodes().Items)
|
||||
availableEpisodeCount := anime.Episodes().AvailableCount()
|
||||
|
||||
err := anime.RefreshEpisodes()
|
||||
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "missing a Shoboi ID") {
|
||||
return
|
||||
}
|
||||
|
||||
color.Red(err.Error())
|
||||
} else {
|
||||
fmt.Println("+"+strconv.Itoa(len(anime.Episodes().Items)-episodeCount)+" airing", "|", "+"+strconv.Itoa(anime.Episodes().AvailableCount()-availableEpisodeCount)+" available")
|
||||
}
|
||||
}
|
||||
|
32
jobs/refresh-episodes/shell.go
Normal file
32
jobs/refresh-episodes/shell.go
Normal file
@ -0,0 +1,32 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
|
||||
"github.com/animenotifier/arn"
|
||||
)
|
||||
|
||||
// Shell parameters
|
||||
var animeID string
|
||||
|
||||
// Shell flags
|
||||
func init() {
|
||||
flag.StringVar(&animeID, "id", "", "ID of the anime you want to refresh")
|
||||
flag.Parse()
|
||||
}
|
||||
|
||||
// InvokeShellArgs ...
|
||||
func InvokeShellArgs() bool {
|
||||
if animeID != "" {
|
||||
anime, err := arn.GetAnime(animeID)
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
refresh(anime)
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
Loading…
Reference in New Issue
Block a user