From f2a4af9ea886ec977ab23b1a57780be9334803dc Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Sun, 18 Mar 2018 06:02:48 +0100 Subject: [PATCH] Added importer for Kitsu mappings --- .../kitsu-import-mappings.go | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 jobs/kitsu-import-mappings/kitsu-import-mappings.go diff --git a/jobs/kitsu-import-mappings/kitsu-import-mappings.go b/jobs/kitsu-import-mappings/kitsu-import-mappings.go new file mode 100644 index 00000000..373c093d --- /dev/null +++ b/jobs/kitsu-import-mappings/kitsu-import-mappings.go @@ -0,0 +1,31 @@ +package main + +import ( + "fmt" + + "github.com/animenotifier/arn" + "github.com/animenotifier/kitsu" + "github.com/fatih/color" +) + +func main() { + color.Yellow("Importing Kitsu mappings") + + defer arn.Node.Close() + defer color.Green("Finished.") + + // Iterate over all mappings + for mapping := range kitsu.StreamMappings() { + sync(mapping) + } +} + +func sync(mapping *kitsu.Mapping) { + // Skip mappings for anything that's not anime + if mapping.Relationships.Item.Data.Type != "anime" { + return + } + + fmt.Printf("[MappingID: %s] [AnimeID: %s] %s %s\n", mapping.ID, mapping.Relationships.Item.Data.ID, color.YellowString(mapping.Attributes.ExternalSite), mapping.Attributes.ExternalID) + arn.Kitsu.Set("Mapping", mapping.ID, mapping) +}