From 9985d926afb2f2207cb23e57b4cd34361b7a2431 Mon Sep 17 00:00:00 2001 From: cooscao Date: Wed, 22 May 2024 20:20:31 +0800 Subject: [PATCH] feat: add live popularity --- hrp/internal/version/VERSION | 2 +- hrp/pkg/uixt/action.go | 25 +++++++++++++++++++------ hrp/pkg/uixt/service_vedem.go | 9 +++++---- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/hrp/internal/version/VERSION b/hrp/internal/version/VERSION index 42cdebb8..9fc5fe9c 100644 --- a/hrp/internal/version/VERSION +++ b/hrp/internal/version/VERSION @@ -1,2 +1,2 @@ -v4.5.0 +v4.5.1 diff --git a/hrp/pkg/uixt/action.go b/hrp/pkg/uixt/action.go index 6ca6bcce..1a555f91 100644 --- a/hrp/pkg/uixt/action.go +++ b/hrp/pkg/uixt/action.go @@ -117,12 +117,13 @@ type ActionOptions struct { Custom map[string]interface{} `json:"custom,omitempty" yaml:"custom,omitempty"` // screenshot related - ScreenShotWithOCR bool `json:"screenshot_with_ocr,omitempty" yaml:"screenshot_with_ocr,omitempty"` - ScreenShotWithUpload bool `json:"screenshot_with_upload,omitempty" yaml:"screenshot_with_upload,omitempty"` - ScreenShotWithLiveType bool `json:"screenshot_with_live_type,omitempty" yaml:"screenshot_with_live_type,omitempty"` - ScreenShotWithUITypes []string `json:"screenshot_with_ui_types,omitempty" yaml:"screenshot_with_ui_types,omitempty"` - ScreenShotWithClosePopups bool `json:"screenshot_with_close_popups,omitempty" yaml:"screenshot_with_close_popups,omitempty"` - ScreenShotWithOCRCluster string `json:"screenshot_with_ocr_cluster,omitempty" yaml:"screenshot_with_ocr_cluster,omitempty"` + ScreenShotWithOCR bool `json:"screenshot_with_ocr,omitempty" yaml:"screenshot_with_ocr,omitempty"` + ScreenShotWithUpload bool `json:"screenshot_with_upload,omitempty" yaml:"screenshot_with_upload,omitempty"` + ScreenShotWithLiveType bool `json:"screenshot_with_live_type,omitempty" yaml:"screenshot_with_live_type,omitempty"` + ScreenShotWithLivePopularity bool `json:"screenshot_with_live_popularity,omitempty" yaml:"screenshot_with_live_popularity,omitempty"` + ScreenShotWithUITypes []string `json:"screenshot_with_ui_types,omitempty" yaml:"screenshot_with_ui_types,omitempty"` + ScreenShotWithClosePopups bool `json:"screenshot_with_close_popups,omitempty" yaml:"screenshot_with_close_popups,omitempty"` + ScreenShotWithOCRCluster string `json:"screenshot_with_ocr_cluster,omitempty" yaml:"screenshot_with_ocr_cluster,omitempty"` } func (o *ActionOptions) Options() []ActionOption { @@ -226,6 +227,9 @@ func (o *ActionOptions) Options() []ActionOption { if o.ScreenShotWithLiveType { options = append(options, WithScreenShotLiveType(true)) } + if o.ScreenShotWithLivePopularity { + options = append(options, WithScreenShotLivePopularity(true)) + } if len(o.ScreenShotWithUITypes) > 0 { options = append(options, WithScreenShotUITypes(o.ScreenShotWithUITypes...)) } @@ -250,6 +254,9 @@ func (o *ActionOptions) screenshotActions() []string { if o.ScreenShotWithLiveType { actions = append(actions, "liveType") } + if o.ScreenShotWithLivePopularity { + actions = append(actions, "livePopularity") + } // UI detection if len(o.ScreenShotWithUITypes) > 0 { actions = append(actions, "ui") @@ -476,6 +483,12 @@ func WithScreenShotLiveType(liveTypeOn bool) ActionOption { } } +func WithScreenShotLivePopularity(livePopularityOn bool) ActionOption { + return func(o *ActionOptions) { + o.ScreenShotWithLivePopularity = livePopularityOn + } +} + func WithScreenShotUITypes(uiTypes ...string) ActionOption { return func(o *ActionOptions) { o.ScreenShotWithUITypes = uiTypes diff --git a/hrp/pkg/uixt/service_vedem.go b/hrp/pkg/uixt/service_vedem.go index 186296c3..60aac2a1 100644 --- a/hrp/pkg/uixt/service_vedem.go +++ b/hrp/pkg/uixt/service_vedem.go @@ -67,9 +67,10 @@ type ImageResult struct { // Media(媒体) // Chat(语音) // Event(赛事) - LiveType string `json:"liveType,omitempty"` // 直播间类型 - UIResult UIResultMap `json:"uiResult,omitempty"` // 图标检测 - CPResult *ClosePopupsResult `json:"closeResult,omitempty"` // 弹窗按钮检测 + LiveType string `json:"liveType,omitempty"` // 直播间类型 + LivePopularity int64 `json:"livePopularity,omitempty"` // 直播间热度 + UIResult UIResultMap `json:"uiResult,omitempty"` // 图标检测 + CPResult *ClosePopupsResult `json:"closeResult,omitempty"` // 弹窗按钮检测 } type APIResponseImage struct { @@ -417,7 +418,7 @@ func (dExt *DriverExt) GetScreenResult(options ...ActionOption) (screenResult *S screenResult.Texts = imageResult.OCRResult.ToOCRTexts() screenResult.UploadedURL = imageResult.URL screenResult.Icons = imageResult.UIResult - screenResult.Video = &Video{LiveType: imageResult.LiveType} + screenResult.Video = &Video{LiveType: imageResult.LiveType, ViewCount: imageResult.LivePopularity} if actionOptions.ScreenShotWithClosePopups && imageResult.CPResult != nil { screenResult.Popup = &PopupInfo{