mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-09 06:23:52 +08:00
fix: skip entering preview live by 25% chance
This commit is contained in:
@@ -207,7 +207,18 @@ func (dExt *DriverExt) VideoCrawler(configs *VideoCrawlerConfigs) (err error) {
|
|||||||
switch feedVideo.Type {
|
switch feedVideo.Type {
|
||||||
case VideoType_PreviewLive:
|
case VideoType_PreviewLive:
|
||||||
// 直播预览流
|
// 直播预览流
|
||||||
|
var skipEnterLive bool
|
||||||
if crawler.isLiveTargetAchieved() {
|
if crawler.isLiveTargetAchieved() {
|
||||||
|
log.Info().Interface("live", screenResult.Video).
|
||||||
|
Msg("live count achieved, skip entering live room")
|
||||||
|
skipEnterLive = true
|
||||||
|
} else if rand.Float64() <= 0.25 {
|
||||||
|
// 25% chance skip entering live room
|
||||||
|
log.Info().Msg("skip entering preview live by 25% chance")
|
||||||
|
skipEnterLive = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if skipEnterLive {
|
||||||
// 达标后不再进入直播间
|
// 达标后不再进入直播间
|
||||||
crawler.LiveCount++
|
crawler.LiveCount++
|
||||||
dExt.cacheStepData.screenResults[time.Now().String()] = screenResult
|
dExt.cacheStepData.screenResults[time.Now().String()] = screenResult
|
||||||
@@ -223,13 +234,6 @@ func (dExt *DriverExt) VideoCrawler(configs *VideoCrawlerConfigs) (err error) {
|
|||||||
break
|
break
|
||||||
} else {
|
} else {
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
|
|
||||||
if rand.Float64() >= 0.75 {
|
|
||||||
// 75% chance enter live room
|
|
||||||
log.Info().Msg("skip enter live room by 25% chance")
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
// live target not achieved, enter live
|
// live target not achieved, enter live
|
||||||
entryPoint := PointF{
|
entryPoint := PointF{
|
||||||
X: float64(dExt.windowSize.Width / 2),
|
X: float64(dExt.windowSize.Width / 2),
|
||||||
@@ -289,7 +293,7 @@ func (dExt *DriverExt) VideoCrawler(configs *VideoCrawlerConfigs) (err error) {
|
|||||||
var exitLive bool
|
var exitLive bool
|
||||||
if crawler.isLiveTargetAchieved() {
|
if crawler.isLiveTargetAchieved() {
|
||||||
log.Info().Interface("live", screenResult.Video).
|
log.Info().Interface("live", screenResult.Video).
|
||||||
Msg("live count achieved, exit live house")
|
Msg("live count achieved, exit live room")
|
||||||
exitLive = true
|
exitLive = true
|
||||||
} else if rand.Float64() <= 0.25 {
|
} else if rand.Float64() <= 0.25 {
|
||||||
// 25% chance exit live room
|
// 25% chance exit live room
|
||||||
|
|||||||
Reference in New Issue
Block a user