🔧 chore: 初始化番茄小说 API 项目结构
新增项目基础框架,包含核心 API 实现、算法模块、HTTP 处理器等完整功能模块
This commit is contained in:
commit
6981148727
107 files changed
+12463
No files matched your search
@@ -0,0 +1,45 @@
|
||||
package fqapi
|
||||
|
||||
import (
|
||||
"fanqie/internal/common"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
var itemSummaryLogger = common.NewLogger("item_summary", "INFO", "")
|
||||
|
||||
// HandleItemSummary 处理获取章节摘要
|
||||
func HandleItemSummary(itemIDs, bookID string) (string, error) {
|
||||
if itemIDs == "" || bookID == "" {
|
||||
return BuildErrorResponseWithCode(100144, "参数错误"), nil
|
||||
}
|
||||
|
||||
reqURL := BuildURL(
|
||||
"https://reading.snssdk.com/reading/reader/item_summary/mget/v",
|
||||
"book_id="+bookID,
|
||||
"item_ids="+itemIDs,
|
||||
)
|
||||
|
||||
resp, err := GorgonRequest(reqURL, map[string]interface{}{
|
||||
"method": "GET",
|
||||
"headers": map[string]string{
|
||||
"User-Agent": "com.dragon.read",
|
||||
},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
itemSummaryLogger.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 resp.Text, nil
|
||||
}
|
||||
|
||||
return BuildErrorResponse("获取失败"), nil
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user