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() {
|
func main() {
|
||||||
color.Yellow("Refreshing episode information for each anime.")
|
color.Yellow("Refreshing episode information for each anime.")
|
||||||
|
|
||||||
|
if InvokeShellArgs() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
highPriority := []*arn.Anime{}
|
highPriority := []*arn.Anime{}
|
||||||
mediumPriority := []*arn.Anime{}
|
mediumPriority := []*arn.Anime{}
|
||||||
lowPriority := []*arn.Anime{}
|
lowPriority := []*arn.Anime{}
|
||||||
@ -32,34 +36,38 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
color.Cyan("High priority queue (%d):", len(highPriority))
|
color.Cyan("High priority queue (%d):", len(highPriority))
|
||||||
refresh(highPriority)
|
refreshQueue(highPriority)
|
||||||
|
|
||||||
color.Cyan("Medium priority queue (%d):", len(mediumPriority))
|
color.Cyan("Medium priority queue (%d):", len(mediumPriority))
|
||||||
refresh(mediumPriority)
|
refreshQueue(mediumPriority)
|
||||||
|
|
||||||
color.Cyan("Low priority queue (%d):", len(lowPriority))
|
color.Cyan("Low priority queue (%d):", len(lowPriority))
|
||||||
refresh(lowPriority)
|
refreshQueue(lowPriority)
|
||||||
|
|
||||||
color.Green("Finished.")
|
color.Green("Finished.")
|
||||||
}
|
}
|
||||||
|
|
||||||
func refresh(queue []*arn.Anime) {
|
func refreshQueue(queue []*arn.Anime) {
|
||||||
for _, anime := range queue {
|
for _, anime := range queue {
|
||||||
fmt.Println(anime.ID, "|", anime.Title.Canonical, "|", anime.GetMapping("shoboi/anime"))
|
refresh(anime)
|
||||||
|
}
|
||||||
episodeCount := len(anime.Episodes().Items)
|
}
|
||||||
availableEpisodeCount := anime.Episodes().AvailableCount()
|
|
||||||
|
func refresh(anime *arn.Anime) {
|
||||||
err := anime.RefreshEpisodes()
|
fmt.Println(anime.ID, "|", anime.Title.Canonical, "|", anime.GetMapping("shoboi/anime"))
|
||||||
|
|
||||||
if err != nil {
|
episodeCount := len(anime.Episodes().Items)
|
||||||
if strings.Contains(err.Error(), "missing a Shoboi ID") {
|
availableEpisodeCount := anime.Episodes().AvailableCount()
|
||||||
continue
|
|
||||||
}
|
err := anime.RefreshEpisodes()
|
||||||
|
|
||||||
color.Red(err.Error())
|
if err != nil {
|
||||||
} else {
|
if strings.Contains(err.Error(), "missing a Shoboi ID") {
|
||||||
fmt.Println("+"+strconv.Itoa(len(anime.Episodes().Items)-episodeCount)+" airing", "|", "+"+strconv.Itoa(anime.Episodes().AvailableCount()-availableEpisodeCount)+" available")
|
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