✨ 初始提交:月读第三方书源插件集合

每个书源一个独立插件目录,含微信读书公众号订阅、书架导入等完整功能。

Co-authored-by: Copilot <[email protected]>
This commit is contained in:
GarfieldandCopilot committed 2026-11-16 12:08:03 +08:00
commit 9190db9019
38 files changed
+5783

No files matched your search

@@ -0,0 +1,42 @@
--[[--
番茄网页榜单:解析榜单页内嵌的 __INITIAL_STATE__。书名 / 简介是 PUA 混淆字体,解码表同正文。
@module koplugin.book.moonsource_fanqie.rank
--]]
local Content = require("moonsource_fanqie.content")
local FanQie = require("moonsource_fanqie.fanqie")
local JSON = require("json")
local Rank = {}
--- 榜单页 HTML → 榜单状态(book_list、rankCategoryTypeList)。脚本是 `(function(){ window.__INITIAL_STATE__={...}; })()`,
--- 里面有裸 `undefined`,不是合法 JSON。
---@param html string
---@return table|nil rank
function Rank.state(html)
local script = html:match("__INITIAL_STATE__=(.-)</script>")
local body = script and script:gsub("([:,%[])undefined", "%1null"):match("^(.*})%s*;%s*}%s*%)%s*%(%s*%)%s*$")
local ok, state = pcall(JSON.decode, body or "")
return ok and type(state) == "table" and state.rank or nil
end
---@param rank table Rank.state 的结果
---@param source_id string
---@return Book[]
function Rank.books(rank, source_id)
local books = {}
for _idx, row in ipairs(rank.book_list or {}) do
books[#books + 1] = {
source_id = source_id,
stable_id = tostring(row.bookId),
title = Content.decode_pua_content(row.bookName),
authors = row.author or "",
intro = Content.decode_pua_content(row.abstract),
cover = FanQie.mobileCover(row.thumbUri),
}
end
return books
end
return Rank