mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 19:39:44 +08:00
change: add live type
This commit is contained in:
@@ -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 识别的图标
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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).
|
||||
|
||||
Reference in New Issue
Block a user