- 正文参数支持语义值(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 签名说明,示例更新
62 lines
1.9 KiB
Go
62 lines
1.9 KiB
Go
package fqapi
|
|
|
|
import (
|
|
"fanqie/internal/common"
|
|
"fmt"
|
|
)
|
|
|
|
var categoryLandingLogger = common.NewLogger("category_landing", "INFO", "")
|
|
|
|
// HandleCategoryLanding 处理获取分类详情,分类详情短缓存 10 分钟
|
|
func HandleCategoryLanding(categoryID, offset, wordNumber, bookStatus, sortBy interface{}) (string, error) {
|
|
return withCache(fmt.Sprintf("category_landing_%v_%v_%v_%v_%v", categoryID, offset, wordNumber, bookStatus, sortBy), 600, func() (string, error) {
|
|
return fetchCategoryLanding(categoryID, offset, wordNumber, bookStatus, sortBy)
|
|
})
|
|
}
|
|
|
|
func fetchCategoryLanding(categoryID, offset, wordNumber, bookStatus, sortBy interface{}) (string, error) {
|
|
// 参数转换
|
|
categoryIDInt := ParseIntParam(categoryID, 0)
|
|
offsetInt := ParseIntParam(offset, 0)
|
|
wordNumberInt := ParseIntParam(wordNumber, 0)
|
|
bookStatusInt := ParseIntParam(bookStatus, 0)
|
|
sortByInt := ParseIntParam(sortBy, 0)
|
|
|
|
if categoryIDInt == 0 {
|
|
return BuildErrorResponseWithCode(100144, "参数错误"), nil
|
|
}
|
|
|
|
reqURL := BuildURL(
|
|
"https://reading.snssdk.com/reading/bookapi/new_category/landing/v/",
|
|
fmt.Sprintf("category_id=%d", categoryIDInt),
|
|
fmt.Sprintf("limit=%d", 20),
|
|
fmt.Sprintf("offset=%d", offsetInt),
|
|
fmt.Sprintf("word_number=%d", wordNumberInt),
|
|
fmt.Sprintf("book_status=%d", bookStatusInt),
|
|
fmt.Sprintf("sort_by=%d", sortByInt),
|
|
)
|
|
|
|
resp, err := GorgonRequest(reqURL, map[string]interface{}{
|
|
"method": "GET",
|
|
"headers": map[string]string{
|
|
"User-Agent": "com.dragon.read",
|
|
},
|
|
})
|
|
|
|
if err != nil {
|
|
categoryLandingLogger.Error(fmt.Sprintf("获取分类详情失败: %v", err))
|
|
return BuildErrorResponse("请求失败"), err
|
|
}
|
|
|
|
respJSON, err := resp.JSON()
|
|
if err != nil {
|
|
return BuildErrorResponse("解析响应失败"), err
|
|
}
|
|
|
|
if code, ok := respJSON["code"].(float64); ok && code == 0 {
|
|
return reencodeUnwrapped(resp.Text), nil
|
|
}
|
|
|
|
return BuildErrorResponse("获取失败"), nil
|
|
}
|