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,19 +36,24 @@ 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 {
|
||||||
|
refresh(anime)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func refresh(anime *arn.Anime) {
|
||||||
fmt.Println(anime.ID, "|", anime.Title.Canonical, "|", anime.GetMapping("shoboi/anime"))
|
fmt.Println(anime.ID, "|", anime.Title.Canonical, "|", anime.GetMapping("shoboi/anime"))
|
||||||
|
|
||||||
episodeCount := len(anime.Episodes().Items)
|
episodeCount := len(anime.Episodes().Items)
|
||||||
@ -54,7 +63,7 @@ func refresh(queue []*arn.Anime) {
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if strings.Contains(err.Error(), "missing a Shoboi ID") {
|
if strings.Contains(err.Error(), "missing a Shoboi ID") {
|
||||||
continue
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
color.Red(err.Error())
|
color.Red(err.Error())
|
||||||
@ -62,4 +71,3 @@ func refresh(queue []*arn.Anime) {
|
|||||||
fmt.Println("+"+strconv.Itoa(len(anime.Episodes().Items)-episodeCount)+" airing", "|", "+"+strconv.Itoa(anime.Episodes().AvailableCount()-availableEpisodeCount)+" available")
|
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