✨ feat(api): 统一响应格式并完善参数体系与文档
- 正文参数支持语义值(plain/html/keep/remove)与别名(img_mode/review_mode),URL 参数优先于配置 - 修复纯文本被段评强制包回 HTML、HTML 模式段评注入失效的问题 - 修复 PKCS7 填充弱校验导致漫画/正文偶发解密乱码返回 200 的问题 - 搜索结果展平:去 search_tabs 层与 selected_tab_idx/server_ab_params,提升 has_more/next_offset - 全接口解包字符串形式的 JSON 字段(category_schema 等),缓存出口幂等处理 - 序列化关闭 HTML 转义,video/audio 播放链接可直接复制播放 - video 响应透传 CENC 加密状态(key_seed/kid/encryption_method) - 新增 gzip 中间件,JSON/文本响应压缩约 81%,二进制透传 - 漫画默认输出模式改为 proxy(url 模式链接 404 且内容加密不可用) - openapi.yaml:补全 23 个路径参数定义、tab_type 完整枚举、CDN 签名说明,示例更新
This commit is contained in:
1 parent
bfb4290c15
commit
1a4997e031
25 files changed
+489
-199
No files matched your search
+19
-4
@@ -95,8 +95,7 @@ func HandleVideo(itemIDs interface{}) (string, error) {
|
||||
"data": decodedModel,
|
||||
}
|
||||
|
||||
resultBytes, _ := json.Marshal(response)
|
||||
return string(resultBytes), nil
|
||||
return marshalNoEscape(response), nil
|
||||
} else {
|
||||
// 批量接口:data 是一个map,key是ID,value包含video_model
|
||||
result := make(map[string]interface{})
|
||||
@@ -119,8 +118,7 @@ func HandleVideo(itemIDs interface{}) (string, error) {
|
||||
"data": result,
|
||||
}
|
||||
|
||||
resultBytes, _ := json.Marshal(response)
|
||||
return string(resultBytes), nil
|
||||
return marshalNoEscape(response), nil
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -144,6 +142,10 @@ func decodeVideoModelAsJSON(videoModelStr string) interface{} {
|
||||
// 解析失败,返回空对象
|
||||
return map[string]interface{}{}
|
||||
}
|
||||
// 解包嵌套的 JSON 字符串字段(category_schema、recommend_info 等)
|
||||
if unwrapped, ok := UnwrapJSONStrings(videoModel).(map[string]interface{}); ok {
|
||||
videoModel = unwrapped
|
||||
}
|
||||
|
||||
// 构建精简的返回结果,只包含关键字段
|
||||
result := make(map[string]interface{})
|
||||
@@ -158,6 +160,10 @@ func decodeVideoModelAsJSON(videoModelStr string) interface{} {
|
||||
if posterURL, ok := videoModel["poster_url"].(string); ok {
|
||||
result["poster_url"] = posterURL
|
||||
}
|
||||
// 加密信息:视频为 CENC 加密(encrypt=true),解密需要 key_seed/kid
|
||||
if keySeed, ok := videoModel["key_seed"].(string); ok {
|
||||
result["key_seed"] = keySeed
|
||||
}
|
||||
|
||||
// 处理 video_list
|
||||
if videoList, ok := videoModel["video_list"].(map[string]interface{}); ok {
|
||||
@@ -189,6 +195,15 @@ func decodeVideoModelAsJSON(videoModelStr string) interface{} {
|
||||
if fps, ok := qualityMap["fps"].(float64); ok {
|
||||
qualityInfo["fps"] = int(fps)
|
||||
}
|
||||
if encrypt, ok := qualityMap["encrypt"].(bool); ok && encrypt {
|
||||
qualityInfo["encrypt"] = true
|
||||
if em, ok := qualityMap["encryption_method"].(string); ok {
|
||||
qualityInfo["encryption_method"] = em
|
||||
}
|
||||
if kid, ok := qualityMap["kid"].(string); ok {
|
||||
qualityInfo["kid"] = kid
|
||||
}
|
||||
}
|
||||
|
||||
// 解码 main_url
|
||||
if mainURL, ok := qualityMap["main_url"].(string); ok {
|
||||
|
||||
Reference in new issue
Block a user