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:
徐聪
2024-01-04 11:26:22 +08:00
parent f98abbda7f
commit 9fa3ae52f6

View File

@@ -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 {