From dba71590822335824c4607fea81555cf0361a55c Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Sun, 1 Jul 2018 10:58:08 +0900 Subject: [PATCH] Added new patch to mark current anime --- .../mark-month-as-current.go | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 patches/mark-month-as-current/mark-month-as-current.go diff --git a/patches/mark-month-as-current/mark-month-as-current.go b/patches/mark-month-as-current/mark-month-as-current.go new file mode 100644 index 00000000..cc89b452 --- /dev/null +++ b/patches/mark-month-as-current/mark-month-as-current.go @@ -0,0 +1,32 @@ +package main + +import ( + "fmt" + "time" + + "github.com/animenotifier/arn" + "github.com/fatih/color" +) + +func main() { + color.Yellow("Marking current month as current") + + defer color.Green("Finished") + defer arn.Node.Close() + + now := time.Now() + currentYear := now.Year() + currentMonth := now.Month() + + for anime := range arn.StreamAnime() { + animeStart := anime.StartDateTime() + + if anime.Status != "current" && animeStart.Year() == currentYear && animeStart.Month() == currentMonth { + fmt.Println(anime) + anime.Status = "current" + anime.Save() + } + } + + time.Sleep(1 * time.Second) +}