From e733dd2bf58601a4c26ce49ac8ffd86f6a72f14c Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Wed, 4 Apr 2018 15:08:18 +0200 Subject: [PATCH] Use Kitsu finder --- pages/editor/kitsu.go | 4 ++-- pages/listimport/listimportkitsu/kitsu.go | 4 ++-- patches/import-kitsu-mappings/import-kitsu-mappings.go | 4 ++-- patches/kitsu-anilist/kitsu-anilist.go | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pages/editor/kitsu.go b/pages/editor/kitsu.go index c8b83f84..960cc0d2 100644 --- a/pages/editor/kitsu.go +++ b/pages/editor/kitsu.go @@ -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 { diff --git a/pages/listimport/listimportkitsu/kitsu.go b/pages/listimport/listimportkitsu/kitsu.go index 89723645..213b26fb 100644 --- a/pages/listimport/listimportkitsu/kitsu.go +++ b/pages/listimport/listimportkitsu/kitsu.go @@ -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), }) } diff --git a/patches/import-kitsu-mappings/import-kitsu-mappings.go b/patches/import-kitsu-mappings/import-kitsu-mappings.go index 0be56971..726d5198 100644 --- a/patches/import-kitsu-mappings/import-kitsu-mappings.go +++ b/patches/import-kitsu-mappings/import-kitsu-mappings.go @@ -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 diff --git a/patches/kitsu-anilist/kitsu-anilist.go b/patches/kitsu-anilist/kitsu-anilist.go index 78a00ab7..a2ad758c 100644 --- a/patches/kitsu-anilist/kitsu-anilist.go +++ b/patches/kitsu-anilist/kitsu-anilist.go @@ -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