package proto import ( "time" "videoweb/pub/common/netutil" "videoweb/pub/common/response" "videoweb/pub/models/videoinformationmod" "videoweb/pub/pubdef" ) // latestTime 返回两个时间中较大的那个 func latestTime(a, b time.Time) time.Time { if b.After(a) { return b } return a } type TagsInfoData struct { Id int64 `json:"id" ` Name string `json:"name"` // 帖子标题 Slug string `json:"slug"` // slug SeoInfo pubdef.SeoValue `json:"seoInfo" bson:"seoInfo"` // Seo相关信息 Works int64 `json:"works" bson:"works,omitempty"` // 作品数量 Images string `json:"images" bson:"images,omitempty"` // 背景 } type CollectionInfoData struct { Id int64 `json:"id" ` Name string `json:"name"` // 帖子标题 } type VideoType int64 const ( VideoTypeVideo VideoType = 0 // 视频 VideoTypeCollection VideoType = 1 // 合集 VideoTypeAdvitise VideoType = 2 // 广告 VideoType_AV VideoType = 3 // AV视频 ) type VideoInfoData struct { Id int64 `json:"id"` Type VideoType `json:"type"` // 类型 Title string `json:"title"` // 帖子标题 Slug string `json:"slug"` // slug Keyworld []string `json:"keyworld"` // 关键字 AddedTime time.Time `json:"addedTime"` // 帖子上架时间 CreateInfo PostCreateInfo `json:"createInfo"` // 作者信息 CoverImg string `json:"coverImg"` // 封面 // Nodes []videoinformationmod.Node `json:"nodes"` // 节点 Video videoinformationmod.VideoInfo `json:"video"` // 视频 Tags []TagsInfoData `json:"tags"` // 标签 IsHot bool `json:"isHot"` // 是否热门 AdvitiseId string `json:"advitiseId"` // 广告Id CollectionInfo []VideoInfoData `json:"collectionInfo"` // 合集数据 Link string `json:"link"` // 跳转链接 WatchTimes int64 `json:"watchTimes" bson:"watchTimes"` // 观看次数 LikeNum int64 `json:"likeNum,omitempty"` // 点赞展示数 CountCollect int64 `json:"countCollect,omitempty"` // 收藏展示数 ShowTimes int64 `json:"showTimes" bson:"showTimes"` // 展示次数 Location int64 `json:"location" bson:"location"` // 广告位置id ActressInfo []ActressInfoData `json:"actressInfo" bson:"actressInfo"` // 女优信息 IssuedAt time.Time `json:"issuedAt" bson:"issuedAt"` // 发行时间 IssuedBrand string `json:"issuedBrand" bson:"issuedBrand"` // 发行商 Desc string `bson:"desc,omitempty" json:"desc"` // 详细描述 Bango string `bson:"bango,omitempty" json:"bango"` // 番号,唯一 UpdatedAt time.Time `json:"updatedAt"` // 页面更新时间 PreviewVtt string `json:"previewVtt,omitempty"` // 雪碧图 vtt } // 面包屑 type BreadcrumbItem struct { Name string `json:"name"` // 名称 Url string `json:"url"` // 跳转链接 } // 详情页导航 type DetailNavItem struct { Name string `json:"name"` // 导航名称 Url string `json:"url"` // 导航链接 } type VideoHistoryInfo struct { Id int64 `json:"id"` Title string `json:"title"` // 帖子标题 AddedTime time.Time `json:"addedTime"` // 上架时间 } type VideoCategoryInfo struct { Id int64 `json:"id" ` Name string `json:"name"` Slug string `json:"slug"` // slug SeoInfo pubdef.SeoValue `json:"seoInfo" bson:"seoInfo"` // Seo相关信息 Title string `json:"title" bson:"title"` // APP显示 Desc string `json:"desc" bson:"desc"` // 描述 } // VideoCategoryListResp 已启用视频分类列表响应 type VideoCategoryListResp struct { List []VideoCategoryListItem `json:"list"` // 全部已启用视频分类 } // VideoCategoryListItem 视频分类列表项 type VideoCategoryListItem struct { Id int64 `json:"id"` // 分类ID Name string `json:"name"` // 分类名称 Slug string `json:"slug"` // 分类slug Title string `json:"title"` // APP展示标题 Desc string `json:"desc"` // 分类描述 Rank int64 `json:"rank"` // 排序值,越大越靠前 SeoInfo pubdef.SeoValue `json:"seoInfo"` // SEO信息 } type VideoPlayReq struct { VideoId int64 `json:"videoId" form:"videoId"` // 视频ID } type VideoPlayResp struct { AuthKey string `json:"authKey"` } type VideoCreaterInfo struct { Id int64 `json:"id" ` Name string `json:"name"` Slug string `json:"slug"` // slug SeoInfo pubdef.SeoValue `json:"seoInfo" bson:"seoInfo"` // Seo相关信息 } // QueryVideoReq 根据分类id查询视频列表请求 type QueryVideoReq struct { pubdef.Page // 视频分类id CategoryId int64 `json:"categoryId" form:"categoryId"` // 分类slug,非空时优先按slug解析分类ID CategorySlug string `json:"categorySlug" form:"categorySlug"` } // QueryVideoItemType 视频更多列表项类型 type QueryVideoItemType int64 const ( // QueryVideoItemTypeVideo 表示视频数据 QueryVideoItemTypeVideo QueryVideoItemType = 0 // QueryVideoItemTypeAdvertise 表示广告数据 QueryVideoItemTypeAdvertise QueryVideoItemType = 2 ) // QueryVideoResp 视频更多分页响应 type QueryVideoResp struct { response.BasePageResp // 当前分类信息(含 SEO) CategoryInfo VideoCategoryInfo `json:"categoryInfo"` // 导航 Translations AppTranslationInfo `json:"translations"` // 底部翻译 BottonTranslations AppTranslationInfo `json:"bottonTranslations"` } // QueryVideoListItem 视频更多列表项,type=0时返回视频信息,type=2时返回广告信息。 type QueryVideoListItem struct { // 数据类型:0-视频数据、2-广告 Type QueryVideoItemType `json:"type"` // 广告ID,type=2时返回 AdvertiseId string `json:"advertiseId"` // 广告跳转链接,type=2时返回 Link string `json:"link"` // 广告位置ID,type=2时返回 Location int64 `json:"location"` VideoInfo } // VideoRecommendListReq 推荐视频分页请求 type VideoRecommendListReq struct { pubdef.Page // 分类id,不传查询全部分类id CategoryId int64 `form:"categoryId" json:"categoryId"` // 分类slug,非空时优先按slug解析分类ID CategorySlug string `form:"categorySlug" json:"categorySlug"` // 标签ID,不传查询全部标签 TagId int64 `form:"tagId" json:"tagId"` // 标签slug,非空时优先按slug解析标签ID TagSlug string `form:"tagSlug" json:"tagSlug"` // 排序方式 1-推荐 2-最新 3-最热 SortList int64 `form:"sortList" json:"sortList"` } // VideoListReq 上架视频分页请求 type VideoListReq struct { pubdef.Page CategoryId int64 `form:"categoryId" json:"categoryId"` // 视频分类 ID,不传查询全部分类 SortType int64 `form:"sortType" json:"sortType"` // 排序方式,1 热度优先,2 最近更新,默认 1 } // VideoListResp 视频与广告混排分页响应 type VideoListResp struct { response.BasePageResp Advitise AdvitiseData `json:"advitise"` // 完整广告配置 } // VideoRecommendSort 推荐视频排序方式 type VideoRecommendSort int64 const ( VideoRecommendSortRecommend VideoRecommendSort = 1 // 推荐 后台配置 isRecommend=true VideoRecommendSortNewest VideoRecommendSort = 2 // 最新 按视频最后更新时间从近到远排序 VideoRecommendSortHot VideoRecommendSort = 3 // 最热 按视频累计播放量从高到低排序 ) // VideoRecommendItemType 推荐视频列表项类型 type VideoRecommendItemType int64 const ( VideoRecommendItemTypeVideo VideoRecommendItemType = 0 // 视频数据 VideoRecommendItemTypeAdvertise VideoRecommendItemType = 2 // 广告数据 ) // VideoRecommendListResp 推荐视频分页响应 type VideoRecommendListResp struct { response.BasePageResp } // VideoGuessListReq 猜你喜欢视频分页请求 type VideoGuessListReq struct { pubdef.Page Id int64 `form:"id" json:"id"` // 当前视频ID,可选,传入时排除该视频 } // VideoGuessListResp 猜你喜欢视频分页响应 type VideoGuessListResp struct { response.BasePageResp } // VideoRecommendListItem 推荐视频列表项 type VideoRecommendListItem struct { Type VideoRecommendItemType `json:"type"` // 数据类型 0-视频数据 2-广告 AdvertiseId string `json:"advertiseId"` // 广告ID,type=2时返回 Link string `json:"link"` // 广告跳转链接,type=2时返回 Location int64 `json:"location"` // 广告位置ID,type=2时返回 VideoInfo } // FavoriteVideoReq 收藏或取消收藏视频请求 type FavoriteVideoReq struct { // ID Id int64 `json:"id" binding:"required"` // 是否收藏,true-收藏、false-取消收藏 IsFavorite *bool `json:"isFavorite" binding:"required"` } // FavoriteVideoResp 收藏或取消收藏视频响应 type FavoriteVideoResp struct { // ID Id int64 `json:"id"` // 是否收藏,true-收藏、false-取消收藏 IsFavorite bool `json:"isFavorite"` } // LikeVideoReq 点赞或取消点赞视频请求 type LikeVideoReq struct { // ID Id int64 `json:"id" binding:"required"` // 是否点赞,true-点赞、false-取消点赞 IsLike *bool `json:"isLike" binding:"required"` } // LikeVideoResp 点赞或取消点赞视频响应 type LikeVideoResp struct { // ID Id int64 `json:"id"` // 是否点赞,true-点赞、false-取消点赞 IsLike bool `json:"isLike"` // 点赞展示数 LikeNum int64 `json:"likeNum"` } // QueryLikeVideoListReq 当前用户点赞视频分页请求 type QueryLikeVideoListReq struct { pubdef.Page } // QueryLikeVideoListResp 当前用户点赞视频分页响应 type QueryLikeVideoListResp struct { response.BasePageResp Translations AppTranslationInfo `json:"translations"` // 导航 BottonTranslations AppTranslationInfo `json:"bottonTranslations"` // 底部翻译 } // VideoHistoryListReq 当前用户视频观看历史分页请求 type VideoHistoryListReq struct { pubdef.Page } // VideoHistoryReportReq 播放成功后上报视频观看历史 type VideoHistoryReportReq struct { Id int64 `json:"id" binding:"required,gt=0"` // 视频 ID } // VideoHistoryReportResp 视频观看历史上报响应 type VideoHistoryReportResp struct { WatchedAt time.Time `json:"watchedAt"` // 最近观看时间 } // VideoHistoryListResp 当前用户视频观看历史分页响应 type VideoHistoryListResp struct { response.BasePageResp Translations AppTranslationInfo `json:"translations"` // 导航 BottonTranslations AppTranslationInfo `json:"bottonTranslations"` // 底部翻译 } // VideoHistoryItem 视频观看历史卡片 type VideoHistoryItem struct { FavoriteVideoListItem Desc string `json:"desc"` // 视频简介 WatchedAt time.Time `json:"watchedAt"` // 最近观看时间 } // VideoHistoryClearResp 清空视频观看历史响应 type VideoHistoryClearResp struct { DeletedCount int64 `json:"deletedCount"` // 删除记录数 } // QueryFavoriteVideoListReq 当前登录用户收藏视频分页请求 type QueryFavoriteVideoListReq struct { pubdef.Page } // QueryFavoriteVideoListResp 当前登录用户收藏视频分页响应 type QueryFavoriteVideoListResp struct { response.BasePageResp // 导航 Translations AppTranslationInfo `json:"translations"` // 底部翻译 BottonTranslations AppTranslationInfo `json:"bottonTranslations"` } // FavoriteVideoListItem 当前登录用户收藏视频列表项 type FavoriteVideoListItem struct { // id Id int64 `json:"id"` // 标题 Title string `json:"title"` // slug Slug string `json:"slug"` // 上架时间 AddedTime time.Time `json:"addedTime"` // 封面 CoverImg string `json:"coverImg"` // 标签id Tags []int64 `json:"tags"` // 标签名称 TagsName []string `json:"tagsName"` // 标签slug 与tagsName顺序一致 TagSlugs []string `json:"tagSlugs"` // 观看展示数 WatchNum int64 `json:"watchNum"` // 点赞展示数 LikeNum int64 `json:"likeNum"` // 收藏展示数 CountCollect int64 `json:"countCollect"` } // VideoRankReq 视频排行榜分页请求 type VideoRankReq struct { pubdef.Page // 榜单类型 0-点赞榜 1-周榜 2-月榜 3-年榜 RankPeriod int64 `json:"rankPeriod" form:"rankPeriod"` } // VideoRankPeriod 视频排行榜类型 type VideoRankPeriod int64 const ( VideoRankPeriodLike VideoRankPeriod = 0 // 点赞榜,按累计点赞量降序,最多50条,不足随机补位 VideoRankPeriodWeek VideoRankPeriod = 1 // 周榜,按本周观看量降序,最多50条,不足随机补位 VideoRankPeriodMonth VideoRankPeriod = 2 // 月榜,按本月观看量降序,最多50条,不足随机补位 VideoRankPeriodYear VideoRankPeriod = 3 // 年榜,按本年观看量降序,最多50条,不足随机补位 ) // VideoRankResp 视频排行榜分页响应 type VideoRankResp struct { response.BasePageResp // 导航 Translations AppTranslationInfo `json:"translations"` // 底部翻译 BottonTranslations AppTranslationInfo `json:"bottonTranslations"` } // QueryVideoInfoReq 视频详情请求 type QueryVideoInfoReq struct { Id int64 `json:"id" form:"id"` // 视频slug,非空时优先按slug解析视频ID Slug string `json:"slug" form:"slug"` } // QueryVideoInfoResp 视频详情响应 type QueryVideoInfoResp struct { // 当前路径 Path string `json:"path"` // 导航 Translations AppTranslationInfo `json:"translations"` // 配置信息 Config ConfigInfo `json:"config"` // 底部翻译 BottonTranslations AppTranslationInfo `json:"bottonTranslations"` // 广告 Advitise AdvitiseData `json:"advitise"` // 公告 Announcement AnnouncementInfo `json:"announcement"` // 视频详情数据 VideoInfo VideoDetailInfo `json:"videoInfo"` // 当前登录用户是否已收藏该视频 IsFavorite bool `json:"isFavorite"` // 当前登录用户是否已点赞该视频 IsLike bool `json:"isLike"` } // VideoDetailInfo 视频详情数据 type VideoDetailInfo struct { // id Id int64 `json:"id"` // 标题 Title string `json:"title"` // slug Slug string `json:"slug"` // 封面 CoverImg string `json:"coverImg"` // 视频播放信息 Video videoinformationmod.VideoInfo `json:"video"` // 标签 Tags []TagsInfoData `json:"tags"` // 观看展示数 WatchNum int64 `json:"watchNum"` // 点赞展示数 LikeNum int64 `json:"likeNum"` // 收藏展示数 CountCollect int64 `json:"countCollect"` // 上架时间 AddedTime time.Time `json:"addedTime"` // 作品简介 Desc string `json:"desc"` // 当前登录用户是否已收藏该视频 IsFavorite bool `json:"isFavorite"` // 当前登录用户是否已点赞该视频 IsLike bool `json:"isLike"` } func VideoInfoToData(videoInfo *videoinformationmod.VideoInformation, imgCdn string, creatorInfo PostCreateInfo) VideoInfoData { t := VideoTypeVideo switch videoInfo.MediaType { case videoinformationmod.MediaType_Video: t = VideoTypeVideo case videoinformationmod.MediaType_Collection: t = VideoTypeCollection case videoinformationmod.MediaType_Advitise: t = VideoTypeAdvitise case videoinformationmod.MediaType_AV: t = VideoType_AV } videotemp := VideoInfoData{ Id: videoInfo.Id, Type: t, Title: videoInfo.Title, Slug: videoInfo.Slug, Keyworld: videoInfo.Keyworld, AddedTime: videoInfo.AddedTime, CreateInfo: creatorInfo, CoverImg: netutil.MergeURL(imgCdn, videoInfo.CoverImg), // Nodes: make([]videoinformationmod.Node, 0), Video: videoInfo.Video, IsHot: videoInfo.IsHot, Tags: make([]TagsInfoData, 0), ShowTimes: videoInfo.Real.ShowTimes*100 + 6241, WatchTimes: videoInfo.Real.WatchTimes*100 + 3152, ActressInfo: make([]ActressInfoData, 0), Desc: videoInfo.Desc, Bango: videoInfo.Bango, IssuedBrand: videoInfo.IssuedBrand, IssuedAt: videoInfo.IssuedAt, UpdatedAt: latestTime(videoInfo.UpdatedAt, videoInfo.PageUpdatedAt), PreviewVtt: videoInfo.PreviewVtt, } if videoInfo.Video.Cover != "" { videotemp.Video.Cover = netutil.MergeURL(imgCdn, videotemp.Video.Cover) } //for _, nodeInfo := range videoInfo.Nodes { // nodeTmp := videoinformationmod.Node{ // Images: make([]string, 0), // Url: nodeInfo.Url, // Text: nodeInfo.Text, // Videos: make([]videoinformationmod.VideoInfo, 0), // Title: nodeInfo.Title, // } // for _, image := range nodeInfo.Images { // nodeTmp.Images = append(nodeTmp.Images, netutil.MergeURL(imgCdn, image)) // } // if nodeInfo.Videos != nil && len(nodeInfo.Videos) > 0 { // for _, video := range nodeInfo.Videos { // videoTmp := videoinformationmod.VideoInfo{ // TaskId: video.TaskId, // FileId: video.FileId, // Url: netutil.MergeURL(imgCdn, video.Url), // Cover: video.Cover, // Height: video.Height, // Width: video.Width, // VideoTime: video.VideoTime, // PreMp4FileNameFs: video.PreMp4FileNameFs, // } // nodeTmp.Videos = append(nodeTmp.Videos, videoTmp) // } // } // videotemp. = append(videotemp.Nodes, nodeTmp) //} return videotemp } // StripH265Url 清空主视频 H265 地址。 func StripH265Url(data *VideoInfoData) { if data == nil { return } data.Video.H265Url = "" }