change: add live type

This commit is contained in:
lilong.129
2023-08-29 14:23:26 +08:00
parent 5b0f158d29
commit bd9c761a97
3 changed files with 18 additions and 12 deletions

View File

@@ -56,7 +56,6 @@ type ScreenResult struct {
imagePath string // image file path imagePath string // image file path
imageResult *ImageResult // image result imageResult *ImageResult // image result
LiveType string
UploadedURL string `json:"uploaded_url"` // uploaded image url UploadedURL string `json:"uploaded_url"` // uploaded image url
Texts OCRTexts `json:"texts"` // dumped raw OCRTexts Texts OCRTexts `json:"texts"` // dumped raw OCRTexts
Icons UIResultMap `json:"icons"` // CV 识别的图标 Icons UIResultMap `json:"icons"` // CV 识别的图标

View File

@@ -54,8 +54,8 @@ func (o OCRResults) ToOCRTexts() (ocrTexts OCRTexts) {
} }
type ImageResult struct { type ImageResult struct {
URL string `json:"url"` // image uploaded url URL string `json:"url,omitempty"` // image uploaded url
OCRResult OCRResults `json:"ocrResult"` // OCR texts OCRResult OCRResults `json:"ocrResult,omitempty"` // OCR texts
// NoLive非直播间 // NoLive非直播间
// Shop电商 // Shop电商
// LifeService生活服务 // LifeService生活服务
@@ -66,9 +66,9 @@ type ImageResult struct {
// Media媒体 // Media媒体
// Chat语音 // Chat语音
// Event赛事 // Event赛事
LiveType string `json:"liveType"` // 直播间类型 LiveType string `json:"liveType,omitempty"` // 直播间类型
UIResult UIResultMap `json:"uiResult"` // 图标检测 UIResult UIResultMap `json:"uiResult,omitempty"` // 图标检测
CPResult ClosePopupsResult `json:"closeResult"` // 弹窗按钮检测 CPResult *ClosePopupsResult `json:"closeResult,omitempty"` // 弹窗按钮检测
} }
type APIResponseImage struct { type APIResponseImage struct {
@@ -382,14 +382,12 @@ func (dExt *DriverExt) GetScreenResult(options ...ActionOption) (screenResult *S
return nil, err return nil, err
} }
if imageResult != nil { if imageResult != nil {
screenResult.imageResult = imageResult
screenResult.ScreenshotCVElapsed = time.Since(startTime).Milliseconds() - screenshotTakeElapsed screenResult.ScreenshotCVElapsed = time.Since(startTime).Milliseconds() - screenshotTakeElapsed
screenResult.Texts = imageResult.OCRResult.ToOCRTexts() screenResult.Texts = imageResult.OCRResult.ToOCRTexts()
screenResult.UploadedURL = imageResult.URL screenResult.UploadedURL = imageResult.URL
screenResult.Icons = imageResult.UIResult screenResult.Icons = imageResult.UIResult
if imageResult.LiveType != "" && imageResult.LiveType != "NoLive" {
screenResult.LiveType = imageResult.LiveType
}
if actionOptions.ScreenShotWithClosePopups { if actionOptions.ScreenShotWithClosePopups {
screenResult.Popup = &PopupInfo{ screenResult.Popup = &PopupInfo{
Type: imageResult.CPResult.Type, Type: imageResult.CPResult.Type,

View File

@@ -185,17 +185,26 @@ func (vc *VideoCrawler) startLiveCrawler(enterPoint PointF) error {
// take screenshot and get screen texts by OCR // take screenshot and get screen texts by OCR
screenResult, err := vc.driverExt.GetScreenResult( screenResult, err := vc.driverExt.GetScreenResult(
WithScreenShotOCR(true), WithScreenShotUpload(true), WithScreenShotLiveType(true)) WithScreenShotOCR(true),
WithScreenShotUpload(true),
WithScreenShotLiveType(true),
)
if err != nil { if err != nil {
log.Error().Err(err).Msg("OCR GetTexts failed") log.Error().Err(err).Msg("OCR GetTexts failed")
time.Sleep(3 * time.Second) time.Sleep(3 * time.Second)
continue 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 // incr live count
screenResult.VideoType = "live" screenResult.VideoType = "live"
screenResult.Live = liveRoom
vc.LiveCount++ vc.LiveCount++
log.Info().Strs("tags", screenResult.Tags). log.Info().Strs("tags", screenResult.Tags).
Interface("live", screenResult.Live). Interface("live", screenResult.Live).