@@ -0,0 +1,60 @@
|
||||
package videoser
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"videoweb/app/api/proto"
|
||||
"videoweb/app/service/configser"
|
||||
"videoweb/pub/models/videoinformationmod"
|
||||
)
|
||||
|
||||
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