This commit is contained in:
Eduard Urbach 2019-11-18 18:58:30 +09:00
parent f3c14a4ed6
commit cfac7b6204
Signed by: akyoto
GPG Key ID: C874F672B1AF20C0
5 changed files with 1 additions and 66 deletions

View File

@ -714,40 +714,6 @@ func (anime *Anime) EpisodeByNumber(number int) *Episode {
return nil 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. // String implements the default string serialization.
func (anime *Anime) String() string { func (anime *Anime) String() string {
return anime.Title.Canonical return anime.Title.Canonical

View File

@ -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))
}
}