From 88b602f03ab5b3be8688ffccc59f99cb74f225cb Mon Sep 17 00:00:00 2001 From: "lilong.129" Date: Wed, 20 Sep 2023 22:03:13 +0800 Subject: [PATCH] fix: clear current video cache before swipe --- hrp/pkg/uixt/video_crawler.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/hrp/pkg/uixt/video_crawler.go b/hrp/pkg/uixt/video_crawler.go index f31693c5..0c1f6c0f 100644 --- a/hrp/pkg/uixt/video_crawler.go +++ b/hrp/pkg/uixt/video_crawler.go @@ -160,6 +160,10 @@ func (dExt *DriverExt) VideoCrawler(configs *VideoCrawlerConfigs) (err error) { log.Warn().Msg("interrupted in feed crawler") return errors.Wrap(code.InterruptError, "feed crawler interrupted") default: + if err = crawler.clearCurrentVideo(); err != nil { + log.Error().Err(err).Msg("clear cache failed") + } + // swipe to next feed video log.Info().Msg("swipe to next feed video") swipeStartTime := time.Now() @@ -363,6 +367,19 @@ type Video struct { RandomPlayDuration int64 `json:"random_play_duration"` // 随机播放时长(ms) } +func (vc *VideoCrawler) clearCurrentVideo() error { + if !vc.driverExt.plugin.Has("ClearCurrentVideo") { + return errors.New("plugin missing ClearCurrentVideo method") + } + + _, err := vc.driverExt.plugin.Call("ClearCurrentVideo") + if err != nil { + return errors.Wrap(err, "call plugin ClearCurrentVideo failed") + } + + return nil +} + func (vc *VideoCrawler) getCurrentVideo() (video *Video, err error) { if !vc.driverExt.plugin.Has("GetCurrentVideo") { return nil, errors.New("plugin missing GetCurrentVideo method")