Use Kitsu finder

This commit is contained in:
Eduard Urbach 2018-04-04 15:08:18 +02:00
parent a6a71358bf
commit e733dd2bf5
4 changed files with 8 additions and 8 deletions

View File

@ -13,10 +13,10 @@ import (
// NewKitsuAnime ...
func NewKitsuAnime(ctx *aero.Context) string {
user := utils.GetUser(ctx)
allAnime := arn.AllAnime()
finder := arn.NewKitsuFinder()
animes := arn.FilterKitsuAnime(func(anime *kitsu.Anime) bool {
return arn.FindKitsuAnime(anime.ID, allAnime) != nil
return finder.GetAnime(anime.ID) == nil
})
sort.Slice(animes, func(i, j int) bool {

View File

@ -112,7 +112,7 @@ func getMatches(ctx *aero.Context) ([]*arn.KitsuMatch, string) {
// findAllMatches returns all matches for the anime inside an anilist anime list.
func findAllMatches(library chan *kitsu.LibraryEntry) []*arn.KitsuMatch {
allAnime := arn.AllAnime()
finder := arn.NewKitsuFinder()
matches := []*arn.KitsuMatch{}
for item := range library {
@ -123,7 +123,7 @@ func findAllMatches(library chan *kitsu.LibraryEntry) []*arn.KitsuMatch {
matches = append(matches, &arn.KitsuMatch{
KitsuItem: item,
ARNAnime: arn.FindKitsuAnime(item.Anime.ID, allAnime),
ARNAnime: finder.GetAnime(item.Anime.ID),
})
}

View File

@ -13,7 +13,7 @@ func main() {
defer color.Green("Finished.")
defer arn.Node.Close()
allAnime := arn.AllAnime()
finder := arn.NewKitsuFinder()
for mapping := range arn.StreamKitsuMappings() {
if mapping.Relationships.Item.Data.Type != "anime" {
@ -24,7 +24,7 @@ func main() {
continue
}
anime := arn.FindKitsuAnime(mapping.Relationships.Item.Data.ID, allAnime)
anime := finder.GetAnime(mapping.Relationships.Item.Data.ID)
if anime == nil {
continue

View File

@ -16,7 +16,7 @@ func main() {
added := 0
conflicted := 0
allAnime := arn.AllAnime()
finder := arn.NewKitsuFinder()
for mapping := range arn.StreamKitsuMappings() {
if mapping.Relationships.Item.Data.Type != "anime" {
@ -33,7 +33,7 @@ func main() {
externalID = externalID[len("anime/"):]
}
anime := arn.FindKitsuAnime(mapping.Relationships.Item.Data.ID, allAnime)
anime := finder.GetAnime(mapping.Relationships.Item.Data.ID)
if anime == nil {
continue