diff --git a/main.go b/main.go index 83b6aa1..70aa75b 100644 --- a/main.go +++ b/main.go @@ -152,10 +152,7 @@ func main() { for _, v := range vtubers { v.Update() if v.IsLive() { - CurrStreamCnt = CurrStreamCnt + 1 - if CurrStreamCnt > MostStreamCnt { - MostStreamCnt = CurrStreamCnt - } + for _, room := range rooms { //check to see if already embeded var content YoutubeWidget @@ -182,7 +179,6 @@ func main() { } else { //Not live, check to see if there's any embeds and remove them for _, room := range rooms { - CurrStreamCnt = CurrStreamCnt - 1 var content YoutubeWidget err = client.StateEvent(room, event.NewEventType("im.vector.modular.widgets"), "dimension-m.video-simp-"+v.Name, &content) if err == nil && content.ID != "" { diff --git a/vtuber.go b/vtuber.go index 7160952..c38dd8d 100644 --- a/vtuber.go +++ b/vtuber.go @@ -78,13 +78,22 @@ 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 - v.TotalStreams = v.TotalStreams + 1 found = true } } if !found { + if v.CurrentStream != "" { + CurrStreamCnt = CurrStreamCnt - 1 + } v.CurrentStream = "" v.CurrentStreamTitle = "" }