From 2edfd91338e9abc8cbd0b3289877edf6b72db8e1 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Sat, 8 Jul 2017 01:50:15 +0200 Subject: [PATCH] Add MAL connections --- .../add-mal-connections.go | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 patches/add-mal-connections/add-mal-connections.go diff --git a/patches/add-mal-connections/add-mal-connections.go b/patches/add-mal-connections/add-mal-connections.go new file mode 100644 index 00000000..b9bf2596 --- /dev/null +++ b/patches/add-mal-connections/add-mal-connections.go @@ -0,0 +1,35 @@ +package main + +import ( + "strconv" + + "github.com/animenotifier/arn" + "github.com/fatih/color" +) + +func main() { + for anime := range arn.MustStreamAnime() { + malID := anime.GetMapping("myanimelist/anime") + + if malID == "" { + continue + } + + // Assure the string represents a number + malNum, _ := strconv.Atoi(malID) + normalizedID := strconv.Itoa(malNum) + + if malID != normalizedID { + color.Red("%s does not match %d", malID, normalizedID) + continue + } + + // Save + arn.PanicOnError(arn.DB.Set("MyAnimeListToAnime", malID, &arn.MyAnimeListToAnime{ + AnimeID: anime.ID, + ServiceID: malID, + Edited: arn.DateTimeUTC(), + EditedBy: "", + })) + } +}