From 43c6de50c22649ba46b32d960d96a9908bda31f9 Mon Sep 17 00:00:00 2001 From: "lilong.129" Date: Mon, 14 Aug 2023 00:04:31 +0800 Subject: [PATCH] feat: get feed simulation play duration --- hrp/pkg/convert/main.go | 1 - hrp/pkg/uixt/ext.go | 6 ++++++ hrp/pkg/uixt/service_vedem.go | 3 +-- hrp/pkg/uixt/video_crawler.go | 13 ++++++++++--- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/hrp/pkg/convert/main.go b/hrp/pkg/convert/main.go index 6eacc6c6..8e226e10 100644 --- a/hrp/pkg/convert/main.go +++ b/hrp/pkg/convert/main.go @@ -1,7 +1,6 @@ package convert import ( - _ "embed" "path/filepath" "time" diff --git a/hrp/pkg/uixt/ext.go b/hrp/pkg/uixt/ext.go index b955e78e..36e49151 100644 --- a/hrp/pkg/uixt/ext.go +++ b/hrp/pkg/uixt/ext.go @@ -231,6 +231,12 @@ func (dExt *DriverExt) GetStepCacheData() map[string]interface{} { "width": screenSize.Width, "height": screenSize.Height, }, + "video_type": screenResult.VideoType, + "feed": screenResult.Feed, + "live": screenResult.Live, + "swipe_start_time": screenResult.SwipeStartTime, + "swipe_finish_time": screenResult.SwipeFinishTime, + "elapsed": screenResult.Elapsed, } screenResults[imagePath] = data diff --git a/hrp/pkg/uixt/service_vedem.go b/hrp/pkg/uixt/service_vedem.go index 480c9d6e..35134b94 100644 --- a/hrp/pkg/uixt/service_vedem.go +++ b/hrp/pkg/uixt/service_vedem.go @@ -367,8 +367,7 @@ func (dExt *DriverExt) GetScreenResult() (screenResult *ScreenResult, err error) Texts: imageResult.OCRResult.ToOCRTexts(), Tags: nil, } - if imageResult.LiveType != "" { - screenResult.VideoType = "live" + if imageResult.LiveType != "" && imageResult.LiveType != "NoLive" { screenResult.Live = &LiveRoom{ LiveType: imageResult.LiveType, } diff --git a/hrp/pkg/uixt/video_crawler.go b/hrp/pkg/uixt/video_crawler.go index 44c9a7e0..fbeb0249 100644 --- a/hrp/pkg/uixt/video_crawler.go +++ b/hrp/pkg/uixt/video_crawler.go @@ -127,8 +127,11 @@ func (s *VideoStat) incrFeed(screenResult *ScreenResult, driverExt *DriverExt) e } // get simulation play duration - if screenResult.Feed.PlayDuration == 0 { - screenResult.Feed.PlayDuration = getSimulationDuration(s.configs.Feed.SleepRandom) + if screenResult.Feed.SimulationPlayDuration != 0 { + screenResult.Feed.PlayDuration = screenResult.Feed.SimulationPlayDuration + } else { + screenResult.Feed.RandomPlayDuration = getSimulationDuration(s.configs.Feed.SleepRandom) + screenResult.Feed.PlayDuration = screenResult.Feed.RandomPlayDuration } log.Info().Strs("tags", screenResult.Tags). @@ -475,6 +478,7 @@ type FeedVideo struct { UserName string `json:"user_name"` // 视频作者 Duration int64 `json:"duration"` // 视频时长(ms) Caption string `json:"caption"` // 视频文案 + // 视频热度数据 ViewCount int64 `json:"view_count"` // feed 观看数 LikeCount int64 `json:"like_count"` // feed 点赞数 @@ -482,8 +486,11 @@ type FeedVideo struct { CollectCount int64 `json:"collect_count"` // feed 收藏数 ForwardCount int64 `json:"forward_count"` // feed 转发数 ShareCount int64 `json:"share_count"` // feed 分享数 + // 记录仿真决策信息 - PlayDuration int64 `json:"play_duration"` // 播放时长(ms) + PlayDuration int64 `json:"play_duration"` // 播放时长(ms),取自 Simulation/Random + SimulationPlayDuration int64 `json:"simulation_play_duration"` // 仿真播放时长(ms) + RandomPlayDuration int64 `json:"random_play_duration"` // 随机播放时长(ms) // timelines PreloadTimestamp int64 `json:"preload_timestamp"` // 预加载时间戳