diff --git a/hrp/pkg/uixt/ext.go b/hrp/pkg/uixt/ext.go index 2cd23504..a7d93797 100644 --- a/hrp/pkg/uixt/ext.go +++ b/hrp/pkg/uixt/ext.go @@ -56,7 +56,6 @@ type ScreenResult struct { imagePath string // image file path imageResult *ImageResult // image result - LiveType string UploadedURL string `json:"uploaded_url"` // uploaded image url Texts OCRTexts `json:"texts"` // dumped raw OCRTexts Icons UIResultMap `json:"icons"` // CV 识别的图标 diff --git a/hrp/pkg/uixt/service_vedem.go b/hrp/pkg/uixt/service_vedem.go index fae52514..099cd9cd 100644 --- a/hrp/pkg/uixt/service_vedem.go +++ b/hrp/pkg/uixt/service_vedem.go @@ -54,8 +54,8 @@ func (o OCRResults) ToOCRTexts() (ocrTexts OCRTexts) { } type ImageResult struct { - URL string `json:"url"` // image uploaded url - OCRResult OCRResults `json:"ocrResult"` // OCR texts + URL string `json:"url,omitempty"` // image uploaded url + OCRResult OCRResults `json:"ocrResult,omitempty"` // OCR texts // NoLive(非直播间) // Shop(电商) // LifeService(生活服务) @@ -66,9 +66,9 @@ type ImageResult struct { // Media(媒体) // Chat(语音) // Event(赛事) - LiveType string `json:"liveType"` // 直播间类型 - UIResult UIResultMap `json:"uiResult"` // 图标检测 - CPResult ClosePopupsResult `json:"closeResult"` // 弹窗按钮检测 + LiveType string `json:"liveType,omitempty"` // 直播间类型 + UIResult UIResultMap `json:"uiResult,omitempty"` // 图标检测 + CPResult *ClosePopupsResult `json:"closeResult,omitempty"` // 弹窗按钮检测 } type APIResponseImage struct { @@ -382,14 +382,12 @@ func (dExt *DriverExt) GetScreenResult(options ...ActionOption) (screenResult *S return nil, err } if imageResult != nil { + screenResult.imageResult = imageResult screenResult.ScreenshotCVElapsed = time.Since(startTime).Milliseconds() - screenshotTakeElapsed screenResult.Texts = imageResult.OCRResult.ToOCRTexts() screenResult.UploadedURL = imageResult.URL screenResult.Icons = imageResult.UIResult - if imageResult.LiveType != "" && imageResult.LiveType != "NoLive" { - screenResult.LiveType = imageResult.LiveType - } if actionOptions.ScreenShotWithClosePopups { screenResult.Popup = &PopupInfo{ Type: imageResult.CPResult.Type, diff --git a/hrp/pkg/uixt/video_crawler.go b/hrp/pkg/uixt/video_crawler.go index 640928a7..fea5d750 100644 --- a/hrp/pkg/uixt/video_crawler.go +++ b/hrp/pkg/uixt/video_crawler.go @@ -185,17 +185,26 @@ func (vc *VideoCrawler) startLiveCrawler(enterPoint PointF) error { // take screenshot and get screen texts by OCR screenResult, err := vc.driverExt.GetScreenResult( - WithScreenShotOCR(true), WithScreenShotUpload(true), WithScreenShotLiveType(true)) + WithScreenShotOCR(true), + WithScreenShotUpload(true), + WithScreenShotLiveType(true), + ) if err != nil { log.Error().Err(err).Msg("OCR GetTexts failed") time.Sleep(3 * time.Second) continue } - liveRoom.LiveType = screenResult.LiveType - screenResult.Live = liveRoom + + // add live type + if screenResult.imageResult != nil && + screenResult.imageResult.LiveType != "" && + screenResult.imageResult.LiveType != "NoLive" { + liveRoom.LiveType = screenResult.imageResult.LiveType + } // incr live count screenResult.VideoType = "live" + screenResult.Live = liveRoom vc.LiveCount++ log.Info().Strs("tags", screenResult.Tags). Interface("live", screenResult.Live).