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

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

Co-authored-by: Copilot <[email protected]>
This commit is contained in:
GarfieldandCopilot committed 2026-11-16 12:08:03 +08:00
commit 0956063d06
44 files changed
+21495

No files matched your search

+39
View File
@@ -0,0 +1,39 @@
--[[-- 起点升级离线缓存不删章节,启用章评时原地追加入口。 @module tests.moonsource_qidian.cache_spec --]]
local Assert = require("support.assert")
local Config = require("support.config")
Config.setupNativePath()
local lfs = require("libs/libkoreader-lfs")
local Paths = require("utils.paths")
local source = require("moonsource_qidian.source").new()
local dir = Config.dir() .. "/qidian-cache-preserve"
lfs.mkdir(dir)
local path = dir .. "/1.html"
local file = assert(io.open(path, "wb"))
file:write("<html><body><p>离线可读正文</p></body></html>")
file:close()
local work_dir = Paths.bookWorkDir
Paths.bookWorkDir = function() return dir end
source.paragraphReviewsEnabled = function() return true end
package.loaded["source.chapter"] = nil
package.preload["source.chapter"] = function()
return {
vipFetcher = function() return function() error("缓存命中不应拉正文") end end,
openAsync = function(_source, _identity, _book, _opts, ops, cb)
Assert.is_true(ops.reuse(path))
cb(path)
return { cancel = function() end }
end,
}
end
local opened
source:openBookAsync({ source_id = "ext.qidian", stable_id = "fixture" }, { chapter_idx = 1 },
function(value) opened = value end)
Assert.eq(opened, path)
file = assert(io.open(path, "rb"))
local html = file:read("*a")
file:close()
Assert.matches(html, "<p>离线可读正文</p>")
Assert.matches(html, 'id="moon%-chapter%-reviews"')
Paths.bookWorkDir = work_dir
os.remove(path)
lfs.rmdir(dir)