mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-04 23:16:57 +08:00
feat: get simulation watch duration for live
This commit is contained in:
@@ -179,14 +179,14 @@ func (vc *VideoCrawler) incrLive(screenResult *ScreenResult) error {
|
|||||||
screenResult.VideoType = "live"
|
screenResult.VideoType = "live"
|
||||||
// TODO: check live type
|
// TODO: check live type
|
||||||
|
|
||||||
if screenResult.Live == nil {
|
// get simulation watch duration
|
||||||
screenResult.Live = &LiveRoom{}
|
if screenResult.Live.SimulationWatchDuration != 0 {
|
||||||
|
screenResult.Live.WatchDuration = screenResult.Live.SimulationWatchDuration
|
||||||
|
} else {
|
||||||
|
screenResult.Live.RandomWatchDuration = getSimulationDuration(vc.configs.Live.SleepRandom)
|
||||||
|
screenResult.Live.WatchDuration = screenResult.Live.RandomWatchDuration
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: add popularity data for live
|
|
||||||
|
|
||||||
screenResult.Live.SimulationWatchDuration = getSimulationDuration(vc.configs.Live.SleepRandom)
|
|
||||||
|
|
||||||
log.Info().Strs("tags", screenResult.Tags).
|
log.Info().Strs("tags", screenResult.Tags).
|
||||||
Interface("live", screenResult.Live).
|
Interface("live", screenResult.Live).
|
||||||
Msg("found live success")
|
Msg("found live success")
|
||||||
@@ -264,6 +264,12 @@ func (vc *VideoCrawler) startLiveCrawler(enterPoint PointF) error {
|
|||||||
// wait for live video loading
|
// wait for live video loading
|
||||||
time.Sleep(5 * time.Second)
|
time.Sleep(5 * time.Second)
|
||||||
|
|
||||||
|
// TODO: get app event trackings
|
||||||
|
liveRoom, err := vc.getCurrentLiveRoom()
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrap(err, "get current live event trackings failed")
|
||||||
|
}
|
||||||
|
|
||||||
// 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()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -271,15 +277,17 @@ func (vc *VideoCrawler) startLiveCrawler(enterPoint PointF) error {
|
|||||||
time.Sleep(3 * time.Second)
|
time.Sleep(3 * time.Second)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
screenResult.Live = liveRoom
|
||||||
|
|
||||||
// check live type and incr live count
|
// incr live count
|
||||||
if err := vc.incrLive(screenResult); err != nil {
|
err = vc.incrLive(screenResult)
|
||||||
log.Error().Err(err).Msg("incr live failed")
|
if err != nil {
|
||||||
|
log.Warn().Err(err).Msg("incr live failed")
|
||||||
|
} else {
|
||||||
|
// simulation watch live video
|
||||||
|
sleepStrict(swipeFinishTime, screenResult.Live.SimulationWatchDuration)
|
||||||
}
|
}
|
||||||
|
|
||||||
// simulation watch live video
|
|
||||||
sleepStrict(swipeFinishTime, screenResult.Live.SimulationWatchDuration)
|
|
||||||
|
|
||||||
// log swipe timelines
|
// log swipe timelines
|
||||||
screenResult.SwipeStartTime = swipeStartTime.UnixMilli()
|
screenResult.SwipeStartTime = swipeStartTime.UnixMilli()
|
||||||
screenResult.SwipeFinishTime = swipeFinishTime.UnixMilli()
|
screenResult.SwipeFinishTime = swipeFinishTime.UnixMilli()
|
||||||
@@ -359,13 +367,12 @@ func (dExt *DriverExt) VideoCrawler(configs *VideoCrawlerConfigs) (err error) {
|
|||||||
}
|
}
|
||||||
swipeFinishTime := time.Now()
|
swipeFinishTime := time.Now()
|
||||||
|
|
||||||
var screenResult *ScreenResult
|
|
||||||
// get app event trackings
|
// get app event trackings
|
||||||
feedVideo, err := crawler.getCurrentFeedVideo()
|
feedVideo, err := crawler.getCurrentFeedVideo()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "get app event trackings failed")
|
return errors.Wrap(err, "get current feed event trackings failed")
|
||||||
}
|
}
|
||||||
screenResult = &ScreenResult{
|
screenResult := &ScreenResult{
|
||||||
Feed: feedVideo,
|
Feed: feedVideo,
|
||||||
Texts: nil,
|
Texts: nil,
|
||||||
Tags: nil,
|
Tags: nil,
|
||||||
@@ -451,7 +458,9 @@ type LiveRoom struct {
|
|||||||
LikeCount int64 `json:"like_count"` // 点赞数
|
LikeCount int64 `json:"like_count"` // 点赞数
|
||||||
|
|
||||||
// 记录仿真决策信息
|
// 记录仿真决策信息
|
||||||
|
WatchDuration int64 `json:"watch_duration"` // 观播时长(ms),取自 Simulation/Random
|
||||||
SimulationWatchDuration int64 `json:"simulation_watch_duration"` // 仿真观播时长(ms)
|
SimulationWatchDuration int64 `json:"simulation_watch_duration"` // 仿真观播时长(ms)
|
||||||
|
RandomWatchDuration int64 `json:"random_watch_duration"` // 随机观播时长(ms)
|
||||||
|
|
||||||
// timelines
|
// timelines
|
||||||
PreloadTimestamp int64 `json:"preload_timestamp"` // feed 预加载时间戳
|
PreloadTimestamp int64 `json:"preload_timestamp"` // feed 预加载时间戳
|
||||||
|
|||||||
Reference in New Issue
Block a user