Use generic AnimeFinder

This commit is contained in:
Eduard Urbach 2018-04-04 15:21:52 +02:00
parent e733dd2bf5
commit 74daef0df7
6 changed files with 12 additions and 10 deletions

View File

@ -33,12 +33,14 @@ func main() {
}, },
Description: kitsuCharacter.Attributes.Description, Description: kitsuCharacter.Attributes.Description,
Attributes: []*arn.CharacterAttribute{}, Attributes: []*arn.CharacterAttribute{},
HasMappings: arn.HasMappings{
Mappings: []*arn.Mapping{ Mappings: []*arn.Mapping{
&arn.Mapping{ &arn.Mapping{
Service: "kitsu/character", Service: "kitsu/character",
ServiceID: kitsuCharacter.ID, ServiceID: kitsuCharacter.ID,
}, },
}, },
},
} }
if kitsuCharacter.Attributes.MalID != 0 { if kitsuCharacter.Attributes.MalID != 0 {

View File

@ -13,7 +13,7 @@ import (
// NewKitsuAnime ... // NewKitsuAnime ...
func NewKitsuAnime(ctx *aero.Context) string { func NewKitsuAnime(ctx *aero.Context) string {
user := utils.GetUser(ctx) user := utils.GetUser(ctx)
finder := arn.NewKitsuFinder() finder := arn.NewAnimeFinder("kitsu/anime")
animes := arn.FilterKitsuAnime(func(anime *kitsu.Anime) bool { animes := arn.FilterKitsuAnime(func(anime *kitsu.Anime) bool {
return finder.GetAnime(anime.ID) == nil return finder.GetAnime(anime.ID) == nil

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. // findAllMatches returns all matches for the anime inside an anilist anime list.
func findAllMatches(library chan *kitsu.LibraryEntry) []*arn.KitsuMatch { func findAllMatches(library chan *kitsu.LibraryEntry) []*arn.KitsuMatch {
finder := arn.NewKitsuFinder() finder := arn.NewAnimeFinder("kitsu/anime")
matches := []*arn.KitsuMatch{} matches := []*arn.KitsuMatch{}
for item := range library { for item := range library {

View File

@ -107,13 +107,13 @@ func getMatches(ctx *aero.Context) ([]*arn.MyAnimeListMatch, string) {
// findAllMatches returns all matches for the anime inside an anilist anime list. // findAllMatches returns all matches for the anime inside an anilist anime list.
func findAllMatches(animeList *mal.AnimeList) []*arn.MyAnimeListMatch { func findAllMatches(animeList *mal.AnimeList) []*arn.MyAnimeListMatch {
allAnime := arn.AllAnime() finder := arn.NewAnimeFinder("myanimelist/anime")
matches := []*arn.MyAnimeListMatch{} matches := []*arn.MyAnimeListMatch{}
for _, item := range animeList.Items { for _, item := range animeList.Items {
matches = append(matches, &arn.MyAnimeListMatch{ matches = append(matches, &arn.MyAnimeListMatch{
MyAnimeListItem: item, MyAnimeListItem: item,
ARNAnime: arn.FindMyAnimeListAnime(item.AnimeID, allAnime), ARNAnime: finder.GetAnime(item.AnimeID),
}) })
} }

View File

@ -13,7 +13,7 @@ func main() {
defer color.Green("Finished.") defer color.Green("Finished.")
defer arn.Node.Close() defer arn.Node.Close()
finder := arn.NewKitsuFinder() finder := arn.NewAnimeFinder("kitsu/anime")
for mapping := range arn.StreamKitsuMappings() { for mapping := range arn.StreamKitsuMappings() {
if mapping.Relationships.Item.Data.Type != "anime" { if mapping.Relationships.Item.Data.Type != "anime" {

View File

@ -16,7 +16,7 @@ func main() {
added := 0 added := 0
conflicted := 0 conflicted := 0
finder := arn.NewKitsuFinder() finder := arn.NewAnimeFinder("kitsu/anime")
for mapping := range arn.StreamKitsuMappings() { for mapping := range arn.StreamKitsuMappings() {
if mapping.Relationships.Item.Data.Type != "anime" { if mapping.Relationships.Item.Data.Type != "anime" {