From 796a9b2b9643b4391ff3f206f9011e777a53b0a0 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Sat, 10 Mar 2018 23:24:23 +0100 Subject: [PATCH] Display anime source --- pages/anime/anime.pixy | 5 +++ patches/add-mal-fields/add-mal-fields.go | 48 ++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 patches/add-mal-fields/add-mal-fields.go diff --git a/pages/anime/anime.pixy b/pages/anime/anime.pixy index 69e3c084..2eb83a15 100644 --- a/pages/anime/anime.pixy +++ b/pages/anime/anime.pixy @@ -215,6 +215,11 @@ component AnimeInformation(anime *arn.Anime) tr.mountable(data-mountable-type="info") td.anime-info-key End date: td.anime-info-value= anime.EndDate + + if anime.Source != "" && arn.AnimeSourceHumanReadable[anime.Source] != "" + tr.mountable(data-mountable-type="info") + td.anime-info-key Source: + td.anime-info-value= arn.AnimeSourceHumanReadable[anime.Source] if anime.FirstChannel != "" tr.mountable(data-mountable-type="info") diff --git a/patches/add-mal-fields/add-mal-fields.go b/patches/add-mal-fields/add-mal-fields.go new file mode 100644 index 00000000..729e4c81 --- /dev/null +++ b/patches/add-mal-fields/add-mal-fields.go @@ -0,0 +1,48 @@ +package main + +import ( + "fmt" + "strings" + + "github.com/animenotifier/arn" + "github.com/animenotifier/mal" + "github.com/fatih/color" +) + +func main() { + defer arn.Node.Close() + + count := 0 + + for anime := range arn.StreamAnime() { + malID := anime.GetMapping("myanimelist/anime") + + if malID == "" { + continue + } + + malAnimeObj, err := arn.MAL.Get("Anime", malID) + + if err != nil { + continue + } + + malAnime := malAnimeObj.(*mal.Anime) + + fmt.Println(anime.Source) + + anime.Source = strings.ToLower(malAnime.Source) + + if anime.Source == "Unknown" { + anime.Source = "" + } + + anime.Save() + + count++ + + fmt.Println(anime.ID, anime, anime.Source) + } + + color.Green("Processed %d anime", count) +}