Cleanup
This commit is contained in:
parent
f3c14a4ed6
commit
cfac7b6204
34
arn/Anime.go
34
arn/Anime.go
@ -714,40 +714,6 @@ func (anime *Anime) EpisodeByNumber(number int) *Episode {
|
||||
return nil
|
||||
}
|
||||
|
||||
// RefreshAnimeCharacters ...
|
||||
func (anime *Anime) RefreshAnimeCharacters() (*AnimeCharacters, error) {
|
||||
resp, err := kitsu.GetAnimeCharactersForAnime(anime.GetMapping("kitsu/anime"))
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
animeCharacters := &AnimeCharacters{
|
||||
AnimeID: anime.ID,
|
||||
Items: []*AnimeCharacter{},
|
||||
}
|
||||
|
||||
for _, incl := range resp.Included {
|
||||
if incl.Type != "animeCharacters" {
|
||||
continue
|
||||
}
|
||||
|
||||
role := incl.Attributes["role"].(string)
|
||||
characterID := incl.Relationships.Character.Data.ID
|
||||
|
||||
animeCharacter := &AnimeCharacter{
|
||||
CharacterID: characterID,
|
||||
Role: role,
|
||||
}
|
||||
|
||||
animeCharacters.Items = append(animeCharacters.Items, animeCharacter)
|
||||
}
|
||||
|
||||
animeCharacters.Save()
|
||||
|
||||
return animeCharacters, nil
|
||||
}
|
||||
|
||||
// String implements the default string serialization.
|
||||
func (anime *Anime) String() string {
|
||||
return anime.Title.Canonical
|
||||
|
@ -1,31 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/akyoto/color"
|
||||
"github.com/animenotifier/notify.moe/arn"
|
||||
)
|
||||
|
||||
func main() {
|
||||
color.Yellow("Refreshing anime characters...")
|
||||
|
||||
defer color.Green("Finished.")
|
||||
defer arn.Node.Close()
|
||||
|
||||
rateLimiter := time.NewTicker(500 * time.Millisecond)
|
||||
|
||||
for anime := range arn.StreamAnime() {
|
||||
<-rateLimiter.C
|
||||
|
||||
chars, err := anime.RefreshAnimeCharacters()
|
||||
|
||||
if err != nil {
|
||||
color.Red(err.Error())
|
||||
continue
|
||||
}
|
||||
|
||||
fmt.Printf("%s %s (%d characters)\n", anime.ID, anime.Title.Canonical, len(chars.Items))
|
||||
}
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
# Layout
|
||||
|
||||
This directory contains the main template that is used for all HTML responses.
|
||||
This directory contains the main template that is used for all HTML responses.
|
||||
|
Loading…
Reference in New Issue
Block a user