feat: 从黄果 NET hgdjnet-server 9bfbafe 导入 HKDJ 官网后端
来源:hgdjnet-server 9bfbafe10d417deea959bd53117bc88a10e60a83 项目身份 HKDJ / JHA-216,独立官网仓库,Jenkins 守卫键 hkdjnet 测试目录 /server/hkdj_net,App/Web API 30331/30332 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
package videoser
|
||||
|
||||
import (
|
||||
"hkdj-web-server/app/api/proto"
|
||||
"hkdj-web-server/app/service/configser"
|
||||
"hkdj-web-server/pub/models/videoinformationmod"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func toVideoInfoData(videoInfo *videoinformationmod.VideoInformation, imgCdn string) proto.VideoInfoData {
|
||||
data := proto.VideoInfoToData(videoInfo, imgCdn)
|
||||
normalizeVideoInfoH265Paths(&data)
|
||||
configser.ApplyVideoH265Policy(&data)
|
||||
return data
|
||||
}
|
||||
|
||||
func applyVideoUrlAuth(resp *proto.VideoInfoData, videoId int64, ip, ua string, userId int64) {
|
||||
normalizeVideoInfoH265Paths(resp)
|
||||
configser.ApplyVideoH265Policy(resp)
|
||||
|
||||
if len(resp.Video.Url) > 0 {
|
||||
resp.Video.Url = GetM3U8AuthParam(videoId, resp.Video.Url, ip, ua, userId)
|
||||
}
|
||||
if len(resp.Video.H265Url) > 0 {
|
||||
resp.Video.H265Url = GetM3U8AuthParam(videoId, resp.Video.H265Url, ip, ua, userId)
|
||||
}
|
||||
for i, node := range resp.Nodes {
|
||||
for j, video := range node.Videos {
|
||||
if len(video.Url) > 0 {
|
||||
video.Url = GetM3U8AuthParam(videoId, video.Url, ip, ua, userId)
|
||||
}
|
||||
if len(video.H265Url) > 0 {
|
||||
video.H265Url = GetM3U8AuthParam(videoId, video.H265Url, ip, ua, userId)
|
||||
}
|
||||
node.Videos[j] = video
|
||||
}
|
||||
resp.Nodes[i] = node
|
||||
}
|
||||
}
|
||||
|
||||
func normalizeVideoInfoH265Paths(data *proto.VideoInfoData) {
|
||||
if data == nil {
|
||||
return
|
||||
}
|
||||
data.Video.H265Url = normalizeLaosijiHEVCPath(data.Video.H265Url)
|
||||
for i := range data.Nodes {
|
||||
for j := range data.Nodes[i].Videos {
|
||||
data.Nodes[i].Videos[j].H265Url = normalizeLaosijiHEVCPath(data.Nodes[i].Videos[j].H265Url)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func normalizeLaosijiHEVCPath(path string) string {
|
||||
path = strings.TrimSpace(path)
|
||||
path = strings.TrimPrefix(path, "laosiji/m3m/")
|
||||
if path != "" && !strings.HasPrefix(path, "laosiji/") {
|
||||
return "laosiji/" + path
|
||||
}
|
||||
return path
|
||||
}
|
||||
Reference in New Issue
Block a user