From 460d4329f6db8928e5a0ca6bfbc5d8bf416bccb6 Mon Sep 17 00:00:00 2001 From: "lilong.129" Date: Wed, 13 Sep 2023 16:58:12 +0800 Subject: [PATCH] fix: check and handle live popups --- hrp/pkg/uixt/video_crawler.go | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/hrp/pkg/uixt/video_crawler.go b/hrp/pkg/uixt/video_crawler.go index 3f8910f6..cecea20a 100644 --- a/hrp/pkg/uixt/video_crawler.go +++ b/hrp/pkg/uixt/video_crawler.go @@ -141,6 +141,23 @@ func (vc *VideoCrawler) startLiveCrawler(enterPoint PointF) error { } swipeFinishTime := time.Now() + // take screenshot and get screen texts by OCR + screenResult, err := vc.driverExt.GetScreenResult( + WithScreenShotOCR(true), + WithScreenShotUpload(true), + WithScreenShotLiveType(true), + WithScreenShotClosePopups(true), + ) + if err != nil { + log.Error().Err(err).Msg("get screen result failed") + time.Sleep(3 * time.Second) + continue + } + if e := vc.driverExt.tapPopupHandler(screenResult.Popup); e != nil { + log.Error().Err(e).Msg("auto handle popup failed") + return e + } + liveRoom, err := vc.getCurrentVideo() if err != nil || liveRoom.Type != VideoType_Live { if vc.failedCount >= 3 { @@ -150,28 +167,11 @@ func (vc *VideoCrawler) startLiveCrawler(enterPoint PointF) error { log.Warn().Int64("failedCount", vc.failedCount). Msg("get current live room failed") - // check and handle popups - if err := vc.driverExt.ClosePopupsHandler(WithMaxRetryTimes(3)); err != nil { - return err - } - // retry vc.failedCount++ continue } - // take screenshot and get screen texts by OCR - screenResult, err := vc.driverExt.GetScreenResult( - WithScreenShotOCR(true), - WithScreenShotUpload(true), - WithScreenShotLiveType(true), - ) - if err != nil { - log.Error().Err(err).Msg("get screen result failed") - time.Sleep(3 * time.Second) - continue - } - // add live type if screenResult.imageResult != nil && screenResult.imageResult.LiveType != "" &&