From 4ca54eb7dbe5489167e3da9b9ae51ff5f2c9030e Mon Sep 17 00:00:00 2001 From: Steve Date: Wed, 1 Dec 2021 13:57:21 -0500 Subject: [PATCH] move count logic to embed section, cuz we know it's right there --- main.go | 6 ++++++ vtuber.go | 10 ---------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/main.go b/main.go index 92b2939..345bf6b 100644 --- a/main.go +++ b/main.go @@ -178,6 +178,11 @@ func main() { log.Println("error embeding video") log.Println(err) } + v.TotalStreams = v.TotalStreams + 1 + CurrStreamCnt = CurrStreamCnt + 1 + if CurrStreamCnt > MostStreamCnt { + MostStreamCnt = CurrStreamCnt + } log.Printf("Embed stream %v for %v ", resp, v.Name) } } @@ -193,6 +198,7 @@ func main() { log.Println("error removed video embed") log.Println(err) } + CurrStreamCnt = CurrStreamCnt - 1 log.Printf("Embed stream %v removed %v", resp, v.Name) } } diff --git a/vtuber.go b/vtuber.go index c38dd8d..e64ac0c 100644 --- a/vtuber.go +++ b/vtuber.go @@ -78,22 +78,12 @@ func (v *Vtuber) Update() error { found := false for _, s := range sl.Streams { if s.Status == "live" { - if v.CurrentStream != s.ID { - v.TotalStreams = v.TotalStreams + 1 - CurrStreamCnt = CurrStreamCnt + 1 - if CurrStreamCnt > MostStreamCnt { - MostStreamCnt = CurrStreamCnt - } - } v.CurrentStream = s.ID v.CurrentStreamTitle = s.Title found = true } } if !found { - if v.CurrentStream != "" { - CurrStreamCnt = CurrStreamCnt - 1 - } v.CurrentStream = "" v.CurrentStreamTitle = "" }