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