mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-11 18:11:21 +08:00
fix: if entry from the preview to the main stream fails, block the use of the exit live room feature
This commit is contained in:
@@ -202,14 +202,15 @@ func (dExt *DriverExt) VideoCrawler(configs *VideoCrawlerConfigs) (err error) {
|
||||
|
||||
switch currentVideo.Type {
|
||||
case VideoType_PreviewLive:
|
||||
isFeed = true
|
||||
// 直播预览流
|
||||
var skipEnterLive bool
|
||||
if crawler.isLiveTargetAchieved() {
|
||||
log.Info().Interface("video", currentVideo).
|
||||
Msg("live count achieved, skip entering live room")
|
||||
skipEnterLive = true
|
||||
} else if rand.Float64() <= 0.50 {
|
||||
// 50% chance skip entering live room
|
||||
} else if rand.Float64() <= 0.70 {
|
||||
// 70% chance skip entering live room
|
||||
log.Info().Msg("skip entering preview live by 50% chance")
|
||||
skipEnterLive = true
|
||||
}
|
||||
@@ -234,7 +235,6 @@ func (dExt *DriverExt) VideoCrawler(configs *VideoCrawlerConfigs) (err error) {
|
||||
sleepTime := math.Min(float64(currentVideo.SimulationPlayDuration), float64(currentVideo.RandomPlayDuration))
|
||||
currentVideo.PlayDuration = int64(sleepTime)
|
||||
}
|
||||
isFeed = false
|
||||
fallthrough
|
||||
|
||||
case VideoType_Live:
|
||||
@@ -277,11 +277,12 @@ func (dExt *DriverExt) VideoCrawler(configs *VideoCrawlerConfigs) (err error) {
|
||||
log.Info().Interface("live", currentVideo).
|
||||
Msg("live count achieved, exit live room")
|
||||
exitLive = true
|
||||
} else if rand.Float64() <= 0.40 {
|
||||
// 10% chance exit live room
|
||||
} else if rand.Float64() <= 0.50 {
|
||||
// 50% chance exit live room
|
||||
log.Info().Msg("exit live room by 10% chance")
|
||||
exitLive = true
|
||||
}
|
||||
// isFeed:通过预览流进入内流失败的情况下,防止使用退出直播间逻辑,影响:首次进入内流,至少会消费两个直播间才能退出
|
||||
if (!isFeed) && exitLive && currentVideo.Type == VideoType_Live {
|
||||
err = crawler.exitLiveRoom()
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user