优化播放

This commit is contained in:
truewhile
2026-09-30 11:20:27 +08:00
parent 8136e6ecb1
commit 1e6909ddbf
10 changed files with 244 additions and 37 deletions
+12
View File
@@ -12,6 +12,8 @@ import (
"net/url"
"strings"
"go.uber.org/zap"
"github.com/gin-gonic/gin"
"github.com/truewhile/MeBox/internal/middleware"
@@ -173,10 +175,20 @@ func externalPlaybackToken(c *gin.Context, svc *service.Container, mediaID strin
uid, _ := c.Get(middleware.CtxUserID)
u, err := svc.Repo.User.FindByID(c.Request.Context(), toString(uid))
if err != nil || u == nil {
if svc.Log != nil {
svc.Log.Warn("external playback token: user lookup failed",
zap.String("media_id", mediaID), zap.Error(err))
}
return ""
}
token, err := svc.Auth.IssueExternalPlaybackToken(u, mediaID, durationSec)
if err != nil {
// 静默返回空串会让 stream_url 变成 ?token=(空)、外部播放器只看到
// 401 无从排查,至少在服务端日志里留下原因。
if svc.Log != nil {
svc.Log.Warn("issue external playback token failed",
zap.String("media_id", mediaID), zap.Error(err))
}
return ""
}
return token