feat: 完成短剧项目空间与结构化资产创作闭环 (#38)
* feat(canvas): 短剧项目空间 - 建立项目章节与画布关联 MVP * feat(canvas): 短剧项目空间 - 完善项目资产、镜头与流程闭环 Refs #30 * fix(deploy): 本地部署 - 修复前端构建并忽略本地 PostgreSQL 配置 * feat(*): 短剧项目空间 - 完成项目、章节、资产、角色与画布创作闭环 Refs #30 --------- Co-authored-by: ddCat <ddcat666@88.com>
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"mime"
|
||||
"mime/multipart"
|
||||
@@ -11,6 +12,7 @@ import (
|
||||
"net/url"
|
||||
"path"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -221,3 +223,35 @@ func proxyRequestModel(contentType string, body []byte) string {
|
||||
modelName, _ := payload["model"].(string)
|
||||
return strings.TrimSpace(modelName)
|
||||
}
|
||||
|
||||
func proxyRequestVideoSeconds(contentType string, body []byte) int64 {
|
||||
mediaType, params, _ := mime.ParseMediaType(contentType)
|
||||
if strings.HasPrefix(mediaType, "multipart/") {
|
||||
reader := multipart.NewReader(bytes.NewReader(body), params["boundary"])
|
||||
for {
|
||||
part, err := reader.NextPart()
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
if part.FormName() == "seconds" || part.FormName() == "duration" {
|
||||
value, _ := io.ReadAll(io.LimitReader(part, 32))
|
||||
seconds, _ := strconv.ParseInt(strings.TrimSpace(string(value)), 10, 64)
|
||||
return seconds
|
||||
}
|
||||
_ = part.Close()
|
||||
}
|
||||
}
|
||||
var payload map[string]any
|
||||
if json.Unmarshal(body, &payload) != nil {
|
||||
return 0
|
||||
}
|
||||
for _, key := range []string{"seconds", "duration"} {
|
||||
value, exists := payload[key]
|
||||
if !exists {
|
||||
continue
|
||||
}
|
||||
seconds, _ := strconv.ParseInt(strings.TrimSpace(fmt.Sprint(value)), 10, 64)
|
||||
return seconds
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user