mirror of
https://github.com/httprunner/httprunner.git
synced 2026-08-28 03:30:01 +08:00
fix: simulation watch video in the preview live when live count achieved
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package uixt
|
package uixt
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"math"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
@@ -201,9 +202,19 @@ func (dExt *DriverExt) VideoCrawler(configs *VideoCrawlerConfigs) (err error) {
|
|||||||
case VideoType_PreviewLive:
|
case VideoType_PreviewLive:
|
||||||
// 直播预览流
|
// 直播预览流
|
||||||
if crawler.isLiveTargetAchieved() {
|
if crawler.isLiveTargetAchieved() {
|
||||||
log.Info().Interface("live", screenResult.Video).
|
// 达标后不再进入直播间
|
||||||
Msg("live count achieved, skip")
|
crawler.LiveCount++
|
||||||
continue
|
dExt.cacheStepData.screenResults[time.Now().String()] = screenResult
|
||||||
|
// 观播时长取随机时长与仿真时长的最小值
|
||||||
|
sleepTime := math.Min(float64(feedVideo.SimulationPlayDuration), float64(feedVideo.RandomPlayDuration))
|
||||||
|
feedVideo.PlayDuration = int64(sleepTime)
|
||||||
|
log.Info().
|
||||||
|
Strs("tags", screenResult.Tags).
|
||||||
|
Interface("video", feedVideo).
|
||||||
|
Msg("found live success")
|
||||||
|
// simulation watch feed video
|
||||||
|
sleepStrict(swipeFinishTime, feedVideo.PlayDuration)
|
||||||
|
break
|
||||||
} else {
|
} else {
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
// live target not achieved, enter live
|
// live target not achieved, enter live
|
||||||
@@ -375,15 +386,16 @@ func (vc *VideoCrawler) getCurrentVideo() (video *Video, err error) {
|
|||||||
return nil, errors.Wrap(err, "json unmarshal video info failed")
|
return nil, errors.Wrap(err, "json unmarshal video info failed")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if video.Type == VideoType_Live || video.Type == VideoType_PreviewLive {
|
||||||
|
video.RandomPlayDuration = getSimulationDuration(vc.configs.Live.SleepRandom)
|
||||||
|
} else {
|
||||||
|
video.RandomPlayDuration = getSimulationDuration(vc.configs.Live.SleepRandom)
|
||||||
|
}
|
||||||
|
|
||||||
// get simulation play duration
|
// get simulation play duration
|
||||||
if video.SimulationPlayDuration != 0 {
|
if video.SimulationPlayDuration != 0 {
|
||||||
video.PlayDuration = video.SimulationPlayDuration
|
video.PlayDuration = video.SimulationPlayDuration
|
||||||
} else {
|
} else {
|
||||||
if video.Type == VideoType_Live || video.Type == VideoType_PreviewLive {
|
|
||||||
video.RandomPlayDuration = getSimulationDuration(vc.configs.Live.SleepRandom)
|
|
||||||
} else {
|
|
||||||
video.RandomPlayDuration = getSimulationDuration(vc.configs.Live.SleepRandom)
|
|
||||||
}
|
|
||||||
video.PlayDuration = video.RandomPlayDuration
|
video.PlayDuration = video.RandomPlayDuration
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user