From 3c86fac5538c4316a355e52d566226cf10a94d28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E8=81=AA?= Date: Tue, 19 Sep 2023 21:09:45 +0800 Subject: [PATCH] fix: simulation watch video in the preview live when live count achieved --- hrp/pkg/uixt/video_crawler.go | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/hrp/pkg/uixt/video_crawler.go b/hrp/pkg/uixt/video_crawler.go index f6759392..aa374cca 100644 --- a/hrp/pkg/uixt/video_crawler.go +++ b/hrp/pkg/uixt/video_crawler.go @@ -1,6 +1,7 @@ package uixt import ( + "math" "time" "github.com/pkg/errors" @@ -201,9 +202,19 @@ func (dExt *DriverExt) VideoCrawler(configs *VideoCrawlerConfigs) (err error) { case VideoType_PreviewLive: // 直播预览流 if crawler.isLiveTargetAchieved() { - log.Info().Interface("live", screenResult.Video). - Msg("live count achieved, skip") - continue + // 达标后不再进入直播间 + crawler.LiveCount++ + 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 { time.Sleep(1 * time.Second) // 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") } + 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 if video.SimulationPlayDuration != 0 { video.PlayDuration = video.SimulationPlayDuration } 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 }