mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-09 06:23:52 +08:00
change: add VideoType
This commit is contained in:
@@ -56,11 +56,10 @@ type ScreenResult struct {
|
|||||||
imageResult *ImageResult // image result
|
imageResult *ImageResult // image result
|
||||||
|
|
||||||
Resolution Size `json:"resolution"`
|
Resolution Size `json:"resolution"`
|
||||||
UploadedURL string `json:"uploaded_url"` // uploaded image url
|
UploadedURL string `json:"uploaded_url"` // uploaded image url
|
||||||
Texts OCRTexts `json:"texts"` // dumped raw OCRTexts
|
Texts OCRTexts `json:"texts"` // dumped raw OCRTexts
|
||||||
Icons UIResultMap `json:"icons"` // CV 识别的图标
|
Icons UIResultMap `json:"icons"` // CV 识别的图标
|
||||||
Tags []string `json:"tags"` // tags for image, e.g. ["feed", "ad", "live"]
|
Tags []string `json:"tags"` // tags for image, e.g. ["feed", "ad", "live"]
|
||||||
VideoType string `json:"video_type,omitempty"` // video type: feed, live-preview or live
|
|
||||||
Video *Video `json:"video,omitempty"`
|
Video *Video `json:"video,omitempty"`
|
||||||
Popup *PopupInfo `json:"popup,omitempty"`
|
Popup *PopupInfo `json:"popup,omitempty"`
|
||||||
|
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ func (vc *VideoCrawler) isTargetAchieved() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (vc *VideoCrawler) checkLiveVideo(video *Video) (enterPoint PointF, yes bool) {
|
func (vc *VideoCrawler) checkLiveVideo(video *Video) (enterPoint PointF, yes bool) {
|
||||||
if video.Type != "preview-live" {
|
if video.Type != VideoType_PreviewLive {
|
||||||
return PointF{}, false
|
return PointF{}, false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,9 +179,9 @@ func (vc *VideoCrawler) startLiveCrawler(enterPoint PointF) error {
|
|||||||
|
|
||||||
liveRoom, err := vc.getCurrentVideo()
|
liveRoom, err := vc.getCurrentVideo()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if vc.failedCount >= 3 {
|
if vc.failedCount >= 5 {
|
||||||
// failed 3 consecutive times
|
// failed 5 consecutive times
|
||||||
return errors.New("get current live event trackings failed 3 consecutive times")
|
return errors.New("get current live event trackings failed 5 consecutive times")
|
||||||
}
|
}
|
||||||
// retry
|
// retry
|
||||||
vc.failedCount++
|
vc.failedCount++
|
||||||
@@ -209,7 +209,6 @@ func (vc *VideoCrawler) startLiveCrawler(enterPoint PointF) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// incr live count
|
// incr live count
|
||||||
screenResult.VideoType = "live"
|
|
||||||
screenResult.Video = liveRoom
|
screenResult.Video = liveRoom
|
||||||
vc.LiveCount++
|
vc.LiveCount++
|
||||||
log.Info().Strs("tags", screenResult.Tags).
|
log.Info().Strs("tags", screenResult.Tags).
|
||||||
@@ -306,9 +305,9 @@ func (dExt *DriverExt) VideoCrawler(configs *VideoCrawlerConfigs) (err error) {
|
|||||||
// retry 3 times if get feed failed, abort if fail 3 consecutive times
|
// retry 3 times if get feed failed, abort if fail 3 consecutive times
|
||||||
feedVideo, err := crawler.getCurrentVideo()
|
feedVideo, err := crawler.getCurrentVideo()
|
||||||
if err != nil || feedVideo.Type == "" {
|
if err != nil || feedVideo.Type == "" {
|
||||||
if crawler.failedCount >= 3 {
|
if crawler.failedCount >= 10 {
|
||||||
// failed 3 consecutive times
|
// failed 10 consecutive times
|
||||||
return errors.New("get current feed video failed 3 consecutive times")
|
return errors.New("get current feed video failed 10 consecutive times")
|
||||||
}
|
}
|
||||||
log.Warn().Interface("feedVideo", feedVideo).Msg("get current feed video failed")
|
log.Warn().Interface("feedVideo", feedVideo).Msg("get current feed video failed")
|
||||||
// retry
|
// retry
|
||||||
@@ -334,7 +333,6 @@ func (dExt *DriverExt) VideoCrawler(configs *VideoCrawlerConfigs) (err error) {
|
|||||||
// check if live video && run live crawler
|
// check if live video && run live crawler
|
||||||
if enterPoint, isLive := crawler.checkLiveVideo(feedVideo); isLive {
|
if enterPoint, isLive := crawler.checkLiveVideo(feedVideo); isLive {
|
||||||
// 直播预览流
|
// 直播预览流
|
||||||
screenResult.VideoType = "live-preview"
|
|
||||||
// TODO
|
// TODO
|
||||||
// screenResult.Live = feedVideo
|
// screenResult.Live = feedVideo
|
||||||
log.Info().Msg("live video found")
|
log.Info().Msg("live video found")
|
||||||
@@ -350,7 +348,6 @@ func (dExt *DriverExt) VideoCrawler(configs *VideoCrawlerConfigs) (err error) {
|
|||||||
} else {
|
} else {
|
||||||
// 点播
|
// 点播
|
||||||
// check feed type and incr feed count
|
// check feed type and incr feed count
|
||||||
screenResult.VideoType = "feed"
|
|
||||||
screenResult.Video = feedVideo
|
screenResult.Video = feedVideo
|
||||||
crawler.FeedCount++
|
crawler.FeedCount++
|
||||||
log.Info().
|
log.Info().
|
||||||
@@ -387,9 +384,17 @@ func (dExt *DriverExt) VideoCrawler(configs *VideoCrawlerConfigs) (err error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type VideoType string
|
||||||
|
|
||||||
|
const (
|
||||||
|
VideoType_Feed VideoType = "FEED"
|
||||||
|
VideoType_PreviewLive VideoType = "PREVIEW-LIVE" // 直播预览流
|
||||||
|
VideoType_Live VideoType = "LIVE"
|
||||||
|
VideoType_Image VideoType = "IMAGE"
|
||||||
|
)
|
||||||
|
|
||||||
type Video struct {
|
type Video struct {
|
||||||
Type string `json:"type" required:"true"` // 视频类型, feed/preview-live/live
|
Type VideoType `json:"type" required:"true"` // 视频类型, feed/preview-live/live/image
|
||||||
IsLivePreview bool `json:"is_live_preview"` // 是否直播预览流
|
|
||||||
|
|
||||||
// Feed 视频基础数据
|
// Feed 视频基础数据
|
||||||
CacheKey string `json:"cache_key,omitempty"` // cachekey
|
CacheKey string `json:"cache_key,omitempty"` // cachekey
|
||||||
@@ -419,59 +424,14 @@ type Video struct {
|
|||||||
// 视频热度数据
|
// 视频热度数据
|
||||||
AudienceCount int64 `json:"audience_count,omitempty"` // 直播间人数
|
AudienceCount int64 `json:"audience_count,omitempty"` // 直播间人数
|
||||||
|
|
||||||
// 记录仿真决策信息
|
// Image
|
||||||
PlayDuration int64 `json:"play_duration"` // 播放时长(ms),取自 Simulation/Random
|
// ImageURLs []string
|
||||||
SimulationPlayProgress float64 `json:"simulation_play_progress"` // 仿真播放比例(完播率)
|
|
||||||
SimulationPlayDuration int64 `json:"simulation_play_duration"` // 仿真播放时长(ms)
|
|
||||||
RandomPlayDuration int64 `json:"random_play_duration"` // 随机播放时长(ms)
|
|
||||||
}
|
|
||||||
|
|
||||||
type FeedVideo struct {
|
|
||||||
// 视频基础数据
|
|
||||||
VideoID string `json:"video_id"` // 视频 video ID
|
|
||||||
URL string `json:"url"` // 视频 url
|
|
||||||
UserName string `json:"user_name"` // 视频作者
|
|
||||||
Duration int64 `json:"duration"` // 视频时长(ms)
|
|
||||||
Caption string `json:"caption"` // 视频文案
|
|
||||||
Type string `json:"type"` // 视频类型
|
|
||||||
IsLivePreview bool `json:"is_live_preview"` // 是否直播预览流
|
|
||||||
|
|
||||||
// 视频热度数据
|
|
||||||
ViewCount int64 `json:"view_count"` // feed 观看数
|
|
||||||
LikeCount int64 `json:"like_count"` // feed 点赞数
|
|
||||||
CommentCount int64 `json:"comment_count"` // feed 评论数
|
|
||||||
CollectCount int64 `json:"collect_count"` // feed 收藏数
|
|
||||||
ForwardCount int64 `json:"forward_count"` // feed 转发数
|
|
||||||
ShareCount int64 `json:"share_count"` // feed 分享数
|
|
||||||
|
|
||||||
// 记录仿真决策信息
|
// 记录仿真决策信息
|
||||||
PlayDuration int64 `json:"play_duration"` // 播放时长(ms),取自 Simulation/Random
|
PlayDuration int64 `json:"play_duration"` // 播放时长(ms),取自 Simulation/Random
|
||||||
SimulationPlayProgress float64 `json:"simulation_play_progress"` // 仿真播放比例(完播率)
|
SimulationPlayProgress float64 `json:"simulation_play_progress"` // 仿真播放比例(完播率)
|
||||||
SimulationPlayDuration int64 `json:"simulation_play_duration"` // 仿真播放时长(ms)
|
SimulationPlayDuration int64 `json:"simulation_play_duration"` // 仿真播放时长(ms)
|
||||||
RandomPlayDuration int64 `json:"random_play_duration"` // 随机播放时长(ms)
|
RandomPlayDuration int64 `json:"random_play_duration"` // 随机播放时长(ms)
|
||||||
|
|
||||||
// timelines
|
|
||||||
PublishTimestamp int64 `json:"publish_timestamp"` // feed 发布时间戳
|
|
||||||
PreloadTimestamp int64 `json:"preload_timestamp"` // feed 预加载时间戳
|
|
||||||
}
|
|
||||||
|
|
||||||
type LiveRoom struct {
|
|
||||||
// 视频基础数据
|
|
||||||
LiveStreamID string `json:"live_stream_id"` // 直播流 ID
|
|
||||||
LiveStreamURL string `json:"live_stream_url"` // 直播流地址
|
|
||||||
UserName string `json:"user_name"` // 主播名称(无法获取?)
|
|
||||||
LiveType string `json:"live_type"` // 直播类型
|
|
||||||
|
|
||||||
// 视频热度数据
|
|
||||||
AudienceCount int64 `json:"audience_count"` // 直播间人数
|
|
||||||
|
|
||||||
// 网络数据
|
|
||||||
ThroughputKbps int64 `json:"throughput_kbps"` // 网速
|
|
||||||
|
|
||||||
// 记录仿真决策信息
|
|
||||||
WatchDuration int64 `json:"watch_duration"` // 观播时长(ms),取自 Simulation/Random
|
|
||||||
SimulationWatchDuration int64 `json:"simulation_watch_duration"` // 仿真观播时长(ms)
|
|
||||||
RandomWatchDuration int64 `json:"random_watch_duration"` // 随机观播时长(ms)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (vc *VideoCrawler) getCurrentVideo() (video *Video, err error) {
|
func (vc *VideoCrawler) getCurrentVideo() (video *Video, err error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user