Initial commit

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
谢宇宁
2026-10-22 14:47:17 +07:00
co-authored by Claude Opus 5.5
commit 3639d2184a
574 changed files with 61690 additions and 0 deletions
+70
View File
@@ -0,0 +1,70 @@
package web
import (
"strings"
"videoweb/app/service/playletser"
"github.com/gin-gonic/gin"
)
// Play 播放页 SSR:GET /api/app/playlet/chapter/detail;seoInfo 直接注入模板。
func Play(c *gin.Context) {
playletKey := strings.TrimSpace(c.Param("slug"))
requestedChapterID := strings.TrimSpace(c.Param("chapterId"))
if playletKey == "" {
NotFound(c, "未找到可播放内容")
return
}
if requestedChapterID != "" && playletser.ParseDetailID(requestedChapterID) <= 0 {
NotFound(c, "未找到该剧集")
return
}
playlet := playletser.FetchDetailOrNilByKey(c, playletKey)
if playlet == nil {
NotFound(c, "未找到可播放内容")
return
}
q := playletser.ParsePlayQuery(playletKey, c.Param("chapterId"))
q.PlayletID = playlet.ID
q.PlayletSlug = playlet.Slug
q.ChapterID = playletser.ResolvePlayChapterID(playlet, q.ChapterID)
if q.ChapterID <= 0 {
NotFound(c, "未找到可播放内容")
return
}
target := playletser.PlayPath(q.PlayletSlug, q.PlayletID)
if q.ChapterID > 0 {
target = playletser.ChapterPlayPath(q.PlayletSlug, q.PlayletID, q.ChapterID)
}
if redirectCanonical(c, target) {
return
}
chapter := playletser.FetchChapterDetailOrNil(c, q.ChapterID, q.PlayletID, q.PlayletSlug)
if chapter == nil {
NotFound(c, "未找到该剧集")
return
}
var episodeRanges []playletser.EpisodeRange
var chapters []playletser.PlayletChapterData
playletID := playlet.ID
playletSlug := playlet.Slug
chapters = playlet.PlayletChapterInfo
episodeRanges = playletser.BuildEpisodeRanges(chapters, playlet.TotalEpisode, 30)
seoInfo := playletser.ResolvePlayPageSEO(chapter, playlet)
data := gin.H{
"title": playletser.ResolvePlayPageTitle(chapter, playlet),
"chapter": chapter,
"playlet": playlet,
"playletID": playletID,
"playletSlug": playletSlug,
"seoInfo": seoInfo,
"chapters": chapters,
"episodeRanges": episodeRanges,
}
HTMLOK(c, "play.html", data)
}