This commit is contained in:
commit
994167fbe5
50 files changed
+18324
No files matched your search
@@ -0,0 +1,211 @@
|
||||
--[[--
|
||||
extensions/moonsource-kavita.koplugin:注解线上形态(写入 / 读回)与同一性键。
|
||||
|
||||
备注在 Kavita 侧是 Quill Delta JSON(`comment`)+ Quill HTML(`commentHtml`),
|
||||
纯文本 `commentPlainText` 由后端从 HTML 去标签算出来。拉取、推送、冲突判定必须
|
||||
共用这一套归一,否则同一段备注每次都会判「改过」→ 无限 update。
|
||||
|
||||
@module tests.moonsource_kavita.annotation_spec
|
||||
--]]
|
||||
---@diagnostic disable: undefined-field, missing-fields, inject-field
|
||||
|
||||
local Assert = require("support.assert")
|
||||
local Config = require("support.config")
|
||||
local JsonStub = require("support.json_stub")
|
||||
|
||||
-- 模块内部 require("json");这里给真实语义的往返桩(encode 出的串 decode 得回同一结构)。
|
||||
package.loaded["json"] = { encode = JsonStub.encode, decode = JsonStub.decode }
|
||||
|
||||
local Annotation = dofile((debug.getinfo(1, "S").source:match("^@(.-)/tests/") .. "/moonsource-kavita.koplugin/moonsource_kavita") .. "/annotation.lua")
|
||||
|
||||
-- 读回:空值集合一律空串(漏判的后果不是显示花括号,而是 note 变成 "{}" → 无限 update)。
|
||||
Assert.eq(Annotation.noteText(nil), "")
|
||||
Assert.eq(Annotation.noteText(""), "")
|
||||
Assert.eq(Annotation.noteText(" "), "")
|
||||
Assert.eq(Annotation.noteText("{}"), "")
|
||||
Assert.eq(Annotation.noteText('{"ops":[]}'), "")
|
||||
Assert.eq(Annotation.noteText('{"ops":[{"insert":"\\n"}]}'), "")
|
||||
Assert.eq(Annotation.noteText('{"ops":[{"insert":" \\n"}]}'), "", "只含空白 insert 也是空")
|
||||
Assert.eq(Annotation.noteText("null"), "")
|
||||
|
||||
-- Delta:拼接字符串 insert,跳过 embed,忽略 attributes,剥掉末尾换行。
|
||||
Assert.eq(Annotation.noteText('{"ops":[{"insert":"一句话\\n"}]}'), "一句话")
|
||||
Assert.eq(
|
||||
Annotation.noteText('{"ops":[{"insert":"第一行\\n"},{"insert":"第二行","attributes":{"bold":true}},{"insert":"\\n"}]}'),
|
||||
"第一行\n第二行"
|
||||
)
|
||||
Assert.eq(
|
||||
Annotation.noteText('{"ops":[{"insert":"有图\\n"},{"insert":{"image":"x.png"}},{"insert":"\\n"}]}'),
|
||||
"有图",
|
||||
"非字符串 insert(图片等 embed)跳过"
|
||||
)
|
||||
Assert.eq(Annotation.noteText('{"ops":[{"insert":"a\\nb\\n"}]}'), "a\nb", "文内换行原样保留")
|
||||
|
||||
-- 非 JSON 的 legacy 纯文本:原样返回(不能当空,也不能当 Delta 报错)。
|
||||
Assert.eq(Annotation.noteText("存量纯文本备注"), "存量纯文本备注")
|
||||
|
||||
-- 优先级:commentHtml → commentPlainText → 解析 comment。
|
||||
Assert.eq(Annotation.noteText('{"ops":[{"insert":"delta\\n"}]}', "<p>html</p>", "plain"), "html")
|
||||
Assert.eq(Annotation.noteText('{"ops":[{"insert":"delta\\n"}]}', "", "plain"), "plain")
|
||||
Assert.eq(Annotation.noteText('{"ops":[{"insert":"delta\\n"}]}', " ", " "), "delta")
|
||||
|
||||
-- commentHtml:块级边界转换行(后端 StripHtml 不插分隔,块之间会粘)。
|
||||
Assert.eq(Annotation.noteText(nil, "<p>第一段</p><p>第二段</p>", ""), "第一段\n第二段")
|
||||
Assert.eq(Annotation.noteText(nil, "<p>a<br>b</p>", ""), "a\nb")
|
||||
Assert.eq(Annotation.noteText(nil, "<p>a</p><p><br></p><p>b</p>", ""), "a\n\nb", "Quill 空行")
|
||||
Assert.eq(Annotation.noteText(nil, "<div>a</div><div>b</div>", ""), "a\nb")
|
||||
Assert.eq(Annotation.noteText(nil, "<p>a & b <c> "d"</p>", ""), 'a & b <c> "d"', "实体解码")
|
||||
Assert.eq(Annotation.noteText(nil, "<p><br></p>", ""), "", "全删后的空 HTML 也是空")
|
||||
|
||||
-- 写入:空备注与 Web「新建未输入」字节一致("{}" + ""),不能写 {"ops":[...]}。
|
||||
for _idx, note in ipairs({ nil, "", " ", "\n\n", " \n \n" }) do
|
||||
local remote = Annotation.toRemote(note)
|
||||
Assert.eq(remote.comment, "{}", "空备注 comment")
|
||||
Assert.eq(remote.commentHtml, "", "空备注 commentHtml")
|
||||
end
|
||||
|
||||
-- 写入:单个 insert op、末尾补 \n(Delta 文档必须以换行结尾);每行一个 <p>。
|
||||
local one = Annotation.toRemote("第一行\n第二行")
|
||||
local ops = JsonStub.decode(one.comment).ops
|
||||
Assert.eq(#ops, 1, "只有一个 insert op")
|
||||
Assert.eq(ops[1].insert, "第一行\n第二行\n")
|
||||
Assert.eq(one.commentHtml, "<p>第一行</p><p>第二行</p>", "空行写 <p><br></p>")
|
||||
Assert.eq(Annotation.toRemote("a\n\nb").commentHtml, "<p>a</p><p><br></p><p>b</p>")
|
||||
|
||||
-- 写入:转义 & < > ";先转 & 再转别的,避免二次转义。
|
||||
Assert.eq(
|
||||
Annotation.toRemote('a & b < c > d "e"').commentHtml,
|
||||
"<p>a & b < c > d "e"</p>"
|
||||
)
|
||||
|
||||
-- 写入:CRLF 归一、尾部换行去掉(否则每轮读回都多一行 → 判改过)。
|
||||
local crlf = Annotation.toRemote("a\r\nb\n\n")
|
||||
Assert.eq(JsonStub.decode(crlf.comment).ops[1].insert, "a\nb\n")
|
||||
Assert.eq(crlf.commentHtml, "<p>a</p><p>b</p>")
|
||||
|
||||
-- 往返:自己写的备注读回后与归一后的 note 一致(push / pull 同一口径 → 零 update)。
|
||||
for _idx, note in ipairs({
|
||||
"一句话",
|
||||
"第一行\n第二行",
|
||||
"a\n\nb",
|
||||
'引号 " 与反斜杠 \\ 都原样',
|
||||
"小于 < 大于 > 和 & 号",
|
||||
"好书📚 与 emoji 👍🏽",
|
||||
" 行首缩进保留",
|
||||
}) do
|
||||
local remote = Annotation.toRemote(note)
|
||||
Assert.eq(Annotation.noteText(remote.comment), note, "Delta 读回:" .. note)
|
||||
Assert.eq(
|
||||
Annotation.noteText(remote.comment, remote.commentHtml, ""),
|
||||
note,
|
||||
"完整 DTO 读回(commentHtml 优先):" .. note
|
||||
)
|
||||
end
|
||||
|
||||
-- 比较归一:trim + 内部连续空白压一个 + 零宽剔除;两边都空判等。
|
||||
Assert.is_true(Annotation.sameNote(nil, ""))
|
||||
Assert.is_true(Annotation.sameNote("", " "))
|
||||
Assert.is_true(Annotation.sameNote("a b", " a b "))
|
||||
Assert.is_true(Annotation.sameNote("a\nb", "a b"), "换行也是空白")
|
||||
Assert.is_true(Annotation.sameNote("a\226\128\139b", "ab"), "零宽空格剔除")
|
||||
Assert.is_true(Annotation.sameNote("a\239\187\191b", "ab"), "BOM 剔除")
|
||||
Assert.is_false(Annotation.sameNote("a", "b"))
|
||||
Assert.is_false(Annotation.sameNote("", "a"))
|
||||
|
||||
-- 幂等键:comment 不参与、selectedText 空白归一、xPath 精确。
|
||||
local base = { chapterId = 7, xPath = "//body/p[1]", endingXPath = "//body/p[2]", selectedText = "选中 文本" }
|
||||
local function keyOf(over)
|
||||
local ann = {}
|
||||
for k, v in pairs(base) do ann[k] = v end
|
||||
for k, v in pairs(over or {}) do ann[k] = v end
|
||||
return Annotation.key(ann)
|
||||
end
|
||||
Assert.eq(keyOf({ comment = "甲" }), keyOf({ comment = "乙" }), "改备注不是新建")
|
||||
Assert.eq(keyOf({ selectedText = " 选中\n文本 " }), keyOf({}), "选中文本的空白差异命中")
|
||||
Assert.is_true(keyOf({ xPath = "//body/p[9]" }) ~= keyOf({}))
|
||||
Assert.is_true(keyOf({ endingXPath = "//body/p[9]" }) ~= keyOf({}))
|
||||
Assert.is_true(keyOf({ chapterId = 8 }) ~= keyOf({}))
|
||||
Assert.eq(keyOf({}), "7" .. string.char(31) .. "//body/p[1]" .. string.char(31) .. "//body/p[2]" .. string.char(31) .. "选中 文本")
|
||||
-- 分隔符对外导出:源侧拼「同坐标」判定键用的是同一个字符,不各写一份字面量。
|
||||
Assert.eq(Annotation.KEY_SEP, string.char(31))
|
||||
-- pull 落库后的本地条目把选中文本叫 text。
|
||||
Assert.eq(
|
||||
Annotation.key({ chapterId = 7, xPath = "//body/p[1]", endingXPath = "//body/p[2]", text = "选中 文本" }),
|
||||
keyOf({})
|
||||
)
|
||||
-- payload 形状(pull 落库后 / 阅读器快照里的条目)没有 DTO 字段名:xPath / endingXPath / selectedText
|
||||
-- 的回退是 kavita_xpath / kavita_ending_xpath / text。源侧「远端同键去重」直接拿它当键。
|
||||
Assert.eq(
|
||||
Annotation.key({ chapterId = 7, kavita_xpath = "//body/p[1]", kavita_ending_xpath = "//body/p[2]",
|
||||
text = "选中 文本" }),
|
||||
keyOf({}),
|
||||
"payload 字段与 DTO 字段算出同一个键"
|
||||
)
|
||||
Assert.eq(
|
||||
Annotation.key({ kavita_xpath = "//body/p[1]", kavita_ending_xpath = "//body/p[2]", text = "选中 文本" }),
|
||||
Annotation.key({ xPath = "//body/p[1]", endingXPath = "//body/p[2]", selectedText = "选中 文本" })
|
||||
)
|
||||
Assert.eq(
|
||||
Annotation.key({ chapterId = 7, xPath = "//body/p[1]", kavita_xpath = "//body/p[9]", endingXPath = "//body/p[2]",
|
||||
text = "选中 文本" }),
|
||||
keyOf({}),
|
||||
"DTO 字段优先,回退只在缺失时生效"
|
||||
)
|
||||
|
||||
-- 对账命中:同键多条取 id 最小;无命中 nil。
|
||||
local remote = {
|
||||
{ id = 9, chapterId = 7, xPath = "//body/p[1]", endingXPath = "//body/p[2]", selectedText = "选中 文本", comment = "{}" },
|
||||
{ id = 3, chapterId = 7, xPath = "//body/p[1]", endingXPath = "//body/p[2]", selectedText = " 选中\n文本 ", comment = "{ops}" },
|
||||
{ id = 1, chapterId = 7, xPath = "//body/p[5]", endingXPath = "//body/p[6]", selectedText = "别的划线" },
|
||||
}
|
||||
Assert.eq(Annotation.match(remote, base).id, 3, "同键两条取 id 最小")
|
||||
Assert.eq(Annotation.match({ { id = "12", chapterId = 7, xPath = "//body/p[1]", endingXPath = "//body/p[2]", selectedText = "选中 文本" } }, base).id, "12", "字符串 id 也能比")
|
||||
Assert.is_nil(Annotation.match(remote, { chapterId = 7, xPath = "//body/p[7]", endingXPath = "//body/p[8]", selectedText = "x" }))
|
||||
Assert.is_nil(Annotation.match(nil, base))
|
||||
|
||||
-- 列表:`GET /api/Annotation/all?chapterId=`,无分页;owner_id 非空才按 ownerUserId 过滤
|
||||
-- (owner_id 为空是 `/api/Users/me` 不可用时的降级:不过滤,宁可多看到自己的)。
|
||||
local chapter = {
|
||||
{ id = 1, ownerUserId = 5, comment = "{}" },
|
||||
{ id = 2, ownerUserId = 9, comment = "别人的纯文本备注" },
|
||||
{ id = 3, ownerUserId = 5, comment = "" },
|
||||
}
|
||||
local calls = {}
|
||||
local function clientReturning(data, err)
|
||||
return {
|
||||
json = function(_self, method, path, query, body, cb)
|
||||
calls[#calls + 1] = { method = method, path = path, query = query, body = body }
|
||||
cb(data, err)
|
||||
return { cancel = function() end }
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
||||
local got, got_err
|
||||
Annotation.listByChapter(clientReturning(chapter), 12763, nil, function(list, err) got, got_err = list, err end)
|
||||
Assert.eq(calls[1].method, "GET")
|
||||
Assert.eq(calls[1].path, "/api/Annotation/all")
|
||||
Assert.eq(calls[1].query.chapterId, 12763)
|
||||
Assert.is_nil(calls[1].query.pageNumber, "该接口没有分页")
|
||||
Assert.is_nil(calls[1].body)
|
||||
Assert.eq(#got, 3, "owner_id 为空时不过滤")
|
||||
Assert.is_nil(got_err)
|
||||
|
||||
calls = {}
|
||||
Annotation.listByChapter(clientReturning(chapter), 12763, 5, function(list) got = list end)
|
||||
Assert.eq(#got, 2, "只留自己的注解")
|
||||
Assert.eq(got[1].id, 1)
|
||||
Assert.eq(got[2].id, 3)
|
||||
|
||||
calls = {}
|
||||
Annotation.listByChapter(clientReturning(chapter), 12763, "5", function(list) got = list end)
|
||||
Assert.eq(#got, 2, "字符串 owner_id 也能对上数字 ownerUserId")
|
||||
|
||||
Annotation.listByChapter(clientReturning(nil, "请求失败 (HTTP 400)"), 12763, 5, function(list, err)
|
||||
got, got_err = list, err
|
||||
end)
|
||||
Assert.is_nil(got, "失败回 nil")
|
||||
Assert.eq(got_err, "请求失败 (HTTP 400)")
|
||||
|
||||
Annotation.listByChapter(clientReturning({}), 12763, 5, function(list) got = list end)
|
||||
Assert.eq(#got, 0, "该章没有注解 = 空列表,不是 nil")
|
||||
@@ -0,0 +1,859 @@
|
||||
--[[--
|
||||
book.koplugin/source/kavita/cache.lua:kamare 缓存适配层。
|
||||
|
||||
kamare 的 `kamarecache` 是唯一的缓存执行者。这里只做探测、能力门面、配置镜像、
|
||||
错误文案、书架投影与删除保护,所有 kamare 模块都在函数内 pcall require、不持有 table。
|
||||
|
||||
@module tests.moonsource_kavita.cache_spec
|
||||
--]]
|
||||
---@diagnostic disable: undefined-field, missing-fields, inject-field
|
||||
|
||||
local Assert = require("support.assert")
|
||||
local Config = require("support.config")
|
||||
|
||||
local PLUGIN = (debug.getinfo(1, "S").source:match("^@(.-)/tests/") .. "/moonsource-kavita.koplugin/moonsource_kavita")
|
||||
|
||||
-- 源配置:每个用例自己改;cache 只读 base_url / api_key。
|
||||
local cfg = {}
|
||||
package.preload["utils.settings"] = function()
|
||||
return {
|
||||
getSource = function() return cfg end,
|
||||
saveSource = function() end,
|
||||
}
|
||||
end
|
||||
|
||||
-- 日志:记录每一行,供「一次性 / 不刷屏」断言。
|
||||
local logs = {}
|
||||
package.preload["utils.log"] = function()
|
||||
local function push(level, ...)
|
||||
local parts = {}
|
||||
for index = 1, select("#", ...) do
|
||||
parts[#parts + 1] = tostring(select(index, ...))
|
||||
end
|
||||
logs[#logs + 1] = { level = level, text = table.concat(parts, " ") }
|
||||
end
|
||||
return {
|
||||
dbg = function(...) push("dbg", ...) end,
|
||||
info = function(...) push("info", ...) end,
|
||||
warn = function(...) push("warn", ...) end,
|
||||
error = function(...) push("error", ...) end,
|
||||
}
|
||||
end
|
||||
|
||||
package.preload["moonsource_kavita.cache"] = function()
|
||||
return dofile(PLUGIN .. "/cache.lua")
|
||||
end
|
||||
local Cache = require("moonsource_kavita.cache")
|
||||
|
||||
--- 清空 kamare 模块,模拟未安装。
|
||||
local function uninstall()
|
||||
package.loaded["kamarecache"] = nil
|
||||
package.preload["kamarecache"] = nil
|
||||
package.loaded["kamareimageviewer"] = nil
|
||||
package.preload["kamareimageviewer"] = nil
|
||||
package.loaded["kamareversion"] = nil
|
||||
package.preload["kamareversion"] = nil
|
||||
end
|
||||
|
||||
--- 装一个 kamarecache 桩;status 用 loadstring 造出可预测的模块路径。
|
||||
---@param spec table { api_version, capabilities, version, path, viewer }
|
||||
---@return table
|
||||
local function installCache(spec)
|
||||
package.loaded["kamareimageviewer"] = spec.viewer
|
||||
local mod = {
|
||||
api_version = spec.api_version,
|
||||
capabilities = spec.capabilities or {},
|
||||
}
|
||||
if spec.path then
|
||||
mod.status = assert(loadstring("return function() end", "@" .. spec.path))()
|
||||
end
|
||||
package.loaded["kamarecache"] = mod
|
||||
if spec.version then
|
||||
package.loaded["kamareversion"] = spec.version
|
||||
end
|
||||
Cache.reset()
|
||||
return mod
|
||||
end
|
||||
|
||||
local function resetLogs()
|
||||
logs = {}
|
||||
end
|
||||
|
||||
local function logText()
|
||||
local parts = {}
|
||||
for _idx, line in ipairs(logs) do parts[#parts + 1] = line.text end
|
||||
return table.concat(parts, "\n")
|
||||
end
|
||||
|
||||
--- 含某段文字的行数(一次性 / 不刷屏断言用)。
|
||||
---@param fragment string
|
||||
---@return integer
|
||||
local function countLines(fragment)
|
||||
local count = 0
|
||||
for _idx, line in ipairs(logs) do
|
||||
if line.text:find(fragment, 1, true) then count = count + 1 end
|
||||
end
|
||||
return count
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- 探测:四安装态、版本、加载路径;成功记忆、失败不记忆。
|
||||
----------------------------------------------------------------------
|
||||
uninstall()
|
||||
Cache.reset()
|
||||
local probe = Cache.probe()
|
||||
Assert.is_false(probe.ok, "没有 kamarecache 不可用")
|
||||
Assert.eq(probe.state, "missing", "未安装 / 已安装但被禁用")
|
||||
Assert.eq(probe.reason, "missing")
|
||||
Assert.eq(Cache.available("open"), false, "未安装时没有任何缓存能力")
|
||||
|
||||
uninstall()
|
||||
package.loaded["kamareimageviewer"] = { new = function() end }
|
||||
Cache.reset()
|
||||
probe = Cache.probe()
|
||||
Assert.is_false(probe.ok, "官方版没有缓存接口")
|
||||
Assert.eq(probe.state, "official", "有查看器但无 kamarecache")
|
||||
|
||||
installCache({ api_version = 2, capabilities = { status = true, open = true } })
|
||||
probe = Cache.probe()
|
||||
Assert.is_false(probe.ok, "主版本不符整体禁用")
|
||||
Assert.eq(probe.state, "incompatible")
|
||||
Assert.eq(probe.api_version, 2)
|
||||
Assert.eq(probe.reason, "major_mismatch")
|
||||
Assert.eq(Cache.available("status"), false, "主版本不符整体禁用缓存")
|
||||
Assert.eq(Cache.available("open"), false, "没有查看器可退回时 open 也不可用")
|
||||
|
||||
local fake_path = "/fake/plugins/kamare.koplugin/src/kamarecache.lua"
|
||||
installCache({
|
||||
api_version = 1,
|
||||
capabilities = { status = true, open = true },
|
||||
version = "0.10.0-dev",
|
||||
path = fake_path,
|
||||
})
|
||||
probe = Cache.probe()
|
||||
Assert.is_true(probe.ok)
|
||||
Assert.eq(probe.state, "enhanced")
|
||||
Assert.eq(probe.api_version, 1)
|
||||
Assert.eq(probe.version, "0.10.0-dev", "kamareversion 返回字符串")
|
||||
Assert.eq(probe.path, fake_path, "加载路径取自 debug.getinfo(module.status)")
|
||||
|
||||
-- data 目录里的插件路径是 `plugins//x.koplugin`(KOReader 的 extra_plugin_paths 带尾斜杠):
|
||||
-- 展示前归一,否则用户会以为路径坏了。
|
||||
installCache({
|
||||
api_version = 1,
|
||||
capabilities = { status = true, open = true },
|
||||
version = "0.10.0-dev",
|
||||
path = "/fake/plugins//kamare.koplugin/kamarecache.lua",
|
||||
})
|
||||
Assert.eq(Cache.probe().path, "/fake/plugins/kamare.koplugin/kamarecache.lua", "重复斜杠归一")
|
||||
Assert.eq(probe.capabilities.status, true)
|
||||
Assert.eq(Cache.available("status"), true)
|
||||
Assert.eq(Cache.available("index"), false, "能力逐项判断")
|
||||
|
||||
-- 成功结果进程内记忆:模块从 package 里消失后仍按上次结果
|
||||
package.loaded["kamarecache"] = nil
|
||||
Assert.eq(Cache.probe().state, "enhanced", "成功结果记住,不重复 require")
|
||||
Assert.eq(Cache.reprobe().state, "missing", "「重新检测」清掉成功记忆")
|
||||
Cache.reset()
|
||||
Assert.eq(Cache.probe().state, "missing", "reset 后重新探测")
|
||||
|
||||
-- 失败不记忆:装上模块后立刻能看到增强版
|
||||
Assert.eq(Cache.probe().state, "missing")
|
||||
installCache({ api_version = 1, capabilities = {} })
|
||||
Assert.eq(Cache.probe().state, "enhanced", "失败结果不缓存")
|
||||
|
||||
-- kamareversion 用表形状也认(老写法)
|
||||
package.loaded["kamareversion"] = { version = "0.9.9" }
|
||||
Cache.reset()
|
||||
Assert.eq(Cache.probe().version, "0.9.9")
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- 功能清单:kamarefeatures.lua 原样展示;缺文件 / 版本不符 / 结构不合法都不显示。
|
||||
----------------------------------------------------------------------
|
||||
local function withManifest(value)
|
||||
package.loaded["kamarefeatures"] = value
|
||||
Cache.reset()
|
||||
return Cache.featureText()
|
||||
end
|
||||
|
||||
uninstall()
|
||||
installCache({ api_version = 1, capabilities = { open = true }, path = fake_path })
|
||||
Assert.eq(withManifest({ api_version = 1, features = { "缓存", "双页", "裁切" } }),
|
||||
"缓存 · 双页 · 裁切", "按清单顺序拼接")
|
||||
Assert.eq(withManifest({ api_version = 1, features = { "缓存", "缓存", "", 42, "裁切" } }),
|
||||
"缓存 · 裁切", "去重并忽略空串 / 非字符串")
|
||||
Assert.is_nil(withManifest({ api_version = 2, features = { "缓存" } }), "api_version 不符")
|
||||
Assert.is_nil(withManifest({ api_version = 1, features = {} }), "空清单")
|
||||
Assert.is_nil(withManifest({ api_version = 1, features = "缓存" }), "不是数组")
|
||||
Assert.is_nil(withManifest({ api_version = 1 }), "没有 features")
|
||||
Assert.is_nil(withManifest("not a table"), "不是表")
|
||||
package.loaded["kamarefeatures"] = nil
|
||||
Cache.reset()
|
||||
Assert.is_nil(Cache.featureText(), "没有清单不显示")
|
||||
|
||||
-- 最多 8 项
|
||||
local many = {}
|
||||
for i = 1, 10 do many[i] = "功能" .. i end
|
||||
local text = withManifest({ api_version = 1, features = many })
|
||||
Assert.not_nil(text:find("功能8", 1, true), "保留前 8 项")
|
||||
Assert.is_nil(text:find("功能9", 1, true), "超出 8 项截断")
|
||||
|
||||
-- 未安装 kamare 时,即使有清单也不显示。
|
||||
package.loaded["kamarefeatures"] = { api_version = 1, features = { "缓存" } }
|
||||
uninstall()
|
||||
Cache.reset()
|
||||
Assert.is_nil(Cache.featureText(), "非增强版不显示")
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- 门面:每个能力一个显式包装,参数只从配置补 base_url;缺能力则 unsupported。
|
||||
----------------------------------------------------------------------
|
||||
cfg = { base_url = "http://kav/", api_key = " k " }
|
||||
|
||||
local calls = {}
|
||||
local function record(name, impl)
|
||||
return function(...)
|
||||
calls[#calls + 1] = { name = name, args = { ... } }
|
||||
if impl then return impl(...) end
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
local function lastCall(name)
|
||||
for index = #calls, 1, -1 do
|
||||
if calls[index].name == name then return calls[index] end
|
||||
end
|
||||
end
|
||||
|
||||
local index_result = { used = 1, available = 2, series = { ["60"] = { seriesId = 60 } } }
|
||||
local mod = installCache({
|
||||
api_version = 1,
|
||||
capabilities = {
|
||||
status = true, summary = true, resume = true, queue = true,
|
||||
index = true, enqueue = true, delete = true, estimate = true,
|
||||
queue_control = true,
|
||||
},
|
||||
})
|
||||
mod.index = record("index", function() return index_result end)
|
||||
mod.status = record("status", function() return { state = "complete" } end)
|
||||
mod.resume_page = record("resume_page", function() return { page = 7 } end)
|
||||
mod.summary = record("summary", function() return { used = 10, available = 20, chapters = 3 } end)
|
||||
mod.queue_state = record("queue_state", function() return { state = "idle" } end)
|
||||
mod.enqueue = record("enqueue", function() return true, nil, { chapters = 1 } end)
|
||||
mod.delete = record("delete", function() return true, nil, 1 end)
|
||||
mod.estimate = record("estimate", function() return { ok = true, chapters = 1, bytes = 1, available = 2 } end)
|
||||
|
||||
Assert.eq(Cache.index(), index_result)
|
||||
Assert.eq(lastCall("index").args[1], "http://kav", "base_url 去尾斜杠;不传 api_key")
|
||||
|
||||
Assert.eq(Cache.status(6001).state, "complete")
|
||||
Assert.eq(lastCall("status").args[1], "http://kav")
|
||||
Assert.eq(lastCall("status").args[2], 6001)
|
||||
|
||||
Assert.eq(Cache.resumePage(6001, 60).page, 7)
|
||||
Assert.eq(lastCall("resume_page").args[1], "http://kav")
|
||||
Assert.eq(lastCall("resume_page").args[2], 6001)
|
||||
Assert.eq(lastCall("resume_page").args[3], 60)
|
||||
|
||||
Assert.eq(Cache.summary().chapters, 3)
|
||||
Assert.eq(lastCall("summary").args[1], "http://kav")
|
||||
|
||||
Assert.eq(Cache.queueState().state, "idle")
|
||||
Assert.eq(lastCall("queue_state").args[1], "http://kav")
|
||||
|
||||
local ok, code, info = Cache.enqueue({ { chapterId = 6001 } })
|
||||
Assert.is_true(ok)
|
||||
Assert.is_nil(code)
|
||||
Assert.eq(info.chapters, 1, "成功时第三个返回值原样透出")
|
||||
Assert.eq(lastCall("enqueue").args[1], "http://kav")
|
||||
Assert.eq(lastCall("enqueue").args[2][1].chapterId, 6001)
|
||||
|
||||
local deleted_ok, deleted_code, deleted = Cache.delete({ 6001 })
|
||||
Assert.is_true(deleted_ok)
|
||||
Assert.is_nil(deleted_code)
|
||||
Assert.eq(deleted, 1)
|
||||
Assert.eq(lastCall("delete").args[1], "http://kav")
|
||||
Assert.eq(lastCall("delete").args[2][1], 6001)
|
||||
|
||||
Assert.is_true(Cache.estimate({ { chapterId = 6001 } }).ok)
|
||||
Assert.eq(lastCall("estimate").args[1], "http://kav")
|
||||
Assert.eq(lastCall("estimate").args[2][1].chapterId, 6001)
|
||||
|
||||
-- 队列控制:三个显式包装,全部作用在全局队列上。
|
||||
mod.queue_pause = record("queue_pause")
|
||||
mod.queue_resume = record("queue_resume")
|
||||
mod.queue_retry = record("queue_retry")
|
||||
Assert.is_true(Cache.queuePause())
|
||||
Assert.is_true(Cache.queueResume())
|
||||
Assert.is_true(Cache.queueRetry({ 6001, 6002 }))
|
||||
Assert.eq(lastCall("queue_pause").args[1], "http://kav")
|
||||
Assert.eq(lastCall("queue_resume").args[1], "http://kav")
|
||||
Assert.eq(lastCall("queue_retry").args[1], "http://kav")
|
||||
Assert.eq(lastCall("queue_retry").args[2][2], 6002)
|
||||
|
||||
-- 缺能力:对应功能单独降级,kamare 的函数不会被调用。
|
||||
calls = {}
|
||||
installCache({ api_version = 1, capabilities = { status = true } })
|
||||
local value, code = Cache.status(1)
|
||||
Assert.eq(code, "unsupported", "能力声明了但没有函数也按缺失处理")
|
||||
value, code = Cache.index()
|
||||
Assert.is_nil(value, "缺 index 返回 nil")
|
||||
Assert.eq(code, "unsupported")
|
||||
value, code = Cache.summary()
|
||||
Assert.is_nil(value)
|
||||
Assert.eq(code, "unsupported")
|
||||
Assert.eq(select(2, Cache.queueState()), "unsupported")
|
||||
Assert.eq(select(2, Cache.queueState()), "unsupported")
|
||||
Assert.eq(select(2, Cache.queuePause()), "unsupported")
|
||||
Assert.eq(select(2, Cache.enqueue({ { chapterId = 1 } })), "unsupported")
|
||||
Assert.eq(select(2, Cache.delete({ 1 })), "unsupported")
|
||||
Assert.eq(select(2, Cache.estimate({ { chapterId = 1 } })), "unsupported")
|
||||
|
||||
-- 未配置服务器:静默 unknown_server,不碰 kamare。
|
||||
cfg = { base_url = "", api_key = "" }
|
||||
calls = {}
|
||||
Assert.eq(select(2, Cache.index()), "unknown_server")
|
||||
Assert.eq(select(2, Cache.enqueue({ { chapterId = 1 } })), "unknown_server")
|
||||
Assert.len(calls, 0, "未配置时不发任何调用")
|
||||
|
||||
-- kamare 的错误码原样透出,文案交给 message 表。
|
||||
cfg = { base_url = "http://kav/", api_key = "k" }
|
||||
installCache({
|
||||
api_version = 1,
|
||||
capabilities = { index = true, enqueue = true },
|
||||
})
|
||||
mod = package.loaded["kamarecache"]
|
||||
mod.index = function() return nil, "unknown_server" end
|
||||
mod.enqueue = function() return nil, "not_enough_space", "空间不足", { needed = 3, available = 1 } end
|
||||
local read, read_code = Cache.index()
|
||||
Assert.is_nil(read)
|
||||
Assert.eq(read_code, "unknown_server")
|
||||
local written, write_code, write_message, write_detail = Cache.enqueue({ { chapterId = 1 } })
|
||||
Assert.is_nil(written)
|
||||
Assert.eq(write_code, "not_enough_space")
|
||||
Assert.eq(write_message, "空间不足")
|
||||
Assert.eq(write_detail.available, 1)
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- 配置镜像:首次缓存操作前 + 每次写操作前;只传 base_url + api_key,不传 name。
|
||||
----------------------------------------------------------------------
|
||||
cfg = { base_url = "http://kav/", api_key = " k " }
|
||||
calls = {}
|
||||
resetLogs()
|
||||
local mirror_mod = installCache({
|
||||
api_version = 1,
|
||||
capabilities = { server = true, index = true, status = true, enqueue = true,
|
||||
delete = true, queue_control = true, estimate = true },
|
||||
})
|
||||
mirror_mod.register_server = record("register_server", function() return "srv-1" end)
|
||||
mirror_mod.index = record("index", function() return { series = {} } end)
|
||||
mirror_mod.status = record("status")
|
||||
mirror_mod.enqueue = record("enqueue", function() return true end)
|
||||
mirror_mod.delete = record("delete", function() return true, nil, 1 end)
|
||||
mirror_mod.queue_pause = record("queue_pause")
|
||||
mirror_mod.queue_resume = record("queue_resume")
|
||||
mirror_mod.queue_retry = record("queue_retry")
|
||||
mirror_mod.estimate = record("estimate", function() return { ok = true } end)
|
||||
|
||||
local function callCount(name)
|
||||
local n = 0
|
||||
for _idx, call in ipairs(calls) do
|
||||
if call.name == name then n = n + 1 end
|
||||
end
|
||||
return n
|
||||
end
|
||||
|
||||
--- 某次调用在 calls 里的位置(从 1 起;没有为 0)
|
||||
local function callIndex(name)
|
||||
for index, call in ipairs(calls) do
|
||||
if call.name == name then return index end
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
Cache.index()
|
||||
Assert.eq(callCount("register_server"), 1, "首次缓存操作前镜像一次")
|
||||
local registered = lastCall("register_server").args[1]
|
||||
Assert.eq(registered.base_url, "http://kav", "URL 规范化:去尾斜杠")
|
||||
Assert.eq(registered.api_key, "k", "API Key 去空白")
|
||||
Assert.is_nil(registered.name, "不传固定显示名(否则两台服务器会共用一个缓存目录)")
|
||||
|
||||
Cache.status(1)
|
||||
Assert.eq(callCount("register_server"), 1, "读操作不重复镜像")
|
||||
|
||||
Cache.enqueue({ { chapterId = 1 } })
|
||||
Assert.eq(callCount("register_server"), 2, "每次写操作前幂等兜底")
|
||||
Assert.is_true(callIndex("register_server") < callIndex("enqueue"), "镜像先于写入")
|
||||
|
||||
Cache.delete({ 1 })
|
||||
Cache.queuePause()
|
||||
Cache.queueResume()
|
||||
Cache.queueRetry({ 1 })
|
||||
Cache.estimate({ { chapterId = 1 } })
|
||||
Assert.eq(callCount("register_server"), 6, "delete / queue_* / 估计写盘前路径都镜像")
|
||||
|
||||
-- 显式调用:设置页保存后走这一个入口。
|
||||
local server_key, mirror_code = Cache.registerServer("http://kav/", " k ")
|
||||
Assert.eq(server_key, "srv-1")
|
||||
Assert.is_nil(mirror_code)
|
||||
Assert.eq(callCount("register_server"), 7)
|
||||
|
||||
-- 失败:后台只记一次日志,功能照常交给 kamare(按 unknown_server 静默降级)。
|
||||
mirror_mod.register_server = record("register_server", function() return nil, "settings_write_failed" end)
|
||||
local before = callCount("register_server")
|
||||
Cache.enqueue({ { chapterId = 2 } })
|
||||
Assert.eq(callCount("register_server"), before + 1)
|
||||
Assert.eq(callCount("enqueue"), 2, "镜像失败不阻断写操作,最终以 kamare 为准")
|
||||
Assert.is_true(Cache.mirrorFailed(), "本次会话镜像失败")
|
||||
Assert.matches(logText(), "settings_write_failed", "失败记一行")
|
||||
local mirror_lines = 0
|
||||
for _idx, line in ipairs(logs) do
|
||||
if line.text:find("mirror", 1, true) then mirror_lines = mirror_lines + 1 end
|
||||
end
|
||||
Assert.eq(mirror_lines, 1, "同一原因只记一次")
|
||||
Cache.enqueue({ { chapterId = 3 } })
|
||||
mirror_lines = 0
|
||||
for _idx, line in ipairs(logs) do
|
||||
if line.text:find("mirror", 1, true) then mirror_lines = mirror_lines + 1 end
|
||||
end
|
||||
Assert.eq(mirror_lines, 1, "重复失败不刷屏")
|
||||
|
||||
mirror_mod.register_server = record("register_server", function() return "srv-1" end)
|
||||
Cache.enqueue({ { chapterId = 4 } })
|
||||
Assert.is_false(Cache.mirrorFailed(), "成功后清除失败态")
|
||||
|
||||
-- 未配置 / 未安装时不假装镜像。
|
||||
cfg = { base_url = "", api_key = "" }
|
||||
calls = {}
|
||||
Cache.index()
|
||||
Assert.len(calls, 0, "未配置不发镜像")
|
||||
|
||||
cfg = { base_url = "http://kav/", api_key = "k" }
|
||||
uninstall()
|
||||
Cache.reset()
|
||||
calls = {}
|
||||
Cache.available("index")
|
||||
Assert.len(calls, 0, "未安装不发镜像")
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- 文案:02 A9 的 code 表 + 07 A7 的 lastError 特征。
|
||||
----------------------------------------------------------------------
|
||||
local CODE_CASES = {
|
||||
{ "offline_not_cached", "这一卷还没缓存,联网后可下载" },
|
||||
{ "viewer_running", "漫画阅读器已在运行" },
|
||||
{ "no_pages", "这一卷没有可显示的页面" },
|
||||
{ "settings_write_failed", "无法写入 kamare 配置" },
|
||||
{ "retry_no_entry", "没有可重试的任务" },
|
||||
{ "chapter_open", "正在阅读这一卷,关闭后可以删除" },
|
||||
}
|
||||
for _idx, case in ipairs(CODE_CASES) do
|
||||
Assert.eq(Cache.message(case[1]), case[2], "code → 文案: " .. case[1])
|
||||
end
|
||||
-- 静默:已是目标状态 / 未知服务器都当无缓存,不打扰用户。
|
||||
Assert.is_nil(Cache.message("unknown_server"), "unknown_server 静默")
|
||||
Assert.is_nil(Cache.message("already_cached"), "已缓存静默")
|
||||
Assert.is_nil(Cache.message("already_queued"), "已排队静默")
|
||||
Assert.is_nil(Cache.message(nil), "没有 code 没有说话")
|
||||
-- 未知 code:kamare 的 message 优先,再退通用文案。
|
||||
Assert.eq(Cache.message("weird_code", "kamare 的原话"), "kamare 的原话")
|
||||
Assert.eq(Cache.message("weird_code"), "缓存操作失败")
|
||||
|
||||
local MB = 1024 * 1024
|
||||
Assert.eq(Cache.sizeText(3 * MB), "3.0 MB")
|
||||
Assert.eq(Cache.message("not_enough_space", nil, { needed = 3 * MB, available = MB }),
|
||||
"空间不足:需要 3.0 MB,可用 1.0 MB")
|
||||
Assert.eq(Cache.message("cache_limit_reached", nil, { needed = 2 * MB, limit = 9 * MB }),
|
||||
"缓存空间已满:需要 2.0 MB,上限 9.0 MB")
|
||||
Assert.eq(Cache.message("low_space", nil, { available = MB, low_water = 500 * MB }),
|
||||
"可用空间低于 500.0 MB,清理后再下载")
|
||||
|
||||
-- estimate 的三种裁决:确认框就地换文案,不复制 kamare 的 2.05 / 500MB 常量。
|
||||
Assert.eq(Cache.estimateMessage({ reason = "nothing_to_do" }), "全部已缓存或正在下载")
|
||||
Assert.eq(Cache.estimateMessage({ reason = "space", bytes = 3 * MB, available = MB }),
|
||||
"空间不足:需要 3.0 MB,可用 1.0 MB")
|
||||
Assert.eq(Cache.estimateMessage({ reason = "low_water", available = MB }),
|
||||
"可用空间不足(剩余 1.0 MB),清理后再下载")
|
||||
Assert.is_nil(Cache.estimateMessage({ ok = true, reason = nil }), "可下载时没有额外文案")
|
||||
Assert.is_nil(Cache.estimateMessage(nil))
|
||||
|
||||
-- 失败原因(07 A7):按 kamare 的 lastError 特征归并成可读文案。
|
||||
local FAILED = {
|
||||
{ "http 403 while fetching page 3", "服务器拒绝下载(403),检查 API Key / 权限" },
|
||||
{ "not an archive: text/html", "下载内容不完整或不是有效压缩包" },
|
||||
{ "size 120/900", "下载内容不完整或不是有效压缩包" },
|
||||
{ "extracted 3 of 5 pages", "下载内容不完整或不是有效压缩包" },
|
||||
{ "sink write failed: no space left on device", "存储空间不足或写入失败" },
|
||||
{ "socket closed", "网络中断或服务器不可达" },
|
||||
{ "connect timeout", "网络中断或服务器不可达" },
|
||||
{ "connection truncated", "网络中断或服务器不可达" },
|
||||
}
|
||||
for _idx, case in ipairs(FAILED) do
|
||||
Assert.eq(Cache.failureText(case[1]), case[2], "lastError → 文案: " .. case[1])
|
||||
end
|
||||
Assert.eq(Cache.failureText("weird failure"), "缓存失败:weird failure", "未知错误前缀保留原话")
|
||||
Assert.is_nil(Cache.failureText(nil))
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- 打开:enhanced 有 open 走 kamare;官方 / 缺 open 退回 legacy;记录当前打开的章。
|
||||
----------------------------------------------------------------------
|
||||
cfg = { base_url = "http://kav/", api_key = "k" }
|
||||
calls = {}
|
||||
local opened = installCache({
|
||||
api_version = 1,
|
||||
capabilities = { open = true, delete = true, server = true },
|
||||
})
|
||||
opened.register_server = record("register_server", function() return "srv-1" end)
|
||||
local closed = {}
|
||||
local nexts = {}
|
||||
local fake_viewer = { kind = "viewer" }
|
||||
opened.open = record("open", function() return fake_viewer end)
|
||||
Assert.is_true(Cache.enhancedOpen(), "增强版有 open:由 kamare 决定起始页 / 离线")
|
||||
local open_result, open_code = Cache.open({
|
||||
base_url = "http://kav/", api_key = "k",
|
||||
entry = { chapterId = 6001, pages = 20 }, title = "漫画",
|
||||
on_close = function(page, total) closed[#closed + 1] = { page, total } end,
|
||||
on_next = function(id) nexts[#nexts + 1] = id end,
|
||||
})
|
||||
Assert.eq(open_result, fake_viewer)
|
||||
Assert.is_nil(open_code)
|
||||
local open_opts = lastCall("open").args[1]
|
||||
Assert.eq(open_opts.entry.chapterId, 6001, "目录条目原样交给 kamare")
|
||||
Assert.eq(open_opts.title, "漫画")
|
||||
Assert.not_nil(open_opts.on_next)
|
||||
Assert.is_true(Cache.isChapterOpen(6001), "打开成功记下当前章")
|
||||
Assert.is_false(Cache.isChapterOpen(6002))
|
||||
|
||||
open_opts.on_close(7, 20)
|
||||
Assert.eq(closed[1][1], 7, "关闭回调原样透出")
|
||||
Assert.eq(closed[1][2], 20)
|
||||
Assert.is_false(Cache.isChapterOpen(6001), "关闭后清除当前章")
|
||||
|
||||
-- 打开失败不留 active。
|
||||
opened.open = function() return nil, "viewer_running", "漫画阅读器已在运行" end
|
||||
local failed, failed_code, failed_message = Cache.open({
|
||||
base_url = "http://kav/", api_key = "k", entry = { chapterId = 6003, pages = 4 },
|
||||
})
|
||||
Assert.is_nil(failed)
|
||||
Assert.eq(failed_code, "viewer_running")
|
||||
Assert.eq(failed_message, "漫画阅读器已在运行")
|
||||
Assert.is_false(Cache.isChapterOpen(6003))
|
||||
|
||||
-- 删除保护:本地先拦,kamare 的 delete 根本不会被调用。
|
||||
calls = {}
|
||||
local deleted_viewer = installCache({
|
||||
api_version = 1,
|
||||
capabilities = { open = true, delete = true },
|
||||
})
|
||||
deleted_viewer.open = record("open", function() return { kind = "viewer" } end)
|
||||
deleted_viewer.delete = record("delete", function() return true, nil, 1 end)
|
||||
Cache.open({ base_url = "http://kav/", api_key = "k", entry = { chapterId = 6001, pages = 20 } })
|
||||
local del_ok, del_code = Cache.delete({ 6001 })
|
||||
Assert.is_nil(del_ok)
|
||||
Assert.eq(del_code, "chapter_open", "正在读的章拒绝删除")
|
||||
Assert.eq(Cache.message(del_code), "正在阅读这一卷,关闭后可以删除")
|
||||
Assert.eq(callCount("delete"), 0, "kamare 的 delete 不被调用")
|
||||
|
||||
Assert.is_true(Cache.delete({ 6002 }), "别的章照删")
|
||||
Assert.eq(lastCall("delete").args[2][1], 6002)
|
||||
|
||||
-- 关掉查看器后可以删。
|
||||
lastCall("open").args[1].on_close(1, 20)
|
||||
Assert.is_true(Cache.delete({ 6001 }))
|
||||
|
||||
-- 官方版 / enhanced 缺 open:退回 legacy 通道(今天的在线看图能力不能丢)。
|
||||
uninstall()
|
||||
package.loaded["kamareimageviewer"] = { new = function(_self, spec) return spec end }
|
||||
local streamed = {}
|
||||
package.loaded["kavitaclient"] = {
|
||||
streamChapter = function(_self, id) streamed[#streamed + 1] = id; return { { pageNumber = 1 } } end,
|
||||
}
|
||||
local shown = {}
|
||||
package.loaded["ui/uimanager"] = { show = function(_, widget) shown[#shown + 1] = widget end }
|
||||
Cache.reset()
|
||||
Assert.is_true(Cache.available("open"), "官方版仍能在线看图")
|
||||
Assert.is_false(Cache.enhancedOpen(), "官方版不接管 open:起始页由 moon 补")
|
||||
local legacy_viewer, legacy_code = Cache.open({
|
||||
base_url = "http://kav/", api_key = "k", entry = { chapterId = 6001, pages = 20 }, title = "漫画",
|
||||
start_page = 3, on_close = function() end, on_next = function() end,
|
||||
})
|
||||
Assert.is_nil(legacy_code)
|
||||
Assert.eq(legacy_viewer.metadata.chapterId, 6001)
|
||||
Assert.eq(legacy_viewer.metadata.startPage, 3)
|
||||
Assert.eq(legacy_viewer.images_list_nb, 20)
|
||||
Assert.eq(legacy_viewer.title, "漫画")
|
||||
Assert.eq(require("kavitaclient").api_key, "k")
|
||||
Assert.eq(require("kavitaclient").device_id, "moon-kavita")
|
||||
Assert.eq(streamed[1], 6001)
|
||||
Assert.eq(shown[1], legacy_viewer, "交给 UIManager 显示")
|
||||
Assert.is_true(Cache.isChapterOpen(6001), "legacy 也记当前章")
|
||||
|
||||
-- enhanced 但缺 open 能力:同样退回 legacy。
|
||||
installCache({ api_version = 1, capabilities = { status = true } })
|
||||
Assert.is_false(Cache.enhancedOpen(), "增强版缺 open:退回 legacy,由 moon 给起始页")
|
||||
package.loaded["kamareimageviewer"] = { new = function(_self, spec) return spec end }
|
||||
package.loaded["kavitaclient"] = { streamChapter = function() return { { pageNumber = 1 } } end }
|
||||
Cache.reset()
|
||||
local fallback = Cache.open({
|
||||
base_url = "http://kav/", api_key = "k", entry = { chapterId = 6004, pages = 4 },
|
||||
})
|
||||
Assert.not_nil(fallback, "增强版缺 open 时退回查看器")
|
||||
Assert.eq(fallback.metadata.chapterId, 6004)
|
||||
|
||||
-- legacy 没有页面 / 查看器已被占用 / 串流失败:稳定 code。
|
||||
Cache.reset()
|
||||
local no_pages, no_pages_code = Cache.open({
|
||||
base_url = "http://kav/", api_key = "k", entry = { chapterId = 6005, pages = 0 },
|
||||
})
|
||||
Assert.is_nil(no_pages)
|
||||
Assert.eq(no_pages_code, "no_pages")
|
||||
|
||||
package.loaded["kamareimageviewer"] = { new = function(_self, spec) spec._aborted = true; return spec end }
|
||||
local running, running_code = Cache.open({
|
||||
base_url = "http://kav/", api_key = "k", entry = { chapterId = 6006, pages = 3 },
|
||||
})
|
||||
Assert.is_nil(running)
|
||||
Assert.eq(running_code, "viewer_running")
|
||||
|
||||
package.loaded["kamareimageviewer"] = { new = function(_self, spec) return spec end }
|
||||
package.loaded["kavitaclient"] = { streamChapter = function() return nil end }
|
||||
local broken, broken_code, broken_message = Cache.open({
|
||||
base_url = "http://kav/", api_key = "k", entry = { chapterId = 6007, pages = 3 },
|
||||
})
|
||||
Assert.is_nil(broken)
|
||||
Assert.eq(broken_code, "open_failed")
|
||||
Assert.eq(broken_message, "打开漫画阅读器失败")
|
||||
|
||||
-- 完全没有 kamare:不能假装能打开。
|
||||
uninstall()
|
||||
Cache.reset()
|
||||
Assert.is_false(Cache.available("open"))
|
||||
local none, none_code = Cache.open({ base_url = "http://kav/", api_key = "k", entry = { chapterId = 1, pages = 1 } })
|
||||
Assert.is_nil(none)
|
||||
Assert.eq(none_code, "unsupported")
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- 书架投影:complete / stale 才算已缓存;三张表按服务器记忆,无 TTL。
|
||||
----------------------------------------------------------------------
|
||||
cfg = { base_url = "http://kav/", api_key = "k" }
|
||||
local work = Config.dir() .. "/cache_spec"
|
||||
os.execute("mkdir -p '" .. work .. "'")
|
||||
local cover = work .. "/cover-60.jpg"
|
||||
local cover_file = assert(io.open(cover, "wb"))
|
||||
cover_file:write("jpeg")
|
||||
cover_file:close()
|
||||
|
||||
calls = {}
|
||||
local shelf_mod = installCache({
|
||||
api_version = 1,
|
||||
capabilities = { index = true, server = true, enqueue = true, delete = true, queue_control = true },
|
||||
})
|
||||
shelf_mod.register_server = record("register_server", function() return "srv" end)
|
||||
local shelf_index = {
|
||||
series = {
|
||||
["60"] = { seriesId = 60, chapters = 2, complete = true, coverPath = cover },
|
||||
["61"] = { seriesId = 61, chapters = 0, complete = true, coverPath = work .. "/missing.jpg" },
|
||||
["62"] = { seriesId = 62, chapters = 1, stale = true },
|
||||
["63"] = { seriesId = 63, chapters = 1 },
|
||||
["64"] = { seriesId = 64, chapters = 3, stale = true, complete = false },
|
||||
},
|
||||
}
|
||||
shelf_mod.index = record("index", function() return shelf_index end)
|
||||
shelf_mod.enqueue = record("enqueue", function() return true end)
|
||||
shelf_mod.delete = record("delete", function() return true, nil, 1 end)
|
||||
shelf_mod.queue_pause = record("queue_pause", function() return true end)
|
||||
|
||||
local shelf = Cache.shelf()
|
||||
Assert.is_true(shelf.series_ids["60"], "complete 算已缓存")
|
||||
Assert.is_true(shelf.mark["60"])
|
||||
Assert.is_true(shelf.series_ids["62"], "stale 与 complete 等价")
|
||||
Assert.is_true(shelf.series_ids["64"])
|
||||
Assert.is_nil(shelf.series_ids["61"], "没有章不算(chapters = 0)")
|
||||
Assert.is_nil(shelf.series_ids["63"], "queued / downloading 不算")
|
||||
Assert.eq(shelf.cover["60"], cover, "封面路径存在才给")
|
||||
Assert.is_nil(shelf.cover["61"], "文件不存在不给")
|
||||
Assert.eq(callCount("index"), 1)
|
||||
|
||||
Cache.shelf()
|
||||
Assert.eq(callCount("index"), 1, "进程内记忆,无 TTL、翻页不重拉")
|
||||
|
||||
-- 三类失效:写操作成功、手动刷新、Registry.reload(源实例重建时调 resetShelf)。
|
||||
Cache.enqueue({ { chapterId = 6001 } })
|
||||
Cache.shelf()
|
||||
Assert.eq(callCount("index"), 2, "enqueue 成功后失效")
|
||||
Cache.delete({ 6001 })
|
||||
Cache.shelf()
|
||||
Assert.eq(callCount("index"), 3, "delete 成功后失效")
|
||||
Cache.queuePause()
|
||||
Cache.shelf()
|
||||
Assert.eq(callCount("index"), 4, "queue_* 成功后失效")
|
||||
Cache.resetShelf()
|
||||
Cache.shelf()
|
||||
Assert.eq(callCount("index"), 5, "手动刷新 / Registry.reload")
|
||||
|
||||
-- 写失败不能误伤投影(失败时缓存没变)。
|
||||
shelf_mod.enqueue = record("enqueue", function() return nil, "not_enough_space" end)
|
||||
Cache.enqueue({ { chapterId = 6002 } })
|
||||
Cache.shelf()
|
||||
Assert.eq(callCount("index"), 5, "失败的写操作不失效")
|
||||
|
||||
-- 按服务器分开记忆:切回旧服务器不重拉。
|
||||
cfg.base_url = "http://other/"
|
||||
Cache.shelf()
|
||||
Assert.eq(callCount("index"), 6)
|
||||
Assert.eq(lastCall("index").args[1], "http://other")
|
||||
cfg.base_url = "http://kav/"
|
||||
Cache.shelf()
|
||||
Assert.eq(callCount("index"), 6, "旧服务器的投影还在")
|
||||
|
||||
-- unknown_server 不记忆:下次进书架再试(可能刚镜像完)。
|
||||
shelf_mod.index = record("index", function() return nil, "unknown_server" end)
|
||||
cfg.base_url = "http://third/"
|
||||
Assert.is_nil(Cache.shelf())
|
||||
Assert.is_nil(Cache.shelf())
|
||||
Assert.eq(callCount("index"), 8, "无缓存不写空投影")
|
||||
|
||||
-- 缺 index 能力:整块降级为无标记。
|
||||
installCache({ api_version = 1, capabilities = { status = true } })
|
||||
Assert.is_nil(Cache.shelf(), "缺 index 无书架标记")
|
||||
|
||||
-- 「已缓存」口径只在一处:章状态与 index 摘要两种形状都认(03 A3)。
|
||||
Assert.is_true(Cache.isCached({ state = "complete" }))
|
||||
Assert.is_true(Cache.isCached({ state = "stale" }))
|
||||
Assert.is_false(Cache.isCached({ state = "partial" }))
|
||||
Assert.is_false(Cache.isCached(nil))
|
||||
Assert.is_true(Cache.isCached({ chapters = 1, complete = true }))
|
||||
Assert.is_false(Cache.isCached({ chapters = 1 }))
|
||||
|
||||
-- 能力名单排序与拼接:设置页与日志共用同一份(08)。
|
||||
Assert.eq(Cache.capabilityNames({ open = true, index = true }), "index,open")
|
||||
Assert.eq(Cache.capabilityNames({ open = true, index = true }, "、"), "index、open")
|
||||
Assert.eq(Cache.capabilityNames(nil), "none")
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- 日志:探测每进程一次、写操作一行、open 失败去重、暂停原因只在变化时记。
|
||||
----------------------------------------------------------------------
|
||||
cfg = { base_url = "http://kav/", api_key = "secret-key" }
|
||||
uninstall()
|
||||
resetLogs()
|
||||
Cache.reset()
|
||||
Cache.probe()
|
||||
Cache.probe()
|
||||
Assert.eq(countLines("kamare probe"), 1, "探测结果每进程只记一次")
|
||||
Assert.matches(logText(), "kamare probe ok=false state=missing")
|
||||
Assert.is_nil(logText():find("secret-key", 1, true), "日志里绝不出现 API Key")
|
||||
|
||||
installCache({
|
||||
api_version = 1,
|
||||
capabilities = { status = true, index = true, enqueue = true, delete = true,
|
||||
queue = true, queue_control = true, open = true },
|
||||
version = "0.10.0",
|
||||
path = "/fake/plugins/kamare.koplugin/kamarecache.lua",
|
||||
})
|
||||
resetLogs()
|
||||
Cache.probe()
|
||||
Cache.probe()
|
||||
Assert.eq(countLines("kamare probe ok=true"), 1)
|
||||
Assert.matches(logText(), "state=enhanced")
|
||||
Assert.matches(logText(), "version=0.10.0")
|
||||
Assert.matches(logText(), "caps=.*index")
|
||||
Assert.is_nil(logText():find("secret-key", 1, true))
|
||||
|
||||
local log_mod = package.loaded["kamarecache"]
|
||||
log_mod.status = function() return { state = "complete" } end
|
||||
log_mod.index = function() return { series = {} } end
|
||||
log_mod.enqueue = function() return nil, "not_enough_space", "空间不足", { needed = 9, available = 1 } end
|
||||
resetLogs()
|
||||
Cache.enqueue({ { chapterId = 6001 }, { chapterId = 6002 } })
|
||||
Cache.enqueue({ { chapterId = 6003 } })
|
||||
Assert.eq(countLines("cache enqueue cid=6001,6002 code=not_enough_space"), 1, "每次写操作一行,带 code 与章 id")
|
||||
Assert.eq(countLines("cache enqueue cid=6003 code=not_enough_space"), 1, "另一次失败另记一行")
|
||||
|
||||
log_mod.delete = function() return true, nil, 1 end
|
||||
resetLogs()
|
||||
Cache.delete({ 6004 })
|
||||
Assert.eq(countLines("cache delete cid=6004 code=ok"), 1)
|
||||
|
||||
log_mod.queue_pause = function() return true end
|
||||
resetLogs()
|
||||
Cache.queuePause()
|
||||
Assert.eq(countLines("cache queue_pause cid=- code=ok"), 1, "队列动作没有章 id,记 -")
|
||||
|
||||
-- 轮询路径不刷日志,只在暂停原因变化时记一行。
|
||||
log_mod.queue_state = function() return { state = "paused", pause_reason = "offline" } end
|
||||
resetLogs()
|
||||
Cache.queueState()
|
||||
Cache.queueState()
|
||||
Assert.eq(countLines("queue paused reason=offline"), 1, "1 秒轮询不重复记")
|
||||
log_mod.queue_state = function() return { state = "idle" } end
|
||||
Cache.queueState()
|
||||
log_mod.queue_state = function() return { state = "paused", pause_reason = "offline" } end
|
||||
Cache.queueState()
|
||||
Assert.eq(countLines("queue paused reason=offline"), 2, "恢复后再次暂停要再记")
|
||||
log_mod.queue_state = function() return { state = "paused", pause_reason = "network" } end
|
||||
Cache.queueState()
|
||||
Assert.eq(countLines("queue paused reason=network"), 1)
|
||||
|
||||
-- 读操作不写日志。
|
||||
resetLogs()
|
||||
Cache.status(6001)
|
||||
Cache.index()
|
||||
Assert.len(logs, 0, "读路径零日志")
|
||||
|
||||
-- open 失败同一原因只记一次。
|
||||
log_mod.open = function() return nil, "viewer_running" end
|
||||
resetLogs()
|
||||
Cache.open({ base_url = "http://kav/", api_key = "k", entry = { chapterId = 6001, pages = 4 } })
|
||||
Cache.open({ base_url = "http://kav/", api_key = "k", entry = { chapterId = 6001, pages = 4 } })
|
||||
Assert.eq(countLines("cache open cid=6001 code=viewer_running"), 1, "open 失败去重")
|
||||
|
||||
-- chapters / delete_all / plan / summaryAll:清理门面
|
||||
cfg.base_url, cfg.api_key = "http://kav", "k"
|
||||
local cleanup_calls = {}
|
||||
local cleanup_mod = installCache({
|
||||
api_version = 1,
|
||||
capabilities = { status = true, summary = true, chapters = true, delete = true,
|
||||
delete_all = true, server = true },
|
||||
version = "0.10.0",
|
||||
})
|
||||
function cleanup_mod.chapters(base_url, series_id)
|
||||
cleanup_calls.chapters = { base_url, series_id }
|
||||
return { { chapterId = 1, pages = 10, bytes = 100, read = true } }
|
||||
end
|
||||
function cleanup_mod.delete_all()
|
||||
cleanup_calls.delete_all = (cleanup_calls.delete_all or 0) + 1
|
||||
return true, nil, { chapters = 3, bytes = 300 }
|
||||
end
|
||||
function cleanup_mod.summary(base_url)
|
||||
cleanup_calls.summary = (cleanup_calls.summary or 0) + 1
|
||||
cleanup_calls.summary_base = base_url
|
||||
return { used = 300, available = 1000, chapters = 3 }
|
||||
end
|
||||
function cleanup_mod.register_server() return "srv" end
|
||||
Cache.reset()
|
||||
|
||||
local plan_rows = Cache.chapters(42)
|
||||
Assert.eq(cleanup_calls.chapters[1], "http://kav", "chapters 用当前服务器")
|
||||
Assert.eq(cleanup_calls.chapters[2], 42, "chapters 透传 series_id")
|
||||
Assert.len(plan_rows, 1, "chapters 返回数组")
|
||||
|
||||
local ok, _code, _message, detail = Cache.deleteAll()
|
||||
Assert.is_true(ok, "deleteAll 成功")
|
||||
Assert.eq(detail and detail.chapters, 3, "deleteAll 透传估算")
|
||||
Assert.eq(cleanup_calls.delete_all, 1, "deleteAll 调 kamare 一次")
|
||||
|
||||
Assert.eq(Cache.summaryAll().chapters, 3, "summaryAll 返回合计")
|
||||
Assert.eq(cleanup_calls.summary_base, nil, "summaryAll 不传 base_url")
|
||||
|
||||
local plan = Cache.plan(plan_rows, "read", nil)
|
||||
Assert.eq(plan.chapters, 1, "read 过滤保留已读")
|
||||
Assert.eq(plan.bytes, 100, "字节合计")
|
||||
Assert.eq(plan.ids[1], 1, "ids 供批量删除")
|
||||
local not_read = Cache.plan({ { chapterId = 2, pages = 10, bytes = 50, read = false } }, "read", nil)
|
||||
Assert.eq(not_read.chapters, 0, "未读不入选")
|
||||
local via_toc = Cache.plan({ { chapterId = 3, pages = 10, bytes = 50, read = false } }, "read",
|
||||
{ ["3"] = 10 })
|
||||
Assert.eq(via_toc.chapters, 1, "toc 的 pagesRead 补第三源")
|
||||
local queued = Cache.plan({ { chapterId = 4, pages = 10, bytes = 1, read = true, queued = true } }, "all", nil)
|
||||
Assert.eq(queued.queued, 1, "排队数进计划")
|
||||
|
||||
|
||||
return true
|
||||
@@ -0,0 +1,256 @@
|
||||
--[[--
|
||||
漫画缓存的后台任务:登记 passive 任务、按本批卷轮询、暂停时放行自动休眠、收尾只提示一次。
|
||||
|
||||
kamare 仍是执行者,这里只观察 queue_state / status;队列全局共享,所以进度只数本批的卷。
|
||||
|
||||
@module tests.moonsource_kavita.cache_task_spec
|
||||
--]]
|
||||
---@diagnostic disable: undefined-field, missing-fields, inject-field, redundant-parameter
|
||||
|
||||
local Assert = require("support.assert")
|
||||
local Config = require("support.config")
|
||||
local Kit = require("support.widget_stubs")
|
||||
Kit.install("paper")
|
||||
|
||||
local Themed = require("support.theme_stubs")
|
||||
Themed.install()
|
||||
|
||||
package.preload["ui/network/manager"] = function()
|
||||
return { isConnected = function() return true end }
|
||||
end
|
||||
package.preload["ui.guard"] = function()
|
||||
return {
|
||||
call = function(_label, fn, ...) return fn(...) end,
|
||||
wrap = function(_label, fn) return fn end,
|
||||
}
|
||||
end
|
||||
package.preload["utils.log"] = function()
|
||||
return { info = function() end, warn = function() end, err = function() end, dbg = function() end }
|
||||
end
|
||||
|
||||
local PLUGIN = (debug.getinfo(1, "S").source:match("^@(.-)/tests/") .. "/moonsource-kavita.koplugin/moonsource_kavita")
|
||||
|
||||
-- 缓存适配层:只提供 cache_task 用到的读接口;写操作不经过这里。
|
||||
local st = { queue = { state = "idle", entries = {} }, statuses = {}, queue_ok = true }
|
||||
package.preload["moonsource_kavita.cache"] = function()
|
||||
return {
|
||||
available = function(cap) return st.queue_ok and cap == "queue" end,
|
||||
queueState = function() return st.queue end,
|
||||
status = function(id) return st.statuses[tostring(id)] end,
|
||||
isCached = function(status)
|
||||
return type(status) == "table" and (status.state == "complete" or status.state == "stale")
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
||||
local Tasks = require("workers.tasks")
|
||||
local CacheTask = dofile(PLUGIN .. "/cache_task.lua")
|
||||
|
||||
local series = { stable_id = "900", title = "测试系列" }
|
||||
local entries = {
|
||||
{ chapterId = 1, title = "第 1 卷" },
|
||||
{ chapterId = 2, title = "第 2 卷" },
|
||||
{ chapterId = 3, title = "第 3 卷" },
|
||||
}
|
||||
|
||||
--- 跑一条指定延迟的定时器:<1 是队列的变更拍,>=1 且 <60 是轮询拍(60 秒是防休眠的 InputEvent 补拍)。
|
||||
---@param match fun(delay: number): boolean
|
||||
---@return boolean
|
||||
local function runTimer(match)
|
||||
for index, item in ipairs(Kit.scheduled) do
|
||||
if match(item.delay) then
|
||||
table.remove(Kit.scheduled, index)
|
||||
item.fn()
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
--- 结清队列的变更拍(pause_auto_suspend 之类)。
|
||||
local function changes()
|
||||
while runTimer(function(delay) return delay < 1 end) do end
|
||||
end
|
||||
|
||||
--- 跑一拍轮询。
|
||||
local function tick()
|
||||
Assert.is_true(runTimer(function(delay) return delay >= 1 and delay < 60 end), "排了下一拍轮询")
|
||||
end
|
||||
|
||||
local function reset()
|
||||
for _idx, item in ipairs(Tasks.tasks()) do
|
||||
local live = Tasks.get(item.key)
|
||||
if live then live.cancel() end
|
||||
end
|
||||
changes()
|
||||
st.queue = { state = "idle", entries = {} }
|
||||
st.statuses = {}
|
||||
st.queue_ok = true
|
||||
Themed.made = {}
|
||||
Kit.scheduled, Kit.unscheduled = {}, {}
|
||||
end
|
||||
|
||||
-- 缺 queue 能力:没有可轮询的队列,不登记(免得后台任务永远挂着)。
|
||||
do
|
||||
reset()
|
||||
st.queue_ok = false
|
||||
Assert.is_nil(CacheTask.track{ series = series, entries = entries })
|
||||
Assert.len(Tasks.tasks(), 0)
|
||||
st.queue_ok = true
|
||||
end
|
||||
|
||||
-- 登记:一条 passive 的 cache 任务,顶栏读到「执行中 1/1」;缓存期间不自动休眠。
|
||||
do
|
||||
reset()
|
||||
local handle = CacheTask.track{ series = series, entries = entries }
|
||||
Assert.not_nil(handle)
|
||||
local list = Tasks.tasks()
|
||||
Assert.len(list, 1, "只登记一条")
|
||||
Assert.eq(list[1].kind, "cache")
|
||||
Assert.eq(list[1].title, "测试系列")
|
||||
Assert.eq(list[1].state, "running", "passive 任务立刻启动,不排队")
|
||||
changes()
|
||||
Assert.is_true(require("pluginshare").pause_auto_suspend, "缓存期间压住自动休眠")
|
||||
end
|
||||
|
||||
-- 进度:只数本批的卷,当前卷名来自 queue.current_chapter_id。
|
||||
do
|
||||
reset()
|
||||
CacheTask.track{ series = series, entries = entries }
|
||||
st.statuses["1"] = { state = "complete" }
|
||||
st.queue = { state = "downloading", entries = { [2] = { state = "downloading" } },
|
||||
current_chapter_id = 2 }
|
||||
tick()
|
||||
local task = Tasks.tasks()[1]
|
||||
Assert.eq(task.count, 1, "已落地 1 卷")
|
||||
Assert.eq(task.total, 3, "总数是本批卷数")
|
||||
Assert.eq(task.text, "第 2 卷", "说明行写当前卷")
|
||||
|
||||
-- 不在本批的卷(别的系列)不计数。
|
||||
st.queue.entries[99] = { state = "downloading" }
|
||||
tick()
|
||||
Assert.eq(Tasks.tasks()[1].count, 1, "别的系列不算进度")
|
||||
end
|
||||
|
||||
-- 全部落地:任务结束、toast 一次、不再排下一拍。
|
||||
do
|
||||
reset()
|
||||
CacheTask.track{ series = series, entries = entries }
|
||||
for index = 1, 3 do st.statuses[tostring(index)] = { state = "complete" } end
|
||||
st.queue = { state = "idle", entries = {} }
|
||||
local toasts = #Themed.all("toast")
|
||||
tick()
|
||||
Assert.len(Tasks.tasks(), 0, "结束后离开未结束列表")
|
||||
local finished = Tasks.finished()[1]
|
||||
Assert.is_true(finished.ok, "全成算成功")
|
||||
Assert.eq(finished.total, 3)
|
||||
Assert.eq(finished.count, 3, "收尾补报最终计数(不是上一拍的 2/3)")
|
||||
Assert.is_nil(finished.text, "收尾后不再挂着上一卷的名字")
|
||||
Assert.eq(#Themed.all("toast"), toasts + 1, "只 toast 一次")
|
||||
Assert.eq(Themed.last("toast").text, "已缓存 3 卷")
|
||||
Assert.is_false(runTimer(function(delay) return delay >= 1 end), "收尾后不再轮询")
|
||||
changes()
|
||||
Assert.is_false(require("pluginshare").pause_auto_suspend, "结束放行自动休眠")
|
||||
end
|
||||
|
||||
-- 部分失败:失败项是终态(kamare 留在队列里等重试),收尾报成功 / 失败数。
|
||||
do
|
||||
reset()
|
||||
CacheTask.track{ series = series, entries = entries }
|
||||
st.statuses["1"] = { state = "complete" }
|
||||
st.statuses["2"] = { state = "complete" }
|
||||
st.queue = { state = "idle", entries = { [3] = { state = "failed", last_error = "http 403" } } }
|
||||
tick()
|
||||
local finished = Tasks.finished()[1]
|
||||
Assert.is_false(finished.ok)
|
||||
Assert.eq(finished.total, 3)
|
||||
Assert.eq(finished.count, 2, "失败的那卷不算成功")
|
||||
Assert.eq(Themed.last("toast").text, "2 卷成功,1 卷失败")
|
||||
end
|
||||
|
||||
-- 静音:页面自己的进度框负责提示时不出 toast。
|
||||
do
|
||||
reset()
|
||||
local handle = CacheTask.track{ series = series, entries = entries }
|
||||
handle.mute(true)
|
||||
for index = 1, 3 do st.statuses[tostring(index)] = { state = "complete" } end
|
||||
st.queue = { state = "idle", entries = {} }
|
||||
local toasts = #Themed.all("toast")
|
||||
tick()
|
||||
Assert.eq(#Themed.all("toast"), toasts, "静音时不提示")
|
||||
Assert.is_true(Tasks.finished()[1].ok, "任务照常收尾")
|
||||
end
|
||||
|
||||
-- 暂停:说明行给暂停原因,放行自动休眠,轮询放慢到 5 秒;恢复后继续。
|
||||
do
|
||||
reset()
|
||||
CacheTask.track{ series = series, entries = entries }
|
||||
st.statuses["1"] = { state = "complete" }
|
||||
st.queue = { state = "paused", pause_reason = "low_space",
|
||||
entries = { [2] = { state = "queued" } } }
|
||||
changes()
|
||||
tick()
|
||||
local task = Tasks.tasks()[1]
|
||||
Assert.eq(task.state, "running", "暂停只是报状态,不结束任务")
|
||||
Assert.eq(task.text, "空间不足,已暂停")
|
||||
changes()
|
||||
Assert.is_false(require("pluginshare").pause_auto_suspend, "暂停时不再撑着不睡")
|
||||
Assert.is_true(runTimer(function(delay) return delay == 5 end), "暂停时 5 秒一拍")
|
||||
|
||||
-- 恢复:下一拍回到下载说明行,重新压住休眠。
|
||||
st.queue = { state = "downloading", entries = { [2] = { state = "downloading" } },
|
||||
current_chapter_id = 2 }
|
||||
tick()
|
||||
Assert.eq(Tasks.tasks()[1].text, "第 2 卷")
|
||||
changes()
|
||||
Assert.is_true(require("pluginshare").pause_auto_suspend, "恢复后继续撑住")
|
||||
end
|
||||
|
||||
-- 队列丢了(kamare 重启 / 队列被清):连续几拍看不到本批的项就按中断收尾。
|
||||
do
|
||||
reset()
|
||||
CacheTask.track{ series = series, entries = entries }
|
||||
local toasts = #Themed.all("toast")
|
||||
for _idx = 1, 4 do
|
||||
tick()
|
||||
Assert.len(Tasks.tasks(), 1, "还没到上限,继续等")
|
||||
end
|
||||
tick()
|
||||
Assert.len(Tasks.tasks(), 0, "超时后收尾")
|
||||
local finished = Tasks.finished()[1]
|
||||
Assert.is_false(finished.ok)
|
||||
Assert.eq(#Themed.all("toast"), toasts + 1)
|
||||
Assert.eq(Themed.last("toast").text, "缓存已中断")
|
||||
end
|
||||
|
||||
-- 同一部再有卷入队 / 重试:并进同一条任务,失败项清掉终态重新观察。
|
||||
do
|
||||
reset()
|
||||
local first = CacheTask.track{ series = series, entries = { entries[1] } }
|
||||
Assert.eq(Tasks.tasks()[1].total, 1)
|
||||
st.queue = { state = "downloading", entries = { [1] = { state = "downloading" } } }
|
||||
tick()
|
||||
Assert.eq(Tasks.tasks()[1].total, 1)
|
||||
|
||||
local merged = CacheTask.track{ series = series, entries = { entries[2], entries[3] } }
|
||||
Assert.eq(merged, first, "同一部书复用同一条任务")
|
||||
Assert.len(Tasks.tasks(), 1, "不新增任务")
|
||||
Assert.eq(Tasks.tasks()[1].total, 3, "总数并进去")
|
||||
|
||||
-- 失败项重试:终态清掉,重新计入进度。
|
||||
st.statuses["1"] = { state = "complete" }
|
||||
st.queue = { state = "downloading", entries = { [2] = { state = "downloading" },
|
||||
[3] = { state = "failed" } } }
|
||||
tick()
|
||||
Assert.eq(Tasks.tasks()[1].count, 1, "失败项不算成功")
|
||||
merged.add({ entries[3] })
|
||||
st.queue = { state = "downloading", entries = { [2] = { state = "downloading" },
|
||||
[3] = { state = "downloading" } } }
|
||||
tick()
|
||||
Assert.eq(Tasks.tasks()[1].count, 1, "重试的卷回到未完成")
|
||||
st.statuses["2"] = { state = "complete" }
|
||||
st.statuses["3"] = { state = "complete" }
|
||||
st.queue = { state = "idle", entries = {} }
|
||||
tick()
|
||||
Assert.is_true(Tasks.finished()[1].ok, "重试成功后收尾")
|
||||
end
|
||||
@@ -0,0 +1,69 @@
|
||||
--[[--
|
||||
book.koplugin/source/kavita/client.lua:请求超时可配置,
|
||||
统计分页的 URL 形态与 `Pagination` 头解析。
|
||||
|
||||
慢设备 / 慢服务器上全量书架(all-v2)一次要几十秒,固定的 30s 上限会让整轮同步中断、
|
||||
书架永远加载不出来;这里锁住「默认足够宽 + 可在设置里调大 + 透传到 HTTP 层」。
|
||||
|
||||
@module tests.moonsource_kavita.client_spec
|
||||
--]]
|
||||
---@diagnostic disable: undefined-field, missing-fields, inject-field
|
||||
|
||||
local Assert = require("support.assert")
|
||||
local Config = require("support.config")
|
||||
local JsonStub = require("support.json_stub")
|
||||
|
||||
package.loaded["json"] = { encode = JsonStub.encode, decode = JsonStub.decode }
|
||||
|
||||
local captured
|
||||
package.loaded["http.request"] = {
|
||||
ok = function(code) return tonumber(code) == 200 end,
|
||||
request = function(opts, cb)
|
||||
captured = opts
|
||||
cb({ code = 200, body = "{}" })
|
||||
return { cancel = function() end }
|
||||
end,
|
||||
}
|
||||
local PLUGIN = (debug.getinfo(1, "S").source:match("^@(.-)/tests/") .. "/moonsource-kavita.koplugin/moonsource_kavita")
|
||||
package.preload["moonsource_kavita.client"] = function()
|
||||
return dofile(PLUGIN .. "/client.lua")
|
||||
end
|
||||
local Client = require("moonsource_kavita.client")
|
||||
|
||||
local function make(timeout)
|
||||
return Client.new({ base_url = "http://kav/", api_key = "k", timeout = timeout })
|
||||
end
|
||||
|
||||
Assert.eq(Client.DEFAULT_TIMEOUT, 60, "默认不再是 30s")
|
||||
Assert.eq(Client.new({ base_url = "http://kav/", api_key = "k" }).timeout, 60, "未配置用默认超时")
|
||||
Assert.eq(make("120").timeout, 120, "设置里的字符串数值也认")
|
||||
Assert.eq(make(1).timeout, 5, "过小收敛到下限")
|
||||
Assert.eq(make(0).timeout, 5, "0 收敛到下限")
|
||||
Assert.eq(make(100000).timeout, 600, "过大收敛到上限")
|
||||
|
||||
local client = make(180)
|
||||
Assert.eq(client:configured(), true)
|
||||
client:request("GET", "/api/Series/all-v2", { pageNumber = 1 }, nil, function() end)
|
||||
Assert.eq(captured.timeout, 180, "超时透传到 HTTP 请求,长拉书架不再被 30s 掐断")
|
||||
Assert.matches(captured.url, "^http://kav/api/Series/all%-v2%?")
|
||||
Assert.eq(captured.headers["x-api-key"], "k")
|
||||
|
||||
-- 统计拉取:`Libraries` 是重复键(逗号串会被服务端当成一个库,恒返回 0 条),
|
||||
-- 其余参数按名排序,PageSize 用服务端接受的上限 200。
|
||||
Assert.eq(
|
||||
client:url("/api/Stats/reading-history", {
|
||||
TimeZoneId = "Asia/Shanghai", Libraries = { 2, 1 }, PageNumber = 1, PageSize = 200,
|
||||
}),
|
||||
"http://kav/api/Stats/reading-history?Libraries=2&Libraries=1&PageNumber=1&PageSize=200&TimeZoneId=Asia%2FShanghai"
|
||||
)
|
||||
Assert.eq(client:url("/api/Image/series-cover", { seriesId = "10" }),
|
||||
"http://kav/api/Image/series-cover?seriesId=10", "单值参数与 formEncode 同形")
|
||||
|
||||
-- 分页头(挂在响应上,不在 body 里):只认 totalPages。
|
||||
Assert.eq(Client.totalPages('{"currentPage":1,"itemsPerPage":200,"totalItems":316,"totalPages":2}'), 2)
|
||||
Assert.eq(Client.totalPages('{"totalPages":0}'), 0, "0 页 = 没有数据,读成 nil 会让调用方按「本页拉满」再拉一页")
|
||||
Assert.is_nil(Client.totalPages('{"currentPage":1}'), "没有 totalPages 就当不可信,调用方走兜底")
|
||||
Assert.is_nil(Client.totalPages('{"totalPages":-1}'), "负数不可信")
|
||||
Assert.is_nil(Client.totalPages(nil))
|
||||
Assert.is_nil(Client.totalPages(""))
|
||||
Assert.is_nil(Client.totalPages("<html>oops</html>"), "反代错误页不能当分页头")
|
||||
@@ -0,0 +1,133 @@
|
||||
--[[--
|
||||
卷列表 / 系列页共用的续读目标:主线 = 最远有进度的卷,回顾旧卷只标「上次翻阅」。
|
||||
|
||||
@module tests.moonsource_kavita.continue_point_spec
|
||||
--]]
|
||||
---@diagnostic disable: undefined-field, missing-fields, inject-field
|
||||
|
||||
local Assert = require("support.assert")
|
||||
local Config = require("support.config")
|
||||
|
||||
local CP = dofile((debug.getinfo(1, "S").source:match("^@(.-)/tests/") .. "/moonsource-kavita.koplugin/moonsource_kavita") .. "/continue_point.lua")
|
||||
|
||||
local function vol(chapter_id, title, pages, pages_read)
|
||||
return {
|
||||
idx = chapter_id, chapterId = chapter_id, title = title,
|
||||
pages = pages, pagesRead = pages_read or 0,
|
||||
}
|
||||
end
|
||||
|
||||
local toc = {
|
||||
vol(101, "第 1 卷", 100, 100),
|
||||
vol(102, "第 2 卷", 100, 40),
|
||||
vol(103, "第 3 卷", 100, 0),
|
||||
vol(104, "第 4 卷", 100, 0),
|
||||
}
|
||||
|
||||
-- 未开始
|
||||
local fresh = CP.pick({
|
||||
vol(101, "第 1 卷", 100, 0),
|
||||
vol(102, "第 2 卷", 100, 0),
|
||||
}, {})
|
||||
Assert.eq(fresh.kind, "fresh")
|
||||
Assert.eq(fresh.entry.chapterId, 101)
|
||||
Assert.eq(fresh.page, 0)
|
||||
local fresh_text, fresh_caption = CP.describe(fresh, "系列")
|
||||
Assert.eq(fresh_text, "开始阅读 · 第 1 卷")
|
||||
Assert.eq(fresh_caption, "共 100 页")
|
||||
|
||||
-- 读到第 2 卷一半:主线是第 2 卷
|
||||
local mid = CP.pick(toc, {})
|
||||
Assert.eq(mid.kind, "continue")
|
||||
Assert.eq(mid.entry.chapterId, 102)
|
||||
Assert.eq(mid.fraction, 0.4)
|
||||
Assert.eq(mid.page, 40)
|
||||
Assert.eq(mid.total_pages, 100)
|
||||
local mid_text, mid_caption = CP.describe(mid, "系列")
|
||||
Assert.eq(mid_text, "继续阅读 · 第 2 卷")
|
||||
Assert.eq(mid_caption, "第 40/100 页 · 40%")
|
||||
Assert.is_nil(mid.browsed)
|
||||
|
||||
-- 第 2 卷读完:顺延第 3 卷
|
||||
local rolled = CP.pick({
|
||||
vol(101, "第 1 卷", 100, 100),
|
||||
vol(102, "第 2 卷", 100, 100),
|
||||
vol(103, "第 3 卷", 100, 0),
|
||||
}, {})
|
||||
Assert.eq(rolled.entry.chapterId, 103)
|
||||
Assert.eq(rolled.kind, "continue")
|
||||
Assert.eq(rolled.page, 0)
|
||||
|
||||
-- 全部读完:回到第 1 卷,kind = done
|
||||
local done = CP.pick({
|
||||
vol(101, "第 1 卷", 100, 100),
|
||||
vol(102, "第 2 卷", 100, 100),
|
||||
}, {})
|
||||
Assert.eq(done.kind, "done")
|
||||
Assert.eq(done.entry.chapterId, 101)
|
||||
|
||||
-- 读到第 4 卷、回头翻第 1 卷:主线不动,第 1 卷只作「上次翻阅」
|
||||
local updated = { [101] = 300, [104] = 200 }
|
||||
local review = CP.pick({
|
||||
vol(101, "第 1 卷", 100, 100),
|
||||
vol(102, "第 2 卷", 100, 100),
|
||||
vol(103, "第 3 卷", 100, 100),
|
||||
vol(104, "第 4 卷", 100, 50),
|
||||
}, {
|
||||
updated_at = function(e) return updated[e.chapterId] end,
|
||||
})
|
||||
Assert.eq(review.entry.chapterId, 104, "主线仍是最远的第 4 卷")
|
||||
Assert.eq(review.browsed.chapterId, 101, "上次翻阅单独返回")
|
||||
|
||||
-- 上次翻阅 == 主线:不返回标记
|
||||
local same = CP.pick(toc, { updated_at = function(e) return e.chapterId == 102 and 500 or 0 end })
|
||||
Assert.is_nil(same.browsed)
|
||||
|
||||
-- 注入 fraction / page(本地 ProgressDB 比 toc 快照新)
|
||||
local local_better = CP.pick(toc, {
|
||||
fraction = function(e) return e.chapterId == 102 and 0.9 or nil end,
|
||||
page = function(e)
|
||||
if e.chapterId == 102 then return { page = 90, total = 100 } end
|
||||
end,
|
||||
})
|
||||
Assert.eq(local_better.fraction, 0.9)
|
||||
Assert.eq(local_better.page, 90)
|
||||
|
||||
-- pages == 0 的卷不参与
|
||||
local zero = CP.pick({
|
||||
vol(101, "第 1 卷", 0, 0),
|
||||
vol(102, "第 2 卷", 100, 10),
|
||||
}, {})
|
||||
Assert.eq(zero.entry.chapterId, 102)
|
||||
|
||||
-- 空目录
|
||||
Assert.is_nil(CP.pick({}, {}))
|
||||
Assert.is_nil(CP.pick(nil, nil))
|
||||
|
||||
-- 服务端已读完、本机重新打开留下 1%:仍按已读完处理,主线顺延下一卷。
|
||||
local reread = CP.pick({
|
||||
vol(101, "第 1 卷", 100, 100),
|
||||
vol(102, "第 2 卷", 100, 100),
|
||||
vol(103, "第 3 卷", 100, 0),
|
||||
}, { fraction = function(e) return e.chapterId == 102 and 0.01 or nil end })
|
||||
Assert.eq(reread.entry.chapterId, 103, "已读完的卷不会被本机低进度拖回主线")
|
||||
Assert.eq(reread.kind, "continue")
|
||||
|
||||
|
||||
-- 调用方说已读完(kamare 三源)时同样按 fraction 1,不再被本机低进度拖回。
|
||||
local by_caller = CP.pick({
|
||||
vol(101, "第 1 卷", 100, 0),
|
||||
vol(102, "第 2 卷", 100, 0),
|
||||
}, {
|
||||
fraction = function(e) return e.chapterId == 101 and 0.01 or nil end,
|
||||
complete = function(e) return e.chapterId == 101 end,
|
||||
})
|
||||
Assert.eq(by_caller.entry.chapterId, 102, "调用方标记已读完的卷不会成为主线")
|
||||
|
||||
|
||||
-- 卷名:优先标题;空 / 退化成系列名时兜底第 N 卷
|
||||
Assert.eq(CP.label({ idx = 3, title = "ONE PIECE (3)" }, "航海王"), "ONE PIECE (3)")
|
||||
Assert.eq(CP.label({ idx = 3, title = "" }, "航海王"), "第 3 卷")
|
||||
Assert.eq(CP.label({ idx = 3, title = "航海王" }, "航海王"), "第 3 卷")
|
||||
Assert.eq(CP.label({ idx = 3 }, "航海王"), "第 3 卷")
|
||||
Assert.eq(CP.label(nil, "航海王"), "?")
|
||||
@@ -0,0 +1,140 @@
|
||||
--[[--
|
||||
样本 fixture:`GET /api/Stats/reading-history/series/7453` 实测响应(2026-10-16,Kavita 0.9.1.4)
|
||||
的精简版,只留聚合用到的字段(seriesId / localDate / startTimeUtc / chapters[])。
|
||||
|
||||
对账基线(research-kavita-stats-pull.md §3):64 条会话 / 14,237s;逐日见 stats_spec 用例。
|
||||
来源完整响应:/tmp/opencode/kavita/live/history-7453-all.json(提交时精简,数值逐条未改)。
|
||||
|
||||
@module tests.extensions.kavita.fixtures.history_7453
|
||||
--]]
|
||||
return {
|
||||
{ seriesId = 7453, localDate = "2026-10-15T00:00:00", startTimeUtc = "2026-10-15T13:49:02.6722926", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-15T13:49:02.6722926", durationSeconds = 845, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-15T00:00:00", startTimeUtc = "2026-10-15T11:51:10.7006183", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-15T11:51:10.7006183", durationSeconds = 638, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-15T00:00:00", startTimeUtc = "2026-10-15T11:14:33.5066159", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-15T11:14:33.5066159", durationSeconds = 436, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-15T00:00:00", startTimeUtc = "2026-10-15T08:01:09.6078347", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-15T08:01:09.6078347", durationSeconds = 33, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-15T00:00:00", startTimeUtc = "2026-10-15T07:20:02.0863122", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-15T07:20:02.0863122", durationSeconds = 156, pagesRead = 15 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-15T00:00:00", startTimeUtc = "2026-10-15T04:38:27.7268649", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-15T04:38:27.7268649", durationSeconds = 462, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-15T00:00:00", startTimeUtc = "2026-10-15T03:25:22.1307379", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-15T03:25:22.1307379", durationSeconds = 266, pagesRead = 1 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-15T00:00:00", startTimeUtc = "2026-10-15T02:59:07.9600274", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-15T02:59:07.9600274", durationSeconds = 126, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-14T00:00:00", startTimeUtc = "2026-10-14T14:50:29.2326588", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-14T14:50:29.2326588", durationSeconds = 329, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-14T00:00:00", startTimeUtc = "2026-10-14T13:55:48.5704762", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-14T13:55:48.5704762", durationSeconds = 716, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-14T00:00:00", startTimeUtc = "2026-10-14T12:59:54.4012612", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-14T12:59:54.4012612", durationSeconds = 210, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-14T00:00:00", startTimeUtc = "2026-10-14T12:32:09.2873459", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-14T12:32:09.2873459", durationSeconds = 354, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-14T00:00:00", startTimeUtc = "2026-10-14T10:50:12.8325335", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-14T10:50:12.8325335", durationSeconds = 427, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-14T00:00:00", startTimeUtc = "2026-10-14T09:55:45.2531997", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-14T09:55:45.2531997", durationSeconds = 229, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-14T00:00:00", startTimeUtc = "2026-10-14T08:18:25.5482677", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-14T08:18:25.5482677", durationSeconds = 631, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-14T00:00:00", startTimeUtc = "2026-10-14T06:35:44.8950968", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-14T06:56:37.9521487", durationSeconds = 597, pagesRead = 5 },
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-14T06:35:44.8950968", durationSeconds = 529, pagesRead = -6 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-14T00:00:00", startTimeUtc = "2026-10-14T06:12:27.3026502", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-14T06:12:27.3026502", durationSeconds = 686, pagesRead = 1 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-14T00:00:00", startTimeUtc = "2026-10-14T05:35:38.8926445", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-14T05:35:38.8926445", durationSeconds = 674, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-14T00:00:00", startTimeUtc = "2026-10-14T03:36:59.7411875", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-14T03:36:59.7411875", durationSeconds = 1352, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-14T00:00:00", startTimeUtc = "2026-10-14T01:39:31.4453653", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-14T01:39:31.4453653", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-13T00:00:00", startTimeUtc = "2026-10-13T14:56:50.7578846", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-13T14:56:50.7578846", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-13T00:00:00", startTimeUtc = "2026-10-13T12:50:13.6195947", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-13T12:50:13.6195947", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-13T00:00:00", startTimeUtc = "2026-10-13T10:49:24.2700176", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-13T10:49:24.2700176", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-13T00:00:00", startTimeUtc = "2026-10-13T09:19:44.4142404", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-13T09:19:44.4142404", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-13T00:00:00", startTimeUtc = "2026-10-13T07:17:51.0855549", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-13T07:17:51.0855549", durationSeconds = 31, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-13T00:00:00", startTimeUtc = "2026-10-13T06:23:56.2429684", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-13T06:23:56.2429684", durationSeconds = 948, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-13T00:00:00", startTimeUtc = "2026-10-13T04:44:11.1456271", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-13T04:44:11.1456271", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-13T00:00:00", startTimeUtc = "2026-10-13T04:04:52.1419963", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-13T04:04:52.1419963", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-12T00:00:00", startTimeUtc = "2026-10-12T03:52:47.3926019", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-12T03:52:47.3926019", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-11T00:00:00", startTimeUtc = "2026-10-11T15:16:45.9848037", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-11T15:16:45.9848037", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-11T00:00:00", startTimeUtc = "2026-10-11T14:54:13.613368", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-11T14:54:13.613368", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-11T00:00:00", startTimeUtc = "2026-10-11T14:35:43.0809755", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-11T14:35:43.0809755", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-11T00:00:00", startTimeUtc = "2026-10-11T12:58:29.291105", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-11T12:58:29.291105", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-11T00:00:00", startTimeUtc = "2026-10-11T11:00:42.6215043", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-11T11:00:42.6215043", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-11T00:00:00", startTimeUtc = "2026-10-11T04:17:28.3592015", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-11T04:17:28.3592015", durationSeconds = 512, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-10T00:00:00", startTimeUtc = "2026-10-10T04:44:42.7023417", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-10T04:44:42.7023417", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-10T00:00:00", startTimeUtc = "2026-10-10T03:55:35.74839", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-10T03:55:35.74839", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-10T00:00:00", startTimeUtc = "2026-10-10T03:39:55.2030981", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-10T03:39:55.2030981", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-09T00:00:00", startTimeUtc = "2026-10-09T14:45:39.0731175", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-09T14:45:39.0731175", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-09T00:00:00", startTimeUtc = "2026-10-09T07:44:06.636679", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-09T07:44:06.636679", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-09T00:00:00", startTimeUtc = "2026-10-09T07:13:20.7857153", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-09T07:13:20.7857153", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-09T00:00:00", startTimeUtc = "2026-10-09T04:40:28.7189645", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-09T04:40:28.7189645", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-09T00:00:00", startTimeUtc = "2026-10-09T04:05:17.6951039", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-09T04:05:17.6951039", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-08T00:00:00", startTimeUtc = "2026-10-08T14:34:05.7981443", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-08T14:34:05.7981443", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-08T00:00:00", startTimeUtc = "2026-10-08T13:12:53.6969824", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-08T13:12:53.6969824", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-08T00:00:00", startTimeUtc = "2026-10-08T11:48:06.6315963", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-08T11:48:06.6315963", durationSeconds = 544, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-08T00:00:00", startTimeUtc = "2026-10-08T11:02:33.6484158", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-08T11:02:33.6484158", durationSeconds = 611, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-08T00:00:00", startTimeUtc = "2026-10-08T10:31:08.475182", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-08T10:31:08.475182", durationSeconds = 3, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-08T00:00:00", startTimeUtc = "2026-10-08T09:03:45.5309711", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-08T09:03:45.5309711", durationSeconds = 86, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-08T00:00:00", startTimeUtc = "2026-10-08T07:59:09.2881628", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-08T07:59:09.2881628", durationSeconds = 263, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-08T00:00:00", startTimeUtc = "2026-10-08T07:20:18.0105615", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-08T07:20:18.0105615", durationSeconds = 233, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-08T00:00:00", startTimeUtc = "2026-10-08T06:48:51.312417", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-08T06:48:51.312417", durationSeconds = 296, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-08T00:00:00", startTimeUtc = "2026-10-08T04:05:45.0300961", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-08T04:05:45.0300961", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-07T00:00:00", startTimeUtc = "2026-10-07T13:44:15.125016", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-07T13:44:15.125016", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-07T00:00:00", startTimeUtc = "2026-10-07T09:45:01.0814021", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-07T09:45:01.0814021", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-07T00:00:00", startTimeUtc = "2026-10-07T05:19:38.9892914", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-07T05:19:38.9892914", durationSeconds = 503, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-06T00:00:00", startTimeUtc = "2026-10-06T12:01:31.4949015", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-06T12:01:31.4949015", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-06T00:00:00", startTimeUtc = "2026-10-06T11:37:48.0185472", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-06T11:37:48.0185472", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-06T00:00:00", startTimeUtc = "2026-10-06T03:21:10.9150125", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-06T03:21:10.9150125", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-06T00:00:00", startTimeUtc = "2026-10-06T02:50:29.5547188", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-06T02:50:29.5547188", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-05T00:00:00", startTimeUtc = "2026-10-05T14:10:59.8916334", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-05T14:10:59.8916334", durationSeconds = 195, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-05T00:00:00", startTimeUtc = "2026-10-05T12:18:33.1689018", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-05T12:18:33.1689018", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-09-29T00:00:00", startTimeUtc = "2026-09-29T10:25:25.4088288", chapters = {
|
||||
{ chapterId = 11271, startTimeUtc = "2026-09-29T10:25:25.4088288", durationSeconds = 86, pagesRead = 2 } } },
|
||||
{ seriesId = 7453, localDate = "2026-09-29T00:00:00", startTimeUtc = "2026-09-29T10:01:44.7835505", chapters = {
|
||||
{ chapterId = 11271, startTimeUtc = "2026-09-29T10:01:44.7835505", durationSeconds = 230, pagesRead = 0 } } },
|
||||
}
|
||||
@@ -0,0 +1,657 @@
|
||||
--[[--
|
||||
样本 fixture:`GET /api/Stats/reading-history` 全量实测响应(2026-10-16,Kavita 0.9.1.4)的
|
||||
精简版,只留聚合用到的字段(seriesId / localDate / startTimeUtc / chapters[]),共 316 条会话 /
|
||||
60 个系列 / 2 页。
|
||||
|
||||
数值逐条未改;对账基线 = research-kavita-stats-pull.md §2(逐日时长 / 页数)与 §4(Σ=60,238s /
|
||||
1,406 页 / 起点 2026-09-18)。来源完整响应:/tmp/opencode/kavita/live/history-all-sep-oct.json。
|
||||
|
||||
@module tests.extensions.kavita.fixtures.history_all
|
||||
--]]
|
||||
return {
|
||||
{ seriesId = 7606, localDate = "2026-10-16T00:00:00", startTimeUtc = "2026-10-15T23:51:47.4527045", chapters = {
|
||||
{ chapterId = 11501, startTimeUtc = "2026-10-15T23:51:47.4527045", durationSeconds = 220, pagesRead = 6 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-15T00:00:00", startTimeUtc = "2026-10-15T13:49:02.6722926", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-15T13:49:02.6722926", durationSeconds = 845, pagesRead = 0 } } },
|
||||
{ seriesId = 7606, localDate = "2026-10-15T00:00:00", startTimeUtc = "2026-10-15T13:41:03.9585123", chapters = {
|
||||
{ chapterId = 11501, startTimeUtc = "2026-10-15T13:41:03.9585123", durationSeconds = 469, pagesRead = 6 } } },
|
||||
{ seriesId = 7606, localDate = "2026-10-15T00:00:00", startTimeUtc = "2026-10-15T12:18:53.1535569", chapters = {
|
||||
{ chapterId = 11501, startTimeUtc = "2026-10-15T12:18:53.1535569", durationSeconds = 163, pagesRead = 7 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-15T00:00:00", startTimeUtc = "2026-10-15T11:51:10.7006183", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-15T11:51:10.7006183", durationSeconds = 638, pagesRead = 0 } } },
|
||||
{ seriesId = 9249, localDate = "2026-10-15T00:00:00", startTimeUtc = "2026-10-15T11:40:49.4449693", chapters = {
|
||||
{ chapterId = 13493, startTimeUtc = "2026-10-15T11:40:49.4449693", durationSeconds = 335, pagesRead = 1 } } },
|
||||
{ seriesId = 10634, localDate = "2026-10-15T00:00:00", startTimeUtc = "2026-10-15T11:35:04.1639136", chapters = {
|
||||
{ chapterId = 17863, startTimeUtc = "2026-10-15T11:38:58.0370869", durationSeconds = 81, pagesRead = 15 },
|
||||
{ chapterId = 17868, startTimeUtc = "2026-10-15T11:35:04.1639136", durationSeconds = 210, pagesRead = 29 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-15T00:00:00", startTimeUtc = "2026-10-15T11:14:33.5066159", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-15T11:14:33.5066159", durationSeconds = 436, pagesRead = 0 } } },
|
||||
{ seriesId = 10634, localDate = "2026-10-15T00:00:00", startTimeUtc = "2026-10-15T11:04:40.7474367", chapters = {
|
||||
{ chapterId = 17868, startTimeUtc = "2026-10-15T11:04:40.7474367", durationSeconds = 321, pagesRead = 44 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-15T00:00:00", startTimeUtc = "2026-10-15T08:01:09.6078347", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-15T08:01:09.6078347", durationSeconds = 33, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-15T00:00:00", startTimeUtc = "2026-10-15T07:20:02.0863122", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-15T07:20:02.0863122", durationSeconds = 156, pagesRead = 15 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-15T00:00:00", startTimeUtc = "2026-10-15T04:38:27.7268649", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-15T04:38:27.7268649", durationSeconds = 462, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-15T00:00:00", startTimeUtc = "2026-10-15T03:25:22.1307379", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-15T03:25:22.1307379", durationSeconds = 266, pagesRead = 1 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-15T00:00:00", startTimeUtc = "2026-10-15T02:59:07.9600274", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-15T02:59:07.9600274", durationSeconds = 126, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-14T00:00:00", startTimeUtc = "2026-10-14T14:50:29.2326588", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-14T14:50:29.2326588", durationSeconds = 329, pagesRead = 0 } } },
|
||||
{ seriesId = 10634, localDate = "2026-10-14T00:00:00", startTimeUtc = "2026-10-14T14:38:39.3797696", chapters = {
|
||||
{ chapterId = 17868, startTimeUtc = "2026-10-14T14:38:39.3797696", durationSeconds = 481, pagesRead = 32 } } },
|
||||
{ seriesId = 10634, localDate = "2026-10-14T00:00:00", startTimeUtc = "2026-10-14T14:08:54.1661113", chapters = {
|
||||
{ chapterId = 17868, startTimeUtc = "2026-10-14T14:08:54.1661113", durationSeconds = 309, pagesRead = 27 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-14T00:00:00", startTimeUtc = "2026-10-14T13:55:48.5704762", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-14T13:55:48.5704762", durationSeconds = 716, pagesRead = 0 } } },
|
||||
{ seriesId = 9249, localDate = "2026-10-14T00:00:00", startTimeUtc = "2026-10-14T13:49:23.172248", chapters = {
|
||||
{ chapterId = 13493, startTimeUtc = "2026-10-14T13:49:23.172248", durationSeconds = 305, pagesRead = 6 } } },
|
||||
{ seriesId = 10634, localDate = "2026-10-14T00:00:00", startTimeUtc = "2026-10-14T13:03:43.5815681", chapters = {
|
||||
{ chapterId = 17868, startTimeUtc = "2026-10-14T13:03:43.5815681", durationSeconds = 22, pagesRead = 3 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-14T00:00:00", startTimeUtc = "2026-10-14T12:59:54.4012612", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-14T12:59:54.4012612", durationSeconds = 210, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-14T00:00:00", startTimeUtc = "2026-10-14T12:32:09.2873459", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-14T12:32:09.2873459", durationSeconds = 354, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-14T00:00:00", startTimeUtc = "2026-10-14T10:50:12.8325335", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-14T10:50:12.8325335", durationSeconds = 427, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-14T00:00:00", startTimeUtc = "2026-10-14T09:55:45.2531997", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-14T09:55:45.2531997", durationSeconds = 229, pagesRead = 0 } } },
|
||||
{ seriesId = 7460, localDate = "2026-10-14T00:00:00", startTimeUtc = "2026-10-14T09:17:05.53145", chapters = {
|
||||
{ chapterId = 11285, startTimeUtc = "2026-10-14T09:17:05.53145", durationSeconds = 433, pagesRead = 0 } } },
|
||||
{ seriesId = 7606, localDate = "2026-10-14T00:00:00", startTimeUtc = "2026-10-14T09:13:54.1770611", chapters = {
|
||||
{ chapterId = 11501, startTimeUtc = "2026-10-14T09:13:54.1770611", durationSeconds = 141, pagesRead = 3 } } },
|
||||
{ seriesId = 7606, localDate = "2026-10-14T00:00:00", startTimeUtc = "2026-10-14T08:31:01.497007", chapters = {
|
||||
{ chapterId = 11501, startTimeUtc = "2026-10-14T08:31:01.497007", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-14T00:00:00", startTimeUtc = "2026-10-14T08:18:25.5482677", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-14T08:18:25.5482677", durationSeconds = 631, pagesRead = 0 } } },
|
||||
{ seriesId = 7540, localDate = "2026-10-14T00:00:00", startTimeUtc = "2026-10-14T07:55:05.3240629", chapters = {
|
||||
{ chapterId = 13394, startTimeUtc = "2026-10-14T07:55:05.3240629", durationSeconds = 82, pagesRead = 0 } } },
|
||||
{ seriesId = 10705, localDate = "2026-10-14T00:00:00", startTimeUtc = "2026-10-14T07:38:45.2095335", chapters = {
|
||||
{ chapterId = 18930, startTimeUtc = "2026-10-14T07:38:45.2095335", durationSeconds = 206, pagesRead = 3 } } },
|
||||
{ seriesId = 7540, localDate = "2026-10-14T00:00:00", startTimeUtc = "2026-10-14T07:34:26.9247375", chapters = {
|
||||
{ chapterId = 13394, startTimeUtc = "2026-10-14T07:34:26.9247375", durationSeconds = 83, pagesRead = 5 } } },
|
||||
{ seriesId = 10720, localDate = "2026-10-14T00:00:00", startTimeUtc = "2026-10-14T07:16:16.0691328", chapters = {
|
||||
{ chapterId = 18951, startTimeUtc = "2026-10-14T07:16:16.0691328", durationSeconds = 72, pagesRead = 10 } } },
|
||||
{ seriesId = 8661, localDate = "2026-10-14T00:00:00", startTimeUtc = "2026-10-14T07:14:59.4980606", chapters = {
|
||||
{ chapterId = 12763, startTimeUtc = "2026-10-14T07:14:59.4980606", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7805, localDate = "2026-10-14T00:00:00", startTimeUtc = "2026-10-14T07:14:45.0436933", chapters = {
|
||||
{ chapterId = 11791, startTimeUtc = "2026-10-14T07:14:45.0436933", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7540, localDate = "2026-10-14T00:00:00", startTimeUtc = "2026-10-14T07:14:08.0963104", chapters = {
|
||||
{ chapterId = 13394, startTimeUtc = "2026-10-14T07:14:08.0963104", durationSeconds = 71, pagesRead = 2 } } },
|
||||
{ seriesId = 7606, localDate = "2026-10-14T00:00:00", startTimeUtc = "2026-10-14T06:46:46.3439122", chapters = {
|
||||
{ chapterId = 11501, startTimeUtc = "2026-10-14T07:07:38.102712", durationSeconds = 0, pagesRead = 0 },
|
||||
{ chapterId = 11501, startTimeUtc = "2026-10-14T06:46:46.3439122", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7460, localDate = "2026-10-14T00:00:00", startTimeUtc = "2026-10-14T06:54:53.1919748", chapters = {
|
||||
{ chapterId = 11285, startTimeUtc = "2026-10-14T07:06:44.0374852", durationSeconds = 21, pagesRead = 24 },
|
||||
{ chapterId = 11285, startTimeUtc = "2026-10-14T06:54:53.1919748", durationSeconds = 48, pagesRead = 1 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-14T00:00:00", startTimeUtc = "2026-10-14T06:35:44.8950968", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-14T06:56:37.9521487", durationSeconds = 597, pagesRead = 5 },
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-14T06:35:44.8950968", durationSeconds = 529, pagesRead = -6 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-14T00:00:00", startTimeUtc = "2026-10-14T06:12:27.3026502", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-14T06:12:27.3026502", durationSeconds = 686, pagesRead = 1 } } },
|
||||
{ seriesId = 7460, localDate = "2026-10-14T00:00:00", startTimeUtc = "2026-10-14T06:02:06.7713486", chapters = {
|
||||
{ chapterId = 11285, startTimeUtc = "2026-10-14T06:02:06.7713486", durationSeconds = 647, pagesRead = 0 } } },
|
||||
{ seriesId = 7460, localDate = "2026-10-14T00:00:00", startTimeUtc = "2026-10-14T05:48:30.213286", chapters = {
|
||||
{ chapterId = 11285, startTimeUtc = "2026-10-14T05:48:30.213286", durationSeconds = 113, pagesRead = 1 } } },
|
||||
{ seriesId = 7606, localDate = "2026-10-14T00:00:00", startTimeUtc = "2026-10-14T05:47:30.9663527", chapters = {
|
||||
{ chapterId = 11501, startTimeUtc = "2026-10-14T05:47:30.9663527", durationSeconds = 40, pagesRead = 3 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-14T00:00:00", startTimeUtc = "2026-10-14T05:35:38.8926445", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-14T05:35:38.8926445", durationSeconds = 674, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-14T00:00:00", startTimeUtc = "2026-10-14T03:36:59.7411875", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-14T03:36:59.7411875", durationSeconds = 1352, pagesRead = 0 } } },
|
||||
{ seriesId = 7460, localDate = "2026-10-14T00:00:00", startTimeUtc = "2026-10-14T03:28:46.1491425", chapters = {
|
||||
{ chapterId = 11285, startTimeUtc = "2026-10-14T03:28:46.1491425", durationSeconds = 794, pagesRead = -1 } } },
|
||||
{ seriesId = 7606, localDate = "2026-10-14T00:00:00", startTimeUtc = "2026-10-14T03:16:21.8058422", chapters = {
|
||||
{ chapterId = 11501, startTimeUtc = "2026-10-14T03:16:21.8058422", durationSeconds = 1063, pagesRead = 1 } } },
|
||||
{ seriesId = 7606, localDate = "2026-10-14T00:00:00", startTimeUtc = "2026-10-14T01:55:37.5163534", chapters = {
|
||||
{ chapterId = 11501, startTimeUtc = "2026-10-14T01:55:37.5163534", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 10004, localDate = "2026-10-14T00:00:00", startTimeUtc = "2026-10-14T01:49:18.2803981", chapters = {
|
||||
{ chapterId = 14594, startTimeUtc = "2026-10-14T01:49:18.2803981", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-14T00:00:00", startTimeUtc = "2026-10-14T01:39:31.4453653", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-14T01:39:31.4453653", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 10634, localDate = "2026-10-13T00:00:00", startTimeUtc = "2026-10-13T14:57:39.6850524", chapters = {
|
||||
{ chapterId = 17868, startTimeUtc = "2026-10-13T14:57:39.6850524", durationSeconds = 296, pagesRead = 43 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-13T00:00:00", startTimeUtc = "2026-10-13T14:56:50.7578846", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-13T14:56:50.7578846", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 10634, localDate = "2026-10-13T00:00:00", startTimeUtc = "2026-10-13T14:36:12.2101045", chapters = {
|
||||
{ chapterId = 17868, startTimeUtc = "2026-10-13T14:42:41.461277", durationSeconds = 73, pagesRead = 17 },
|
||||
{ chapterId = 17861, startTimeUtc = "2026-10-13T14:36:12.2101045", durationSeconds = 382, pagesRead = 50 } } },
|
||||
{ seriesId = 10634, localDate = "2026-10-13T00:00:00", startTimeUtc = "2026-10-13T13:30:56.9584871", chapters = {
|
||||
{ chapterId = 17861, startTimeUtc = "2026-10-13T13:30:56.9584871", durationSeconds = 965, pagesRead = 35 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-13T00:00:00", startTimeUtc = "2026-10-13T12:50:13.6195947", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-13T12:50:13.6195947", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 10634, localDate = "2026-10-13T00:00:00", startTimeUtc = "2026-10-13T11:07:48.1054905", chapters = {
|
||||
{ chapterId = 17861, startTimeUtc = "2026-10-13T11:07:48.1054905", durationSeconds = 1557, pagesRead = 87 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-13T00:00:00", startTimeUtc = "2026-10-13T10:49:24.2700176", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-13T10:49:24.2700176", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 10634, localDate = "2026-10-13T00:00:00", startTimeUtc = "2026-10-13T10:33:26.9620773", chapters = {
|
||||
{ chapterId = 17861, startTimeUtc = "2026-10-13T10:33:26.9620773", durationSeconds = 85, pagesRead = 9 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-13T00:00:00", startTimeUtc = "2026-10-13T09:19:44.4142404", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-13T09:19:44.4142404", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7606, localDate = "2026-10-13T00:00:00", startTimeUtc = "2026-10-13T08:41:22.7503239", chapters = {
|
||||
{ chapterId = 11501, startTimeUtc = "2026-10-13T08:41:22.7503239", durationSeconds = 177, pagesRead = 3 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-13T00:00:00", startTimeUtc = "2026-10-13T07:17:51.0855549", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-13T07:17:51.0855549", durationSeconds = 31, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-13T00:00:00", startTimeUtc = "2026-10-13T06:23:56.2429684", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-13T06:23:56.2429684", durationSeconds = 948, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-13T00:00:00", startTimeUtc = "2026-10-13T04:44:11.1456271", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-13T04:44:11.1456271", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-13T00:00:00", startTimeUtc = "2026-10-13T04:04:52.1419963", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-13T04:04:52.1419963", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 10634, localDate = "2026-10-12T00:00:00", startTimeUtc = "2026-10-12T13:41:25.4902953", chapters = {
|
||||
{ chapterId = 17861, startTimeUtc = "2026-10-12T13:41:25.4902953", durationSeconds = 77, pagesRead = 5 } } },
|
||||
{ seriesId = 10634, localDate = "2026-10-12T00:00:00", startTimeUtc = "2026-10-12T04:30:51.522376", chapters = {
|
||||
{ chapterId = 17861, startTimeUtc = "2026-10-12T04:30:51.522376", durationSeconds = 26, pagesRead = 4 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-12T00:00:00", startTimeUtc = "2026-10-12T03:52:47.3926019", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-12T03:52:47.3926019", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 10634, localDate = "2026-10-12T00:00:00", startTimeUtc = "2026-10-12T02:50:17.2681685", chapters = {
|
||||
{ chapterId = 17861, startTimeUtc = "2026-10-12T02:59:07.2940778", durationSeconds = 505, pagesRead = 5 },
|
||||
{ chapterId = 17855, startTimeUtc = "2026-10-12T02:50:17.2681685", durationSeconds = 518, pagesRead = 12 } } },
|
||||
{ seriesId = 10634, localDate = "2026-10-12T00:00:00", startTimeUtc = "2026-10-12T02:26:17.4191481", chapters = {
|
||||
{ chapterId = 17855, startTimeUtc = "2026-10-12T02:26:17.4191481", durationSeconds = 332, pagesRead = 27 } } },
|
||||
{ seriesId = 10600, localDate = "2026-10-12T00:00:00", startTimeUtc = "2026-10-11T16:06:22.9336343", chapters = {
|
||||
{ chapterId = 17139, startTimeUtc = "2026-10-11T16:06:22.9336343", durationSeconds = 34, pagesRead = 11 } } },
|
||||
{ seriesId = 10634, localDate = "2026-10-12T00:00:00", startTimeUtc = "2026-10-11T16:00:00.7226412", chapters = {
|
||||
{ chapterId = 17855, startTimeUtc = "2026-10-11T16:00:00.7226412", durationSeconds = 311, pagesRead = 39 } } },
|
||||
{ seriesId = 10634, localDate = "2026-10-11T00:00:00", startTimeUtc = "2026-10-11T15:54:42.9913657", chapters = {
|
||||
{ chapterId = 17855, startTimeUtc = "2026-10-11T15:54:42.9913657", durationSeconds = 137, pagesRead = 26 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-11T00:00:00", startTimeUtc = "2026-10-11T15:16:45.9848037", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-11T15:16:45.9848037", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-11T00:00:00", startTimeUtc = "2026-10-11T14:54:13.613368", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-11T14:54:13.613368", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-11T00:00:00", startTimeUtc = "2026-10-11T14:35:43.0809755", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-11T14:35:43.0809755", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-11T00:00:00", startTimeUtc = "2026-10-11T12:58:29.291105", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-11T12:58:29.291105", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-11T00:00:00", startTimeUtc = "2026-10-11T11:00:42.6215043", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-11T11:00:42.6215043", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-11T00:00:00", startTimeUtc = "2026-10-11T04:17:28.3592015", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-11T04:17:28.3592015", durationSeconds = 512, pagesRead = 0 } } },
|
||||
{ seriesId = 7606, localDate = "2026-10-11T00:00:00", startTimeUtc = "2026-10-11T02:53:45.4676925", chapters = {
|
||||
{ chapterId = 11501, startTimeUtc = "2026-10-11T02:53:45.4676925", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 9249, localDate = "2026-10-10T00:00:00", startTimeUtc = "2026-10-10T15:00:59.375396", chapters = {
|
||||
{ chapterId = 13493, startTimeUtc = "2026-10-10T15:00:59.375396", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 9249, localDate = "2026-10-10T00:00:00", startTimeUtc = "2026-10-10T09:37:25.4148239", chapters = {
|
||||
{ chapterId = 13493, startTimeUtc = "2026-10-10T09:37:25.4148239", durationSeconds = 2, pagesRead = 0 } } },
|
||||
{ seriesId = 9249, localDate = "2026-10-10T00:00:00", startTimeUtc = "2026-10-10T08:58:13.142957", chapters = {
|
||||
{ chapterId = 13493, startTimeUtc = "2026-10-10T08:58:13.142957", durationSeconds = 9, pagesRead = 0 } } },
|
||||
{ seriesId = 9249, localDate = "2026-10-10T00:00:00", startTimeUtc = "2026-10-10T08:15:36.7468877", chapters = {
|
||||
{ chapterId = 13493, startTimeUtc = "2026-10-10T08:15:36.7468877", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 9249, localDate = "2026-10-10T00:00:00", startTimeUtc = "2026-10-10T07:52:18.8289612", chapters = {
|
||||
{ chapterId = 13493, startTimeUtc = "2026-10-10T07:52:18.8289612", durationSeconds = 164, pagesRead = 0 } } },
|
||||
{ seriesId = 9249, localDate = "2026-10-10T00:00:00", startTimeUtc = "2026-10-10T07:10:45.3655221", chapters = {
|
||||
{ chapterId = 13493, startTimeUtc = "2026-10-10T07:10:45.3655221", durationSeconds = 33, pagesRead = 1 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-10T00:00:00", startTimeUtc = "2026-10-10T04:44:42.7023417", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-10T04:44:42.7023417", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-10T00:00:00", startTimeUtc = "2026-10-10T03:55:35.74839", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-10T03:55:35.74839", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7606, localDate = "2026-10-10T00:00:00", startTimeUtc = "2026-10-10T03:41:12.3904529", chapters = {
|
||||
{ chapterId = 11501, startTimeUtc = "2026-10-10T03:41:12.3904529", durationSeconds = 12, pagesRead = 2 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-10T00:00:00", startTimeUtc = "2026-10-10T03:39:55.2030981", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-10T03:39:55.2030981", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7606, localDate = "2026-10-10T00:00:00", startTimeUtc = "2026-10-10T02:29:21.0392738", chapters = {
|
||||
{ chapterId = 11501, startTimeUtc = "2026-10-10T02:29:21.0392738", durationSeconds = 40, pagesRead = 2 } } },
|
||||
{ seriesId = 7606, localDate = "2026-10-10T00:00:00", startTimeUtc = "2026-10-10T02:12:18.2048535", chapters = {
|
||||
{ chapterId = 11501, startTimeUtc = "2026-10-10T02:12:18.2048535", durationSeconds = 53, pagesRead = 3 } } },
|
||||
{ seriesId = 7606, localDate = "2026-10-10T00:00:00", startTimeUtc = "2026-10-10T01:55:30.4051153", chapters = {
|
||||
{ chapterId = 11501, startTimeUtc = "2026-10-10T01:55:30.4051153", durationSeconds = 50, pagesRead = 2 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-09T00:00:00", startTimeUtc = "2026-10-09T14:45:39.0731175", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-09T14:45:39.0731175", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7606, localDate = "2026-10-09T00:00:00", startTimeUtc = "2026-10-09T13:43:07.3149178", chapters = {
|
||||
{ chapterId = 11501, startTimeUtc = "2026-10-09T13:43:07.3149178", durationSeconds = 5, pagesRead = 0 } } },
|
||||
{ seriesId = 10735, localDate = "2026-10-09T00:00:00", startTimeUtc = "2026-10-09T13:32:16.6705302", chapters = {
|
||||
{ chapterId = 18969, startTimeUtc = "2026-10-09T13:32:16.6705302", durationSeconds = 163, pagesRead = 5 } } },
|
||||
{ seriesId = 10698, localDate = "2026-10-09T00:00:00", startTimeUtc = "2026-10-09T13:30:11.0145349", chapters = {
|
||||
{ chapterId = 18923, startTimeUtc = "2026-10-09T13:30:11.0145349", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7606, localDate = "2026-10-09T00:00:00", startTimeUtc = "2026-10-09T13:17:56.7622935", chapters = {
|
||||
{ chapterId = 11501, startTimeUtc = "2026-10-09T13:17:56.7622935", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7606, localDate = "2026-10-09T00:00:00", startTimeUtc = "2026-10-09T11:51:14.1858092", chapters = {
|
||||
{ chapterId = 11501, startTimeUtc = "2026-10-09T11:51:14.1858092", durationSeconds = 7, pagesRead = 0 } } },
|
||||
{ seriesId = 10732, localDate = "2026-10-09T00:00:00", startTimeUtc = "2026-10-09T11:20:33.6944863", chapters = {
|
||||
{ chapterId = 18966, startTimeUtc = "2026-10-09T11:20:33.6944863", durationSeconds = 29, pagesRead = 21 } } },
|
||||
{ seriesId = 10735, localDate = "2026-10-09T00:00:00", startTimeUtc = "2026-10-09T11:15:31.2028337", chapters = {
|
||||
{ chapterId = 18969, startTimeUtc = "2026-10-09T11:15:31.2028337", durationSeconds = 80, pagesRead = 33 } } },
|
||||
{ seriesId = 10724, localDate = "2026-10-09T00:00:00", startTimeUtc = "2026-10-09T11:12:30.4622536", chapters = {
|
||||
{ chapterId = 18957, startTimeUtc = "2026-10-09T11:12:30.4622536", durationSeconds = 4, pagesRead = 0 } } },
|
||||
{ seriesId = 7606, localDate = "2026-10-09T00:00:00", startTimeUtc = "2026-10-09T11:04:22.6125371", chapters = {
|
||||
{ chapterId = 11501, startTimeUtc = "2026-10-09T11:04:22.6125371", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 10724, localDate = "2026-10-09T00:00:00", startTimeUtc = "2026-10-09T10:29:16.8959018", chapters = {
|
||||
{ chapterId = 18957, startTimeUtc = "2026-10-09T10:29:16.8959018", durationSeconds = 7, pagesRead = 16 } } },
|
||||
{ seriesId = 7606, localDate = "2026-10-09T00:00:00", startTimeUtc = "2026-10-09T09:51:43.6940126", chapters = {
|
||||
{ chapterId = 11501, startTimeUtc = "2026-10-09T09:51:43.6940126", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 9249, localDate = "2026-10-09T00:00:00", startTimeUtc = "2026-10-09T09:34:29.5406473", chapters = {
|
||||
{ chapterId = 13493, startTimeUtc = "2026-10-09T09:34:29.5406473", durationSeconds = 3, pagesRead = 0 } } },
|
||||
{ seriesId = 7606, localDate = "2026-10-09T00:00:00", startTimeUtc = "2026-10-09T09:34:17.5161863", chapters = {
|
||||
{ chapterId = 11501, startTimeUtc = "2026-10-09T09:34:17.5161863", durationSeconds = 5, pagesRead = 1 } } },
|
||||
{ seriesId = 7606, localDate = "2026-10-09T00:00:00", startTimeUtc = "2026-10-09T09:10:02.1865718", chapters = {
|
||||
{ chapterId = 11501, startTimeUtc = "2026-10-09T09:10:02.1865718", durationSeconds = 759, pagesRead = 11 } } },
|
||||
{ seriesId = 10708, localDate = "2026-10-09T00:00:00", startTimeUtc = "2026-10-09T08:18:07.1620583", chapters = {
|
||||
{ chapterId = 18933, startTimeUtc = "2026-10-09T08:18:07.1620583", durationSeconds = 15, pagesRead = 2 } } },
|
||||
{ seriesId = 10707, localDate = "2026-10-09T00:00:00", startTimeUtc = "2026-10-09T07:55:45.2365064", chapters = {
|
||||
{ chapterId = 18932, startTimeUtc = "2026-10-09T07:55:45.2365064", durationSeconds = 7, pagesRead = 4 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-09T00:00:00", startTimeUtc = "2026-10-09T07:44:06.636679", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-09T07:44:06.636679", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-09T00:00:00", startTimeUtc = "2026-10-09T07:13:20.7857153", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-09T07:13:20.7857153", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-09T00:00:00", startTimeUtc = "2026-10-09T04:40:28.7189645", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-09T04:40:28.7189645", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-09T00:00:00", startTimeUtc = "2026-10-09T04:05:17.6951039", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-09T04:05:17.6951039", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 9249, localDate = "2026-10-09T00:00:00", startTimeUtc = "2026-10-09T03:03:56.2211648", chapters = {
|
||||
{ chapterId = 13493, startTimeUtc = "2026-10-09T03:03:56.2211648", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 9292, localDate = "2026-10-09T00:00:00", startTimeUtc = "2026-10-09T01:10:42.7539032", chapters = {
|
||||
{ chapterId = 13569, startTimeUtc = "2026-10-09T01:10:42.7539032", durationSeconds = 8, pagesRead = 0 } } },
|
||||
{ seriesId = 9292, localDate = "2026-10-08T00:00:00", startTimeUtc = "2026-10-08T15:26:10.3634693", chapters = {
|
||||
{ chapterId = 13569, startTimeUtc = "2026-10-08T15:26:10.3634693", durationSeconds = 15, pagesRead = 10 } } },
|
||||
{ seriesId = 9249, localDate = "2026-10-08T00:00:00", startTimeUtc = "2026-10-08T15:12:20.8270779", chapters = {
|
||||
{ chapterId = 13493, startTimeUtc = "2026-10-08T15:12:20.8270779", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-08T00:00:00", startTimeUtc = "2026-10-08T14:34:05.7981443", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-08T14:34:05.7981443", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-08T00:00:00", startTimeUtc = "2026-10-08T13:12:53.6969824", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-08T13:12:53.6969824", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 9249, localDate = "2026-10-08T00:00:00", startTimeUtc = "2026-10-08T11:49:28.3986198", chapters = {
|
||||
{ chapterId = 13493, startTimeUtc = "2026-10-08T11:49:28.3986198", durationSeconds = 95, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-08T00:00:00", startTimeUtc = "2026-10-08T11:48:06.6315963", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-08T11:48:06.6315963", durationSeconds = 544, pagesRead = 0 } } },
|
||||
{ seriesId = 7460, localDate = "2026-10-08T00:00:00", startTimeUtc = "2026-10-08T10:57:20.8373954", chapters = {
|
||||
{ chapterId = 11285, startTimeUtc = "2026-10-08T11:15:47.102", durationSeconds = 1111, pagesRead = 0 },
|
||||
{ chapterId = 11285, startTimeUtc = "2026-10-08T10:57:20.8373954", durationSeconds = 406, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-08T00:00:00", startTimeUtc = "2026-10-08T11:02:33.6484158", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-08T11:02:33.6484158", durationSeconds = 611, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-08T00:00:00", startTimeUtc = "2026-10-08T10:31:08.475182", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-08T10:31:08.475182", durationSeconds = 3, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-08T00:00:00", startTimeUtc = "2026-10-08T09:03:45.5309711", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-08T09:03:45.5309711", durationSeconds = 86, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-08T00:00:00", startTimeUtc = "2026-10-08T07:59:09.2881628", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-08T07:59:09.2881628", durationSeconds = 263, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-08T00:00:00", startTimeUtc = "2026-10-08T07:20:18.0105615", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-08T07:20:18.0105615", durationSeconds = 233, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-08T00:00:00", startTimeUtc = "2026-10-08T06:48:51.312417", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-08T06:48:51.312417", durationSeconds = 296, pagesRead = 0 } } },
|
||||
{ seriesId = 7460, localDate = "2026-10-08T00:00:00", startTimeUtc = "2026-10-08T04:42:54.7579483", chapters = {
|
||||
{ chapterId = 11285, startTimeUtc = "2026-10-08T04:42:54.7579483", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-08T00:00:00", startTimeUtc = "2026-10-08T04:05:45.0300961", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-08T04:05:45.0300961", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7540, localDate = "2026-10-08T00:00:00", startTimeUtc = "2026-10-08T02:52:33.5236184", chapters = {
|
||||
{ chapterId = 13394, startTimeUtc = "2026-10-08T02:52:33.5236184", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7460, localDate = "2026-10-08T00:00:00", startTimeUtc = "2026-10-08T02:20:36.4169563", chapters = {
|
||||
{ chapterId = 11285, startTimeUtc = "2026-10-08T02:20:36.4169563", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-07T00:00:00", startTimeUtc = "2026-10-07T13:44:15.125016", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-07T13:44:15.125016", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-07T00:00:00", startTimeUtc = "2026-10-07T09:45:01.0814021", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-07T09:45:01.0814021", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-07T00:00:00", startTimeUtc = "2026-10-07T05:19:38.9892914", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-07T05:19:38.9892914", durationSeconds = 503, pagesRead = 0 } } },
|
||||
{ seriesId = 7460, localDate = "2026-10-06T00:00:00", startTimeUtc = "2026-10-06T13:00:26.371751", chapters = {
|
||||
{ chapterId = 11285, startTimeUtc = "2026-10-06T13:00:26.371751", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7460, localDate = "2026-10-06T00:00:00", startTimeUtc = "2026-10-06T12:21:25.7149691", chapters = {
|
||||
{ chapterId = 11285, startTimeUtc = "2026-10-06T12:21:25.7149691", durationSeconds = 489, pagesRead = 0 } } },
|
||||
{ seriesId = 9249, localDate = "2026-10-06T00:00:00", startTimeUtc = "2026-10-06T12:07:54.0702478", chapters = {
|
||||
{ chapterId = 13493, startTimeUtc = "2026-10-06T12:07:54.0702478", durationSeconds = 320, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-06T00:00:00", startTimeUtc = "2026-10-06T12:01:31.4949015", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-06T12:01:31.4949015", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-06T00:00:00", startTimeUtc = "2026-10-06T11:37:48.0185472", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-06T11:37:48.0185472", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-06T00:00:00", startTimeUtc = "2026-10-06T03:21:10.9150125", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-06T03:21:10.9150125", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-06T00:00:00", startTimeUtc = "2026-10-06T02:50:29.5547188", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-06T02:50:29.5547188", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-05T00:00:00", startTimeUtc = "2026-10-05T14:10:59.8916334", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-05T14:10:59.8916334", durationSeconds = 195, pagesRead = 0 } } },
|
||||
{ seriesId = 7453, localDate = "2026-10-05T00:00:00", startTimeUtc = "2026-10-05T12:18:33.1689018", chapters = {
|
||||
{ chapterId = 11273, startTimeUtc = "2026-10-05T12:18:33.1689018", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7460, localDate = "2026-10-05T00:00:00", startTimeUtc = "2026-10-05T11:54:12.1093305", chapters = {
|
||||
{ chapterId = 11285, startTimeUtc = "2026-10-05T11:54:12.1093305", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7460, localDate = "2026-10-05T00:00:00", startTimeUtc = "2026-10-05T11:34:55.3786363", chapters = {
|
||||
{ chapterId = 11285, startTimeUtc = "2026-10-05T11:34:55.3786363", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7460, localDate = "2026-10-05T00:00:00", startTimeUtc = "2026-10-05T09:15:25.8448735", chapters = {
|
||||
{ chapterId = 11285, startTimeUtc = "2026-10-05T09:15:25.8448735", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7460, localDate = "2026-10-04T00:00:00", startTimeUtc = "2026-10-04T09:36:48.7199331", chapters = {
|
||||
{ chapterId = 11285, startTimeUtc = "2026-10-04T09:36:48.7199331", durationSeconds = 226, pagesRead = 0 } } },
|
||||
{ seriesId = 7460, localDate = "2026-10-04T00:00:00", startTimeUtc = "2026-10-04T06:13:00.6097898", chapters = {
|
||||
{ chapterId = 11285, startTimeUtc = "2026-10-04T06:13:00.6097898", durationSeconds = 412, pagesRead = 1 } } },
|
||||
{ seriesId = 9249, localDate = "2026-10-03T00:00:00", startTimeUtc = "2026-10-03T14:24:26.495891", chapters = {
|
||||
{ chapterId = 13493, startTimeUtc = "2026-10-03T14:24:26.495891", durationSeconds = 337, pagesRead = 0 } } },
|
||||
{ seriesId = 7460, localDate = "2026-10-03T00:00:00", startTimeUtc = "2026-10-03T13:00:16.6885142", chapters = {
|
||||
{ chapterId = 11285, startTimeUtc = "2026-10-03T13:00:16.6885142", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 10588, localDate = "2026-10-03T00:00:00", startTimeUtc = "2026-10-03T12:25:37.0931958", chapters = {
|
||||
{ chapterId = 16914, startTimeUtc = "2026-10-03T12:25:37.0931958", durationSeconds = 358, pagesRead = 24 } } },
|
||||
{ seriesId = 7460, localDate = "2026-10-03T00:00:00", startTimeUtc = "2026-10-03T12:09:12.6479717", chapters = {
|
||||
{ chapterId = 11285, startTimeUtc = "2026-10-03T12:09:12.6479717", durationSeconds = 409, pagesRead = 1 } } },
|
||||
{ seriesId = 7540, localDate = "2026-10-03T00:00:00", startTimeUtc = "2026-10-03T02:10:46.4251132", chapters = {
|
||||
{ chapterId = 13394, startTimeUtc = "2026-10-03T02:10:46.4251132", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7540, localDate = "2026-10-02T00:00:00", startTimeUtc = "2026-10-02T04:04:43.6820861", chapters = {
|
||||
{ chapterId = 13394, startTimeUtc = "2026-10-02T04:04:43.6820861", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7460, localDate = "2026-10-02T00:00:00", startTimeUtc = "2026-10-02T01:31:26.0795951", chapters = {
|
||||
{ chapterId = 11285, startTimeUtc = "2026-10-02T01:31:26.0795951", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7460, localDate = "2026-10-02T00:00:00", startTimeUtc = "2026-10-02T01:19:47.6481957", chapters = {
|
||||
{ chapterId = 11285, startTimeUtc = "2026-10-02T01:19:47.6481957", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7460, localDate = "2026-10-01T00:00:00", startTimeUtc = "2026-10-01T14:01:45.997983", chapters = {
|
||||
{ chapterId = 11285, startTimeUtc = "2026-10-01T14:01:45.997983", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 10585, localDate = "2026-10-01T00:00:00", startTimeUtc = "2026-10-01T13:36:40.8506172", chapters = {
|
||||
{ chapterId = 16862, startTimeUtc = "2026-10-01T13:36:40.8506172", durationSeconds = 113, pagesRead = 8 } } },
|
||||
{ seriesId = 7460, localDate = "2026-10-01T00:00:00", startTimeUtc = "2026-10-01T13:35:51.0806955", chapters = {
|
||||
{ chapterId = 11285, startTimeUtc = "2026-10-01T13:35:51.0806955", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7460, localDate = "2026-10-01T00:00:00", startTimeUtc = "2026-10-01T11:55:01.4289659", chapters = {
|
||||
{ chapterId = 11285, startTimeUtc = "2026-10-01T11:55:01.4289659", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7460, localDate = "2026-10-01T00:00:00", startTimeUtc = "2026-10-01T11:41:02.5910426", chapters = {
|
||||
{ chapterId = 11285, startTimeUtc = "2026-10-01T11:41:02.5910426", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7460, localDate = "2026-10-01T00:00:00", startTimeUtc = "2026-10-01T11:28:36.4902671", chapters = {
|
||||
{ chapterId = 11285, startTimeUtc = "2026-10-01T11:28:36.4902671", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7460, localDate = "2026-10-01T00:00:00", startTimeUtc = "2026-10-01T11:10:02.1536935", chapters = {
|
||||
{ chapterId = 11285, startTimeUtc = "2026-10-01T11:10:02.1536935", durationSeconds = 289, pagesRead = 0 } } },
|
||||
{ seriesId = 10585, localDate = "2026-10-01T00:00:00", startTimeUtc = "2026-10-01T11:04:28.7600787", chapters = {
|
||||
{ chapterId = 16862, startTimeUtc = "2026-10-01T11:04:28.7600787", durationSeconds = 241, pagesRead = 15 } } },
|
||||
{ seriesId = 7540, localDate = "2026-10-01T00:00:00", startTimeUtc = "2026-10-01T10:32:28.7130273", chapters = {
|
||||
{ chapterId = 13394, startTimeUtc = "2026-10-01T10:32:28.7130273", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 8661, localDate = "2026-09-30T00:00:00", startTimeUtc = "2026-09-30T13:03:27.0677663", chapters = {
|
||||
{ chapterId = 12763, startTimeUtc = "2026-09-30T13:03:27.0677663", durationSeconds = 1530, pagesRead = -3 } } },
|
||||
{ seriesId = 7540, localDate = "2026-09-30T00:00:00", startTimeUtc = "2026-09-30T13:02:32.9357375", chapters = {
|
||||
{ chapterId = 13394, startTimeUtc = "2026-09-30T13:02:32.9357375", durationSeconds = 22, pagesRead = 0 } } },
|
||||
{ seriesId = 7540, localDate = "2026-09-30T00:00:00", startTimeUtc = "2026-09-30T12:28:33.282795", chapters = {
|
||||
{ chapterId = 13394, startTimeUtc = "2026-09-30T12:28:33.282795", durationSeconds = 189, pagesRead = 0 } } },
|
||||
{ seriesId = 8661, localDate = "2026-09-30T00:00:00", startTimeUtc = "2026-09-30T11:37:13.1197026", chapters = {
|
||||
{ chapterId = 12763, startTimeUtc = "2026-09-30T11:37:13.1197026", durationSeconds = 25, pagesRead = 0 } } },
|
||||
{ seriesId = 7540, localDate = "2026-09-30T00:00:00", startTimeUtc = "2026-09-30T11:33:44.6966312", chapters = {
|
||||
{ chapterId = 13394, startTimeUtc = "2026-09-30T11:33:44.6966312", durationSeconds = 130, pagesRead = 0 } } },
|
||||
{ seriesId = 7540, localDate = "2026-09-30T00:00:00", startTimeUtc = "2026-09-30T09:14:25.3316858", chapters = {
|
||||
{ chapterId = 13394, startTimeUtc = "2026-09-30T09:14:25.3316858", durationSeconds = 37, pagesRead = -4 } } },
|
||||
{ seriesId = 7540, localDate = "2026-09-30T00:00:00", startTimeUtc = "2026-09-30T08:52:37.2436808", chapters = {
|
||||
{ chapterId = 13394, startTimeUtc = "2026-09-30T08:52:37.2436808", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7540, localDate = "2026-09-30T00:00:00", startTimeUtc = "2026-09-30T07:54:07.7610298", chapters = {
|
||||
{ chapterId = 13394, startTimeUtc = "2026-09-30T07:54:07.7610298", durationSeconds = 5, pagesRead = 0 } } },
|
||||
{ seriesId = 7805, localDate = "2026-09-30T00:00:00", startTimeUtc = "2026-09-30T03:56:53.2380567", chapters = {
|
||||
{ chapterId = 11791, startTimeUtc = "2026-09-30T03:56:53.2380567", durationSeconds = 6, pagesRead = 0 } } },
|
||||
{ seriesId = 7540, localDate = "2026-09-30T00:00:00", startTimeUtc = "2026-09-30T03:42:57.6124947", chapters = {
|
||||
{ chapterId = 13394, startTimeUtc = "2026-09-30T03:42:57.6124947", durationSeconds = 1749, pagesRead = 4 } } },
|
||||
{ seriesId = 7540, localDate = "2026-09-30T00:00:00", startTimeUtc = "2026-09-30T03:23:47.6591832", chapters = {
|
||||
{ chapterId = 13394, startTimeUtc = "2026-09-30T03:23:47.6591832", durationSeconds = 548, pagesRead = 0 } } },
|
||||
{ seriesId = 10684, localDate = "2026-09-30T00:00:00", startTimeUtc = "2026-09-30T03:12:37.6514083", chapters = {
|
||||
{ chapterId = 18895, startTimeUtc = "2026-09-30T03:12:37.6514083", durationSeconds = 68, pagesRead = 15 } } },
|
||||
{ seriesId = 10556, localDate = "2026-09-30T00:00:00", startTimeUtc = "2026-09-30T01:58:37.2644751", chapters = {
|
||||
{ chapterId = 16398, startTimeUtc = "2026-09-30T01:58:37.2644751", durationSeconds = 5, pagesRead = 6 } } },
|
||||
{ seriesId = 7805, localDate = "2026-09-30T00:00:00", startTimeUtc = "2026-09-30T00:43:20.1361231", chapters = {
|
||||
{ chapterId = 11791, startTimeUtc = "2026-09-30T01:16:48.8842393", durationSeconds = 387, pagesRead = 0 },
|
||||
{ chapterId = 11791, startTimeUtc = "2026-09-30T00:43:20.1361231", durationSeconds = 204, pagesRead = 1 } } },
|
||||
{ seriesId = 8661, localDate = "2026-09-30T00:00:00", startTimeUtc = "2026-09-30T00:46:55.2653707", chapters = {
|
||||
{ chapterId = 12763, startTimeUtc = "2026-09-30T00:46:55.2653707", durationSeconds = 1330, pagesRead = 3 } } },
|
||||
{ seriesId = 7460, localDate = "2026-09-30T00:00:00", startTimeUtc = "2026-09-30T00:25:09.4803818", chapters = {
|
||||
{ chapterId = 11285, startTimeUtc = "2026-09-30T00:37:14.7633119", durationSeconds = 43, pagesRead = 0 },
|
||||
{ chapterId = 11285, startTimeUtc = "2026-09-30T00:25:09.4803818", durationSeconds = 32, pagesRead = 0 } } },
|
||||
{ seriesId = 7540, localDate = "2026-09-30T00:00:00", startTimeUtc = "2026-09-30T00:30:04.5325361", chapters = {
|
||||
{ chapterId = 13394, startTimeUtc = "2026-09-30T00:30:04.5325361", durationSeconds = 222, pagesRead = -1 } } },
|
||||
{ seriesId = 9249, localDate = "2026-09-30T00:00:00", startTimeUtc = "2026-09-30T00:27:17.7123717", chapters = {
|
||||
{ chapterId = 13493, startTimeUtc = "2026-09-30T00:27:17.7123717", durationSeconds = 108, pagesRead = 1 } } },
|
||||
{ seriesId = 10584, localDate = "2026-09-29T00:00:00", startTimeUtc = "2026-09-29T15:27:07.2391439", chapters = {
|
||||
{ chapterId = 16853, startTimeUtc = "2026-09-29T15:27:07.2391439", durationSeconds = 6, pagesRead = 6 } } },
|
||||
{ seriesId = 7460, localDate = "2026-09-29T00:00:00", startTimeUtc = "2026-09-29T15:23:24.6913136", chapters = {
|
||||
{ chapterId = 11285, startTimeUtc = "2026-09-29T15:23:24.6913136", durationSeconds = 51, pagesRead = 1 } } },
|
||||
{ seriesId = 10584, localDate = "2026-09-29T00:00:00", startTimeUtc = "2026-09-29T15:11:40.8997791", chapters = {
|
||||
{ chapterId = 16853, startTimeUtc = "2026-09-29T15:11:40.8997791", durationSeconds = 24, pagesRead = 14 } } },
|
||||
{ seriesId = 8661, localDate = "2026-09-29T00:00:00", startTimeUtc = "2026-09-29T15:10:15.9077958", chapters = {
|
||||
{ chapterId = 12763, startTimeUtc = "2026-09-29T15:10:15.9077958", durationSeconds = 23, pagesRead = 6 } } },
|
||||
{ seriesId = 7540, localDate = "2026-09-29T00:00:00", startTimeUtc = "2026-09-29T15:02:32.6735695", chapters = {
|
||||
{ chapterId = 13394, startTimeUtc = "2026-09-29T15:02:32.6735695", durationSeconds = 452, pagesRead = 7 } } },
|
||||
{ seriesId = 7460, localDate = "2026-09-29T00:00:00", startTimeUtc = "2026-09-29T14:58:04.6106466", chapters = {
|
||||
{ chapterId = 11285, startTimeUtc = "2026-09-29T14:58:04.6106466", durationSeconds = 82, pagesRead = 0 } } },
|
||||
{ seriesId = 9249, localDate = "2026-09-29T00:00:00", startTimeUtc = "2026-09-29T14:38:04.1555096", chapters = {
|
||||
{ chapterId = 13493, startTimeUtc = "2026-09-29T14:38:04.1555096", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 9249, localDate = "2026-09-29T00:00:00", startTimeUtc = "2026-09-29T14:12:48.9320003", chapters = {
|
||||
{ chapterId = 13493, startTimeUtc = "2026-09-29T14:12:48.9320003", durationSeconds = 86, pagesRead = 3 } } },
|
||||
{ seriesId = 7460, localDate = "2026-09-29T00:00:00", startTimeUtc = "2026-09-29T14:07:43.3739949", chapters = {
|
||||
{ chapterId = 11285, startTimeUtc = "2026-09-29T14:07:43.3739949", durationSeconds = 439, pagesRead = 20 } } },
|
||||
{ seriesId = 10560, localDate = "2026-09-29T00:00:00", startTimeUtc = "2026-09-29T13:55:37.9561391", chapters = {
|
||||
{ chapterId = 16493, startTimeUtc = "2026-09-29T13:55:37.9561391", durationSeconds = 0, pagesRead = 1 } } },
|
||||
{ seriesId = 9249, localDate = "2026-09-29T00:00:00", startTimeUtc = "2026-09-29T12:39:52.7733874", chapters = {
|
||||
{ chapterId = 13493, startTimeUtc = "2026-09-29T12:39:52.7733874", durationSeconds = 31, pagesRead = 3 } } },
|
||||
{ seriesId = 10559, localDate = "2026-09-29T00:00:00", startTimeUtc = "2026-09-29T12:33:10.2857117", chapters = {
|
||||
{ chapterId = 16479, startTimeUtc = "2026-09-29T12:33:10.2857117", durationSeconds = 7, pagesRead = 15 } } },
|
||||
{ seriesId = 10560, localDate = "2026-09-29T00:00:00", startTimeUtc = "2026-09-29T11:51:35.4694759", chapters = {
|
||||
{ chapterId = 16493, startTimeUtc = "2026-09-29T12:22:43.7993875", durationSeconds = 936, pagesRead = 2 },
|
||||
{ chapterId = 16493, startTimeUtc = "2026-09-29T11:51:35.4694759", durationSeconds = 1223, pagesRead = 12 } } },
|
||||
{ seriesId = 7460, localDate = "2026-09-29T00:00:00", startTimeUtc = "2026-09-29T11:58:50.1222492", chapters = {
|
||||
{ chapterId = 11285, startTimeUtc = "2026-09-29T12:21:19.3748615", durationSeconds = 909, pagesRead = -2 },
|
||||
{ chapterId = 11285, startTimeUtc = "2026-09-29T11:58:50.1222492", durationSeconds = 20, pagesRead = 0 } } },
|
||||
{ seriesId = 10563, localDate = "2026-09-29T00:00:00", startTimeUtc = "2026-09-29T12:17:34.2571271", chapters = {
|
||||
{ chapterId = 16505, startTimeUtc = "2026-09-29T12:17:34.2571271", durationSeconds = 36, pagesRead = 17 } } },
|
||||
{ seriesId = 10562, localDate = "2026-09-29T00:00:00", startTimeUtc = "2026-09-29T12:07:43.0627869", chapters = {
|
||||
{ chapterId = 16502, startTimeUtc = "2026-09-29T12:07:43.0627869", durationSeconds = 70, pagesRead = 17 } } },
|
||||
{ seriesId = 7910, localDate = "2026-09-29T00:00:00", startTimeUtc = "2026-09-29T11:50:25.270629", chapters = {
|
||||
{ chapterId = 11904, startTimeUtc = "2026-09-29T11:50:25.270629", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7910, localDate = "2026-09-29T00:00:00", startTimeUtc = "2026-09-29T11:25:02.6769601", chapters = {
|
||||
{ chapterId = 11896, startTimeUtc = "2026-09-29T11:25:16.5490822", durationSeconds = 442, pagesRead = 6 },
|
||||
{ chapterId = 11898, startTimeUtc = "2026-09-29T11:25:02.6769601", durationSeconds = 328, pagesRead = 1 } } },
|
||||
{ seriesId = 7460, localDate = "2026-09-29T00:00:00", startTimeUtc = "2026-09-29T11:24:52.8021347", chapters = {
|
||||
{ chapterId = 11285, startTimeUtc = "2026-09-29T11:24:52.8021347", durationSeconds = 525, pagesRead = 15 } } },
|
||||
{ seriesId = 10639, localDate = "2026-09-29T00:00:00", startTimeUtc = "2026-09-29T11:08:39.2618986", chapters = {
|
||||
{ chapterId = 18031, startTimeUtc = "2026-09-29T11:08:39.2618986", durationSeconds = 0, pagesRead = 1 } } },
|
||||
{ seriesId = 10556, localDate = "2026-09-29T00:00:00", startTimeUtc = "2026-09-29T10:56:40.6001656", chapters = {
|
||||
{ chapterId = 16398, startTimeUtc = "2026-09-29T10:56:40.6001656", durationSeconds = 11, pagesRead = 9 } } },
|
||||
{ seriesId = 7460, localDate = "2026-09-29T00:00:00", startTimeUtc = "2026-09-29T10:45:47.6455857", chapters = {
|
||||
{ chapterId = 11285, startTimeUtc = "2026-09-29T10:45:47.6455857", durationSeconds = 4, pagesRead = 4 } } },
|
||||
{ seriesId = 7462, localDate = "2026-09-29T00:00:00", startTimeUtc = "2026-09-29T10:45:05.5896105", chapters = {
|
||||
{ chapterId = 11290, startTimeUtc = "2026-09-29T10:45:05.5896105", durationSeconds = 3, pagesRead = 1 } } },
|
||||
{ seriesId = 7540, localDate = "2026-09-29T00:00:00", startTimeUtc = "2026-09-29T10:35:52.0518521", chapters = {
|
||||
{ chapterId = 13394, startTimeUtc = "2026-09-29T10:35:52.0518521", durationSeconds = 39, pagesRead = 6 } } },
|
||||
{ seriesId = 7805, localDate = "2026-09-29T00:00:00", startTimeUtc = "2026-09-29T10:34:39.8658599", chapters = {
|
||||
{ chapterId = 11791, startTimeUtc = "2026-09-29T10:34:39.8658599", durationSeconds = 12, pagesRead = 3 } } },
|
||||
{ seriesId = 7453, localDate = "2026-09-29T00:00:00", startTimeUtc = "2026-09-29T10:25:25.4088288", chapters = {
|
||||
{ chapterId = 11271, startTimeUtc = "2026-09-29T10:25:25.4088288", durationSeconds = 86, pagesRead = 2 } } },
|
||||
{ seriesId = 10004, localDate = "2026-09-29T00:00:00", startTimeUtc = "2026-09-29T10:22:33.7903381", chapters = {
|
||||
{ chapterId = 14594, startTimeUtc = "2026-09-29T10:22:33.7903381", durationSeconds = 167, pagesRead = 4 } } },
|
||||
{ seriesId = 7453, localDate = "2026-09-29T00:00:00", startTimeUtc = "2026-09-29T10:01:44.7835505", chapters = {
|
||||
{ chapterId = 11271, startTimeUtc = "2026-09-29T10:01:44.7835505", durationSeconds = 230, pagesRead = 0 } } },
|
||||
{ seriesId = 10001, localDate = "2026-09-29T00:00:00", startTimeUtc = "2026-09-29T09:57:30.1875022", chapters = {
|
||||
{ chapterId = 14591, startTimeUtc = "2026-09-29T09:57:30.1875022", durationSeconds = 14, pagesRead = 0 } } },
|
||||
{ seriesId = 7460, localDate = "2026-09-29T00:00:00", startTimeUtc = "2026-09-29T09:39:33.8232177", chapters = {
|
||||
{ chapterId = 11285, startTimeUtc = "2026-09-29T09:39:33.8232177", durationSeconds = 332, pagesRead = 19 } } },
|
||||
{ seriesId = 7476, localDate = "2026-09-29T00:00:00", startTimeUtc = "2026-09-29T09:30:15.0902649", chapters = {
|
||||
{ chapterId = 11317, startTimeUtc = "2026-09-29T09:30:15.0902649", durationSeconds = 27, pagesRead = 0 } } },
|
||||
{ seriesId = 7476, localDate = "2026-09-29T00:00:00", startTimeUtc = "2026-09-29T09:02:28.8339509", chapters = {
|
||||
{ chapterId = 11317, startTimeUtc = "2026-09-29T09:02:28.8339509", durationSeconds = 267, pagesRead = 0 } } },
|
||||
{ seriesId = 10004, localDate = "2026-09-29T00:00:00", startTimeUtc = "2026-09-29T08:51:39.2655404", chapters = {
|
||||
{ chapterId = 14594, startTimeUtc = "2026-09-29T08:51:39.2655404", durationSeconds = 39, pagesRead = 0 } } },
|
||||
{ seriesId = 10004, localDate = "2026-09-29T00:00:00", startTimeUtc = "2026-09-29T08:33:15.8755207", chapters = {
|
||||
{ chapterId = 14594, startTimeUtc = "2026-09-29T08:33:15.8755207", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 10004, localDate = "2026-09-29T00:00:00", startTimeUtc = "2026-09-29T08:14:10.4993494", chapters = {
|
||||
{ chapterId = 14594, startTimeUtc = "2026-09-29T08:14:10.4993494", durationSeconds = 106, pagesRead = 0 } } },
|
||||
{ seriesId = 7476, localDate = "2026-09-29T00:00:00", startTimeUtc = "2026-09-29T07:47:38.8544242", chapters = {
|
||||
{ chapterId = 11317, startTimeUtc = "2026-09-29T08:02:48.272453", durationSeconds = 461, pagesRead = -1 },
|
||||
{ chapterId = 11317, startTimeUtc = "2026-09-29T07:47:38.8544242", durationSeconds = 39, pagesRead = 7 } } },
|
||||
{ seriesId = 7452, localDate = "2026-09-29T00:00:00", startTimeUtc = "2026-09-29T07:51:52.786463", chapters = {
|
||||
{ chapterId = 11269, startTimeUtc = "2026-09-29T07:51:52.786463", durationSeconds = 365, pagesRead = 115 } } },
|
||||
{ seriesId = 10042, localDate = "2026-09-29T00:00:00", startTimeUtc = "2026-09-29T07:39:42.880422", chapters = {
|
||||
{ chapterId = 14638, startTimeUtc = "2026-09-29T07:39:42.880422", durationSeconds = 50, pagesRead = 0 } } },
|
||||
{ seriesId = 7540, localDate = "2026-09-28T00:00:00", startTimeUtc = "2026-09-28T09:16:47.6382365", chapters = {
|
||||
{ chapterId = 13394, startTimeUtc = "2026-09-28T09:16:47.6382365", durationSeconds = 59, pagesRead = 0 } } },
|
||||
{ seriesId = 9158, localDate = "2026-09-28T00:00:00", startTimeUtc = "2026-09-27T17:16:38.7193514", chapters = {
|
||||
{ chapterId = 13395, startTimeUtc = "2026-09-27T17:16:38.7193514", durationSeconds = 29, pagesRead = 1 } } },
|
||||
{ seriesId = 10683, localDate = "2026-09-28T00:00:00", startTimeUtc = "2026-09-27T17:13:53.8061535", chapters = {
|
||||
{ chapterId = 18893, startTimeUtc = "2026-09-27T17:13:53.8061535", durationSeconds = 16, pagesRead = -1 } } },
|
||||
{ seriesId = 7540, localDate = "2026-09-27T00:00:00", startTimeUtc = "2026-09-27T15:13:47.085122", chapters = {
|
||||
{ chapterId = 13394, startTimeUtc = "2026-09-27T15:13:47.085122", durationSeconds = 746, pagesRead = 0 } } },
|
||||
{ seriesId = 7540, localDate = "2026-09-27T00:00:00", startTimeUtc = "2026-09-27T13:34:49.3907937", chapters = {
|
||||
{ chapterId = 13394, startTimeUtc = "2026-09-27T13:34:49.3907937", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7540, localDate = "2026-09-27T00:00:00", startTimeUtc = "2026-09-27T13:03:53.8173515", chapters = {
|
||||
{ chapterId = 13394, startTimeUtc = "2026-09-27T13:03:53.8173515", durationSeconds = 9, pagesRead = 0 } } },
|
||||
{ seriesId = 7540, localDate = "2026-09-27T00:00:00", startTimeUtc = "2026-09-27T09:21:25.6490847", chapters = {
|
||||
{ chapterId = 13394, startTimeUtc = "2026-09-27T09:21:25.6490847", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7540, localDate = "2026-09-27T00:00:00", startTimeUtc = "2026-09-27T09:03:41.6524393", chapters = {
|
||||
{ chapterId = 13394, startTimeUtc = "2026-09-27T09:03:41.6524393", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7540, localDate = "2026-09-27T00:00:00", startTimeUtc = "2026-09-27T01:38:10.6211012", chapters = {
|
||||
{ chapterId = 13394, startTimeUtc = "2026-09-27T01:38:10.6211012", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7540, localDate = "2026-09-26T00:00:00", startTimeUtc = "2026-09-26T15:13:21.9970834", chapters = {
|
||||
{ chapterId = 13394, startTimeUtc = "2026-09-26T15:13:21.9970834", durationSeconds = 14, pagesRead = 4 } } },
|
||||
{ seriesId = 8110, localDate = "2026-09-26T00:00:00", startTimeUtc = "2026-09-26T14:58:04.4305334", chapters = {
|
||||
{ chapterId = 12126, startTimeUtc = "2026-09-26T14:58:04.4305334", durationSeconds = 181, pagesRead = 1 } } },
|
||||
{ seriesId = 8110, localDate = "2026-09-26T00:00:00", startTimeUtc = "2026-09-26T14:37:55.4114027", chapters = {
|
||||
{ chapterId = 12126, startTimeUtc = "2026-09-26T14:37:55.4114027", durationSeconds = 55, pagesRead = 1 } } },
|
||||
{ seriesId = 7460, localDate = "2026-09-26T00:00:00", startTimeUtc = "2026-09-26T14:33:39.6298963", chapters = {
|
||||
{ chapterId = 11285, startTimeUtc = "2026-09-26T14:33:39.6298963", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7460, localDate = "2026-09-26T00:00:00", startTimeUtc = "2026-09-26T14:19:48.5269015", chapters = {
|
||||
{ chapterId = 11285, startTimeUtc = "2026-09-26T14:19:48.5269015", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 10676, localDate = "2026-09-26T00:00:00", startTimeUtc = "2026-09-26T13:34:15.9269344", chapters = {
|
||||
{ chapterId = 18818, startTimeUtc = "2026-09-26T13:34:15.9269344", durationSeconds = 1021, pagesRead = 54 } } },
|
||||
{ seriesId = 10676, localDate = "2026-09-26T00:00:00", startTimeUtc = "2026-09-26T12:08:23.540117", chapters = {
|
||||
{ chapterId = 18818, startTimeUtc = "2026-09-26T12:08:23.540117", durationSeconds = 107, pagesRead = 11 } } },
|
||||
{ seriesId = 7460, localDate = "2026-09-26T00:00:00", startTimeUtc = "2026-09-26T12:07:39.7719041", chapters = {
|
||||
{ chapterId = 11285, startTimeUtc = "2026-09-26T12:07:39.7719041", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7460, localDate = "2026-09-26T00:00:00", startTimeUtc = "2026-09-26T01:55:50.078051", chapters = {
|
||||
{ chapterId = 11285, startTimeUtc = "2026-09-26T01:55:50.078051", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7460, localDate = "2026-09-26T00:00:00", startTimeUtc = "2026-09-26T01:32:58.4149147", chapters = {
|
||||
{ chapterId = 11285, startTimeUtc = "2026-09-26T01:32:58.4149147", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7460, localDate = "2026-09-26T00:00:00", startTimeUtc = "2026-09-26T01:13:02.4223873", chapters = {
|
||||
{ chapterId = 11285, startTimeUtc = "2026-09-26T01:13:02.4223873", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 9110, localDate = "2026-09-25T00:00:00", startTimeUtc = "2026-09-25T14:23:56.0117314", chapters = {
|
||||
{ chapterId = 13318, startTimeUtc = "2026-09-25T14:23:56.0117314", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 9110, localDate = "2026-09-25T00:00:00", startTimeUtc = "2026-09-25T13:59:56.4928672", chapters = {
|
||||
{ chapterId = 13318, startTimeUtc = "2026-09-25T13:59:56.4928672", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 9110, localDate = "2026-09-25T00:00:00", startTimeUtc = "2026-09-25T07:58:26.2227579", chapters = {
|
||||
{ chapterId = 13318, startTimeUtc = "2026-09-25T07:58:26.2227579", durationSeconds = 3, pagesRead = 0 } } },
|
||||
{ seriesId = 8110, localDate = "2026-09-25T00:00:00", startTimeUtc = "2026-09-25T07:08:30.8014023", chapters = {
|
||||
{ chapterId = 12126, startTimeUtc = "2026-09-25T07:08:30.8014023", durationSeconds = 7, pagesRead = 3 } } },
|
||||
{ seriesId = 7460, localDate = "2026-09-25T00:00:00", startTimeUtc = "2026-09-25T01:28:12.7465578", chapters = {
|
||||
{ chapterId = 11285, startTimeUtc = "2026-09-25T01:28:12.7465578", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 10663, localDate = "2026-09-24T00:00:00", startTimeUtc = "2026-09-24T14:34:51.9798262", chapters = {
|
||||
{ chapterId = 18514, startTimeUtc = "2026-09-24T14:34:51.9798262", durationSeconds = 59, pagesRead = 10 } } },
|
||||
{ seriesId = 10682, localDate = "2026-09-24T00:00:00", startTimeUtc = "2026-09-24T14:00:55.5695168", chapters = {
|
||||
{ chapterId = 18889, startTimeUtc = "2026-09-24T14:00:55.5695168", durationSeconds = 65, pagesRead = 8 } } },
|
||||
{ seriesId = 10634, localDate = "2026-09-24T00:00:00", startTimeUtc = "2026-09-24T13:41:48.3170857", chapters = {
|
||||
{ chapterId = 17855, startTimeUtc = "2026-09-24T13:41:48.3170857", durationSeconds = 328, pagesRead = 65 } } },
|
||||
{ seriesId = 10663, localDate = "2026-09-24T00:00:00", startTimeUtc = "2026-09-24T12:55:37.0956115", chapters = {
|
||||
{ chapterId = 18514, startTimeUtc = "2026-09-24T12:55:37.0956115", durationSeconds = 44, pagesRead = 8 } } },
|
||||
{ seriesId = 10634, localDate = "2026-09-24T00:00:00", startTimeUtc = "2026-09-24T12:54:21.9067307", chapters = {
|
||||
{ chapterId = 17855, startTimeUtc = "2026-09-24T12:54:21.9067307", durationSeconds = 8, pagesRead = 4 } } },
|
||||
{ seriesId = 10634, localDate = "2026-09-24T00:00:00", startTimeUtc = "2026-09-24T11:36:17.6978208", chapters = {
|
||||
{ chapterId = 17855, startTimeUtc = "2026-09-24T11:36:17.6978208", durationSeconds = 56, pagesRead = 14 } } },
|
||||
{ seriesId = 10682, localDate = "2026-09-24T00:00:00", startTimeUtc = "2026-09-24T09:54:25.899822", chapters = {
|
||||
{ chapterId = 18889, startTimeUtc = "2026-09-24T09:54:25.899822", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 10674, localDate = "2026-09-24T00:00:00", startTimeUtc = "2026-09-24T09:27:10.4132213", chapters = {
|
||||
{ chapterId = 18789, startTimeUtc = "2026-09-24T09:27:10.4132213", durationSeconds = 8, pagesRead = 3 } } },
|
||||
{ seriesId = 9249, localDate = "2026-09-24T00:00:00", startTimeUtc = "2026-09-24T07:47:32.97548", chapters = {
|
||||
{ chapterId = 13493, startTimeUtc = "2026-09-24T07:47:32.97548", durationSeconds = 461, pagesRead = 0 } } },
|
||||
{ seriesId = 9249, localDate = "2026-09-24T00:00:00", startTimeUtc = "2026-09-24T07:26:01.1542479", chapters = {
|
||||
{ chapterId = 13493, startTimeUtc = "2026-09-24T07:26:01.1542479", durationSeconds = 146, pagesRead = 0 } } },
|
||||
{ seriesId = 9095, localDate = "2026-09-24T00:00:00", startTimeUtc = "2026-09-24T06:46:54.4314754", chapters = {
|
||||
{ chapterId = 13282, startTimeUtc = "2026-09-24T06:46:54.4314754", durationSeconds = 0, pagesRead = 1 } } },
|
||||
{ seriesId = 9649, localDate = "2026-09-24T00:00:00", startTimeUtc = "2026-09-23T16:09:03.1098014", chapters = {
|
||||
{ chapterId = 14126, startTimeUtc = "2026-09-23T16:09:03.1098014", durationSeconds = 4, pagesRead = 2 } } },
|
||||
{ seriesId = 7461, localDate = "2026-09-24T00:00:00", startTimeUtc = "2026-09-23T16:05:48.0362145", chapters = {
|
||||
{ chapterId = 11312, startTimeUtc = "2026-09-23T16:05:48.0362145", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7460, localDate = "2026-09-23T00:00:00", startTimeUtc = "2026-09-23T13:47:22.8458997", chapters = {
|
||||
{ chapterId = 11285, startTimeUtc = "2026-09-23T13:47:22.8458997", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 8137, localDate = "2026-09-23T00:00:00", startTimeUtc = "2026-09-23T05:52:39.9019755", chapters = {
|
||||
{ chapterId = 12159, startTimeUtc = "2026-09-23T05:52:39.9019755", durationSeconds = 79, pagesRead = 18 } } },
|
||||
{ seriesId = 9249, localDate = "2026-09-23T00:00:00", startTimeUtc = "2026-09-23T03:51:46.3681335", chapters = {
|
||||
{ chapterId = 13493, startTimeUtc = "2026-09-23T03:51:46.3681335", durationSeconds = 327, pagesRead = 0 } } },
|
||||
{ seriesId = 9262, localDate = "2026-09-22T00:00:00", startTimeUtc = "2026-09-22T13:38:38.3358566", chapters = {
|
||||
{ chapterId = 13508, startTimeUtc = "2026-09-22T13:38:38.3358566", durationSeconds = 52, pagesRead = 4 } } },
|
||||
{ seriesId = 9249, localDate = "2026-09-22T00:00:00", startTimeUtc = "2026-09-22T13:22:52.4340931", chapters = {
|
||||
{ chapterId = 13493, startTimeUtc = "2026-09-22T13:22:52.4340931", durationSeconds = 5, pagesRead = 0 } } },
|
||||
{ seriesId = 7460, localDate = "2026-09-22T00:00:00", startTimeUtc = "2026-09-22T10:28:46.3070635", chapters = {
|
||||
{ chapterId = 11285, startTimeUtc = "2026-09-22T10:28:46.3070635", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7460, localDate = "2026-09-22T00:00:00", startTimeUtc = "2026-09-22T09:53:02.9688203", chapters = {
|
||||
{ chapterId = 11285, startTimeUtc = "2026-09-22T09:53:02.9688203", durationSeconds = 515, pagesRead = 1 } } },
|
||||
{ seriesId = 9257, localDate = "2026-09-22T00:00:00", startTimeUtc = "2026-09-22T09:45:09.829169", chapters = {
|
||||
{ chapterId = 13503, startTimeUtc = "2026-09-22T09:45:09.829169", durationSeconds = 5, pagesRead = 11 } } },
|
||||
{ seriesId = 9249, localDate = "2026-09-22T00:00:00", startTimeUtc = "2026-09-22T08:59:44.2021935", chapters = {
|
||||
{ chapterId = 13493, startTimeUtc = "2026-09-22T08:59:44.2021935", durationSeconds = 85, pagesRead = 0 } } },
|
||||
{ seriesId = 7460, localDate = "2026-09-22T00:00:00", startTimeUtc = "2026-09-22T08:57:31.3039746", chapters = {
|
||||
{ chapterId = 11285, startTimeUtc = "2026-09-22T08:57:31.3039746", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7460, localDate = "2026-09-22T00:00:00", startTimeUtc = "2026-09-22T08:34:21.7362395", chapters = {
|
||||
{ chapterId = 11285, startTimeUtc = "2026-09-22T08:34:21.7362395", durationSeconds = 697, pagesRead = 0 } } },
|
||||
{ seriesId = 9249, localDate = "2026-09-22T00:00:00", startTimeUtc = "2026-09-22T08:00:48.3941463", chapters = {
|
||||
{ chapterId = 13493, startTimeUtc = "2026-09-22T08:00:48.3941463", durationSeconds = 149, pagesRead = 2 } } },
|
||||
{ seriesId = 9180, localDate = "2026-09-22T00:00:00", startTimeUtc = "2026-09-22T03:13:37.560087", chapters = {
|
||||
{ chapterId = 13420, startTimeUtc = "2026-09-22T03:13:37.560087", durationSeconds = 11, pagesRead = 7 } } },
|
||||
{ seriesId = 7460, localDate = "2026-09-22T00:00:00", startTimeUtc = "2026-09-22T02:24:02.4880326", chapters = {
|
||||
{ chapterId = 11285, startTimeUtc = "2026-09-22T02:24:02.4880326", durationSeconds = 163, pagesRead = 0 } } },
|
||||
{ seriesId = 7460, localDate = "2026-09-21T00:00:00", startTimeUtc = "2026-09-21T13:24:04.9528675", chapters = {
|
||||
{ chapterId = 11285, startTimeUtc = "2026-09-21T13:24:04.9528675", durationSeconds = 307, pagesRead = 1 } } },
|
||||
{ seriesId = 7805, localDate = "2026-09-21T00:00:00", startTimeUtc = "2026-09-21T13:07:31.7048466", chapters = {
|
||||
{ chapterId = 11791, startTimeUtc = "2026-09-21T13:07:31.7048466", durationSeconds = 8, pagesRead = 0 } } },
|
||||
{ seriesId = 8661, localDate = "2026-09-21T00:00:00", startTimeUtc = "2026-09-21T13:04:31.936106", chapters = {
|
||||
{ chapterId = 12763, startTimeUtc = "2026-09-21T13:04:31.936106", durationSeconds = 84, pagesRead = 0 } } },
|
||||
{ seriesId = 8661, localDate = "2026-09-21T00:00:00", startTimeUtc = "2026-09-21T10:07:50.9423535", chapters = {
|
||||
{ chapterId = 12763, startTimeUtc = "2026-09-21T10:07:50.9423535", durationSeconds = 563, pagesRead = 5 } } },
|
||||
{ seriesId = 7805, localDate = "2026-09-21T00:00:00", startTimeUtc = "2026-09-21T09:56:54.7828239", chapters = {
|
||||
{ chapterId = 11791, startTimeUtc = "2026-09-21T09:56:54.7828239", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 9110, localDate = "2026-09-21T00:00:00", startTimeUtc = "2026-09-21T04:49:43.5918775", chapters = {
|
||||
{ chapterId = 13318, startTimeUtc = "2026-09-21T04:49:43.5918775", durationSeconds = 207, pagesRead = 4 } } },
|
||||
{ seriesId = 7603, localDate = "2026-09-21T00:00:00", startTimeUtc = "2026-09-21T04:49:04.8491169", chapters = {
|
||||
{ chapterId = 11484, startTimeUtc = "2026-09-21T04:49:04.8491169", durationSeconds = 6, pagesRead = 4 } } },
|
||||
{ seriesId = 7603, localDate = "2026-09-21T00:00:00", startTimeUtc = "2026-09-21T03:38:08.3558687", chapters = {
|
||||
{ chapterId = 11484, startTimeUtc = "2026-09-21T03:38:08.3558687", durationSeconds = 8, pagesRead = 4 } } },
|
||||
{ seriesId = 8247, localDate = "2026-09-20T00:00:00", startTimeUtc = "2026-09-20T14:14:20.693305", chapters = {
|
||||
{ chapterId = 12300, startTimeUtc = "2026-09-20T14:14:20.693305", durationSeconds = 86, pagesRead = 6 } } },
|
||||
{ seriesId = 8281, localDate = "2026-09-20T00:00:00", startTimeUtc = "2026-09-20T14:11:24.8897015", chapters = {
|
||||
{ chapterId = 12334, startTimeUtc = "2026-09-20T14:11:24.8897015", durationSeconds = 25, pagesRead = 1 } } },
|
||||
{ seriesId = 7476, localDate = "2026-09-20T00:00:00", startTimeUtc = "2026-09-20T13:17:19.1246015", chapters = {
|
||||
{ chapterId = 11317, startTimeUtc = "2026-09-20T13:17:19.1246015", durationSeconds = 34, pagesRead = 7 } } },
|
||||
{ seriesId = 7805, localDate = "2026-09-20T00:00:00", startTimeUtc = "2026-09-20T13:07:24.1160188", chapters = {
|
||||
{ chapterId = 11791, startTimeUtc = "2026-09-20T13:07:24.1160188", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 8310, localDate = "2026-09-20T00:00:00", startTimeUtc = "2026-09-20T09:52:07.5117003", chapters = {
|
||||
{ chapterId = 12363, startTimeUtc = "2026-09-20T09:52:07.5117003", durationSeconds = 671, pagesRead = 3 } } },
|
||||
{ seriesId = 8310, localDate = "2026-09-20T00:00:00", startTimeUtc = "2026-09-20T09:32:51.5623005", chapters = {
|
||||
{ chapterId = 12363, startTimeUtc = "2026-09-20T09:32:51.5623005", durationSeconds = 364, pagesRead = 1 } } },
|
||||
{ seriesId = 8106, localDate = "2026-09-20T00:00:00", startTimeUtc = "2026-09-20T08:11:17.3798059", chapters = {
|
||||
{ chapterId = 12122, startTimeUtc = "2026-09-20T08:11:17.3798059", durationSeconds = 35, pagesRead = 5 } } },
|
||||
{ seriesId = 7510, localDate = "2026-09-20T00:00:00", startTimeUtc = "2026-09-20T07:50:30.9737641", chapters = {
|
||||
{ chapterId = 11360, startTimeUtc = "2026-09-20T07:50:30.9737641", durationSeconds = 19, pagesRead = 0 } } },
|
||||
{ seriesId = 7805, localDate = "2026-09-20T00:00:00", startTimeUtc = "2026-09-20T07:47:25.7922257", chapters = {
|
||||
{ chapterId = 11791, startTimeUtc = "2026-09-20T07:47:25.7922257", durationSeconds = 3, pagesRead = 0 } } },
|
||||
{ seriesId = 7461, localDate = "2026-09-20T00:00:00", startTimeUtc = "2026-09-20T07:25:56.7820012", chapters = {
|
||||
{ chapterId = 11312, startTimeUtc = "2026-09-20T07:25:56.7820012", durationSeconds = 427, pagesRead = 2 } } },
|
||||
{ seriesId = 7461, localDate = "2026-09-20T00:00:00", startTimeUtc = "2026-09-20T07:01:03.0337544", chapters = {
|
||||
{ chapterId = 11312, startTimeUtc = "2026-09-20T07:01:03.0337544", durationSeconds = 311, pagesRead = 0 } } },
|
||||
{ seriesId = 7461, localDate = "2026-09-20T00:00:00", startTimeUtc = "2026-09-20T04:37:11.2011378", chapters = {
|
||||
{ chapterId = 11312, startTimeUtc = "2026-09-20T04:37:11.2011378", durationSeconds = 407, pagesRead = 0 } } },
|
||||
{ seriesId = 7460, localDate = "2026-09-20T00:00:00", startTimeUtc = "2026-09-20T04:29:53.9882097", chapters = {
|
||||
{ chapterId = 11285, startTimeUtc = "2026-09-20T04:29:53.9882097", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7461, localDate = "2026-09-20T00:00:00", startTimeUtc = "2026-09-20T03:23:39.822214", chapters = {
|
||||
{ chapterId = 11312, startTimeUtc = "2026-09-20T03:23:39.822214", durationSeconds = 431, pagesRead = 0 } } },
|
||||
{ seriesId = 7461, localDate = "2026-09-19T00:00:00", startTimeUtc = "2026-09-19T14:37:14.3112506", chapters = {
|
||||
{ chapterId = 11312, startTimeUtc = "2026-09-19T14:37:14.3112506", durationSeconds = 460, pagesRead = 0 } } },
|
||||
{ seriesId = 7461, localDate = "2026-09-19T00:00:00", startTimeUtc = "2026-09-19T14:16:12.9574126", chapters = {
|
||||
{ chapterId = 11312, startTimeUtc = "2026-09-19T14:16:12.9574126", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7461, localDate = "2026-09-19T00:00:00", startTimeUtc = "2026-09-19T13:33:23.8175739", chapters = {
|
||||
{ chapterId = 11312, startTimeUtc = "2026-09-19T13:33:23.8175739", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7461, localDate = "2026-09-19T00:00:00", startTimeUtc = "2026-09-19T13:01:57.6991072", chapters = {
|
||||
{ chapterId = 11312, startTimeUtc = "2026-09-19T13:01:57.6991072", durationSeconds = 102, pagesRead = 0 } } },
|
||||
{ seriesId = 7461, localDate = "2026-09-19T00:00:00", startTimeUtc = "2026-09-19T10:51:52.8573558", chapters = {
|
||||
{ chapterId = 11312, startTimeUtc = "2026-09-19T10:51:52.8573558", durationSeconds = 445, pagesRead = 0 } } },
|
||||
{ seriesId = 7461, localDate = "2026-09-19T00:00:00", startTimeUtc = "2026-09-19T09:58:37.3332857", chapters = {
|
||||
{ chapterId = 11312, startTimeUtc = "2026-09-19T09:58:37.3332857", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7461, localDate = "2026-09-19T00:00:00", startTimeUtc = "2026-09-19T06:19:27.9750172", chapters = {
|
||||
{ chapterId = 11312, startTimeUtc = "2026-09-19T06:19:27.9750172", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7461, localDate = "2026-09-19T00:00:00", startTimeUtc = "2026-09-19T05:44:36.041471", chapters = {
|
||||
{ chapterId = 11312, startTimeUtc = "2026-09-19T05:44:36.041471", durationSeconds = 500, pagesRead = 0 } } },
|
||||
{ seriesId = 7461, localDate = "2026-09-19T00:00:00", startTimeUtc = "2026-09-19T05:08:30.2036102", chapters = {
|
||||
{ chapterId = 11312, startTimeUtc = "2026-09-19T05:08:30.2036102", durationSeconds = 263, pagesRead = 4 } } },
|
||||
{ seriesId = 7560, localDate = "2026-09-19T00:00:00", startTimeUtc = "2026-09-19T04:47:13.2207635", chapters = {
|
||||
{ chapterId = 11430, startTimeUtc = "2026-09-19T04:47:13.2207635", durationSeconds = 1, pagesRead = 1 } } },
|
||||
{ seriesId = 7556, localDate = "2026-09-19T00:00:00", startTimeUtc = "2026-09-19T04:07:25.0646351", chapters = {
|
||||
{ chapterId = 11426, startTimeUtc = "2026-09-19T04:07:25.0646351", durationSeconds = 0, pagesRead = 1 } } },
|
||||
{ seriesId = 7561, localDate = "2026-09-19T00:00:00", startTimeUtc = "2026-09-19T03:29:58.6171005", chapters = {
|
||||
{ chapterId = 11438, startTimeUtc = "2026-09-19T03:29:58.6171005", durationSeconds = 5, pagesRead = 4 } } },
|
||||
{ seriesId = 7461, localDate = "2026-09-19T00:00:00", startTimeUtc = "2026-09-19T02:37:58.1533148", chapters = {
|
||||
{ chapterId = 11312, startTimeUtc = "2026-09-19T02:37:58.1533148", durationSeconds = 524, pagesRead = 0 } } },
|
||||
{ seriesId = 7461, localDate = "2026-09-19T00:00:00", startTimeUtc = "2026-09-19T02:00:00.8956888", chapters = {
|
||||
{ chapterId = 11312, startTimeUtc = "2026-09-19T02:00:00.8956888", durationSeconds = 524, pagesRead = 1 } } },
|
||||
{ seriesId = 7461, localDate = "2026-09-18T00:00:00", startTimeUtc = "2026-09-18T13:54:08.9566107", chapters = {
|
||||
{ chapterId = 11312, startTimeUtc = "2026-09-18T13:54:08.9566107", durationSeconds = 174, pagesRead = 0 } } },
|
||||
{ seriesId = 7461, localDate = "2026-09-18T00:00:00", startTimeUtc = "2026-09-18T12:53:09.8665339", chapters = {
|
||||
{ chapterId = 11312, startTimeUtc = "2026-09-18T12:53:09.8665339", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7461, localDate = "2026-09-18T00:00:00", startTimeUtc = "2026-09-18T09:50:06.0469366", chapters = {
|
||||
{ chapterId = 11312, startTimeUtc = "2026-09-18T09:50:06.0469366", durationSeconds = 0, pagesRead = 0 } } },
|
||||
{ seriesId = 7461, localDate = "2026-09-18T00:00:00", startTimeUtc = "2026-09-18T09:25:33.4181389", chapters = {
|
||||
{ chapterId = 11312, startTimeUtc = "2026-09-18T09:25:33.4181389", durationSeconds = 738, pagesRead = 1 } } },
|
||||
{ seriesId = 7490, localDate = "2026-09-18T00:00:00", startTimeUtc = "2026-09-18T07:52:05.2045118", chapters = {
|
||||
{ chapterId = 11335, startTimeUtc = "2026-09-18T07:52:05.2045118", durationSeconds = 6, pagesRead = 2 } } },
|
||||
{ seriesId = 7476, localDate = "2026-09-18T00:00:00", startTimeUtc = "2026-09-18T06:59:54.0156885", chapters = {
|
||||
{ chapterId = 11317, startTimeUtc = "2026-09-18T06:59:54.0156885", durationSeconds = 2, pagesRead = 2 } } },
|
||||
{ seriesId = 7461, localDate = "2026-09-18T00:00:00", startTimeUtc = "2026-09-18T06:47:37.6019707", chapters = {
|
||||
{ chapterId = 11312, startTimeUtc = "2026-09-18T06:47:37.6019707", durationSeconds = 0, pagesRead = 0 } } },
|
||||
}
|
||||
@@ -0,0 +1,202 @@
|
||||
--[[--
|
||||
moonsource_kavita.kamare_update:kamare 目标描述(只问 api.github.com、探测已装版本、装到 kamare 目录)。流程本身由 features.update 的 spec 覆盖。
|
||||
|
||||
@module tests.moonsource_kavita.kamare_update_spec
|
||||
--]]
|
||||
---@diagnostic disable: undefined-field, missing-fields, inject-field
|
||||
|
||||
local Assert = require("support.assert")
|
||||
|
||||
local shown, closed, ticks = {}, {}, {}
|
||||
local restarted = 0
|
||||
package.preload["ui/uimanager"] = function()
|
||||
return {
|
||||
nextTick = function(_, fn) ticks[#ticks + 1] = fn end,
|
||||
}
|
||||
end
|
||||
local function flush()
|
||||
while #ticks > 0 do table.remove(ticks, 1)() end
|
||||
end
|
||||
local connected = true
|
||||
package.preload["ui/network/manager"] = function()
|
||||
return { isConnected = function() return connected end }
|
||||
end
|
||||
package.preload["json"] = function()
|
||||
return { decode = function(value) return value end }
|
||||
end
|
||||
package.preload["utils.log"] = function()
|
||||
return { warn = function() end, dbg = function() end, info = function() end }
|
||||
end
|
||||
package.preload["utils.paths"] = function()
|
||||
return {
|
||||
ensureDir = function() return true end,
|
||||
root = function() return "/tmp" end,
|
||||
}
|
||||
end
|
||||
|
||||
-- 探测结果与安装根目录由用例控制。
|
||||
local probe_result = { ok = false, state = "missing" }
|
||||
local plugins_dir = "/fake/plugins"
|
||||
package.preload["moonsource_kavita.cache"] = function()
|
||||
return {
|
||||
probe = function() return probe_result end,
|
||||
pluginsDir = function() return plugins_dir end,
|
||||
}
|
||||
end
|
||||
|
||||
local function dialogModule()
|
||||
return {
|
||||
new = function(_, opts)
|
||||
function opts:show() shown[#shown + 1] = self end
|
||||
function opts:close() closed[#closed + 1] = self end
|
||||
return opts
|
||||
end,
|
||||
}
|
||||
end
|
||||
package.preload["ui.themes.widgets.text_viewer"] = dialogModule
|
||||
package.preload["ui.themes.widgets.toast"] = dialogModule
|
||||
package.preload["ui.themes.widgets.progress_dialog"] = function()
|
||||
return {
|
||||
new = function(_, opts)
|
||||
function opts:show() shown[#shown + 1] = self end
|
||||
function opts:close() closed[#closed + 1] = self end
|
||||
function opts:bytes(done, total)
|
||||
self.progress, self.progress_max = done, total
|
||||
end
|
||||
function opts:set(text, percent)
|
||||
self.status, self.percent = text, percent
|
||||
end
|
||||
return opts
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
||||
local check_cbs, gets = {}, 0
|
||||
local download_cb, download_opts
|
||||
package.preload["http.request"] = function()
|
||||
return {
|
||||
get = function(url, _, cb)
|
||||
gets = gets + 1
|
||||
check_cbs[#check_cbs + 1] = { url = url, cb = cb }
|
||||
return { cancel = function() end }
|
||||
end,
|
||||
download = function(opts, _, cb)
|
||||
download_opts, download_cb = opts, cb
|
||||
return { cancel = function() end }
|
||||
end,
|
||||
}
|
||||
end
|
||||
local pick_calls = 0
|
||||
package.preload["http.github"] = function()
|
||||
return {
|
||||
pickRelease = function(release, cb)
|
||||
pick_calls = pick_calls + 1
|
||||
cb(release.url)
|
||||
return { cancel = function() end }
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
||||
local job_opts, job_worker
|
||||
package.preload["workers.job"] = function()
|
||||
return {
|
||||
run = function(worker, opts)
|
||||
job_worker, job_opts = worker, opts
|
||||
return { cancel = function() end }
|
||||
end,
|
||||
}
|
||||
end
|
||||
local install_args
|
||||
package.preload["utils.plugin_install"] = function()
|
||||
return {
|
||||
run = function(archive, parent, sha, opts)
|
||||
install_args = { archive = archive, parent = parent, sha = sha, opts = opts }
|
||||
return true, "kamare.koplugin"
|
||||
end,
|
||||
}
|
||||
end
|
||||
package.preload["utils.restart"] = function()
|
||||
return { now = function() restarted = restarted + 1 end }
|
||||
end
|
||||
|
||||
local Kamare = require("moonsource_kavita.kamare_update")
|
||||
|
||||
local hash = string.rep("a", 64)
|
||||
local direct = "https://github.com/backtracker/kamare.koplugin/releases/download/v0.10.4/kamare.koplugin.zip"
|
||||
local function release(tag, digest)
|
||||
local asset = {
|
||||
name = "kamare.koplugin.zip",
|
||||
browser_download_url = "https://github.com/backtracker/kamare.koplugin/releases/download/"
|
||||
.. tag .. "/kamare.koplugin.zip",
|
||||
size = 2048,
|
||||
}
|
||||
if digest ~= false then asset.digest = "sha256:" .. hash end
|
||||
return { tag_name = tag, body = "## 新增\n\n- **蓝牙翻页器**\n", assets = { asset } }
|
||||
end
|
||||
|
||||
---@return table|nil, any
|
||||
local function check(response)
|
||||
local got, got_err
|
||||
check_cbs = {}
|
||||
Kamare:check(function(r, e) got, got_err = r, e end)
|
||||
for _idx, entry in ipairs(check_cbs) do entry.cb(response) end
|
||||
flush()
|
||||
return got, got_err
|
||||
end
|
||||
|
||||
-- 版本和 digest 先问 api.ankio.net 的转发。
|
||||
check_cbs = {}
|
||||
Kamare:check(function() end)
|
||||
Assert.eq(#check_cbs, 1)
|
||||
Assert.eq(check_cbs[1].url, "https://api.ankio.net/gh/repos/backtracker/kamare.koplugin/releases/latest")
|
||||
check_cbs[1].cb(release("v0.10.4"))
|
||||
flush()
|
||||
|
||||
-- 已装版本来自探测;没装 / 官方版同版本也要提示安装。
|
||||
probe_result = { ok = true, state = "enhanced", version = "0.10.4-dev" }
|
||||
local parsed = check(release("v0.10.4"))
|
||||
Assert.eq(parsed.installed, "0.10.4-dev")
|
||||
Assert.eq(parsed.sha256, hash)
|
||||
Assert.is_true(parsed.available, "开发版低于同号正式版")
|
||||
probe_result = { ok = true, state = "enhanced", version = "0.10.4" }
|
||||
Assert.is_false(check(release("v0.10.4")).available)
|
||||
probe_result = { ok = false, state = "official", version = "0.10.4" }
|
||||
Assert.is_true(check(release("v0.10.4")).available)
|
||||
Assert.is_nil(check(release("v0.10.4", false)).sha256, "kamare 的 digest 可选")
|
||||
|
||||
-- 已是最新:toast 带 kamare 前缀;没装:安装提示。
|
||||
local function startCheck(response)
|
||||
shown, closed = {}, {}
|
||||
check_cbs = {}
|
||||
Kamare:manualCheck(nil)
|
||||
for _idx, entry in ipairs(check_cbs) do entry.cb(response) end
|
||||
flush()
|
||||
end
|
||||
probe_result = { ok = true, state = "enhanced", version = "0.10.4" }
|
||||
startCheck(release("v0.10.4"))
|
||||
Assert.matches(shown[#shown].text, "已是最新版本(kamare 0%.10%.4)")
|
||||
probe_result = { ok = false, state = "missing" }
|
||||
startCheck(release("v0.10.4"))
|
||||
local prompt = shown[#shown]
|
||||
Assert.eq(prompt.title, "更新 kamare")
|
||||
Assert.matches(prompt.text, "当前未安装可用的 kamare 增强版")
|
||||
|
||||
-- 装到 kamare 当前所在目录,带目录名;没有 digest 只直连。
|
||||
plugins_dir = "/mnt/us/koreader/plugins"
|
||||
prompt.buttons[2].callback()
|
||||
Assert.eq(download_opts.url, direct)
|
||||
download_cb(true)
|
||||
job_worker()
|
||||
Assert.eq(install_args.sha, hash)
|
||||
Assert.eq(install_args.opts.name, "kamare.koplugin")
|
||||
Assert.eq(install_args.parent, plugins_dir)
|
||||
job_opts.on_done()
|
||||
flush()
|
||||
Assert.eq(restarted, 1)
|
||||
|
||||
local nosha = check(release("v0.10.4", false))
|
||||
pick_calls = 0
|
||||
Kamare:install(nosha, nil, function() end)
|
||||
Assert.eq(pick_calls, 0, "没有 digest 不走镜像")
|
||||
|
||||
return true
|
||||
@@ -0,0 +1,108 @@
|
||||
--[[--
|
||||
Kavita 一次性迁移:卷行继承容器元数据并退出书架。
|
||||
|
||||
@module tests.moonsource_kavita.migration_spec
|
||||
--]]
|
||||
|
||||
local Assert = require("support.assert")
|
||||
local Config = require("support.config")
|
||||
|
||||
local db_path = Config.dir() .. "/kavita_migration_spec.sqlite3"
|
||||
local state_path = Config.dir() .. "/settings/moonsource_kavita_meta.lua"
|
||||
for _idx, suffix in ipairs({ "", "-wal", "-shm" }) do os.remove(db_path .. suffix) end
|
||||
for _idx, suffix in ipairs({ "", ".old" }) do os.remove(state_path .. suffix) end
|
||||
|
||||
package.loaded["utils.paths"] = nil
|
||||
package.preload["utils.paths"] = function()
|
||||
return { dbPath = function() return db_path end, ensureSettings = function() end,
|
||||
sanitizeSourceId = function(id) return id end }
|
||||
end
|
||||
|
||||
local DB = require("utils.db")
|
||||
require("book.books_db")
|
||||
Assert.not_nil(DB.open())
|
||||
|
||||
local function insert(source_id, stable_id, authors, intro, deleted, sync_status, path)
|
||||
Assert.is_true(DB.exec([[
|
||||
INSERT INTO books (source_id, stable_id, title, authors, intro, deleted, sync_status, path)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?);
|
||||
]], source_id, stable_id, "书 " .. stable_id, authors, intro, deleted, sync_status, path))
|
||||
end
|
||||
|
||||
insert("kavita", "10", "容器作者", "容器简介", 0, 1, nil)
|
||||
insert("kavita", "10:100", nil, "", 0, 0, "/books/volume.epub")
|
||||
insert("kavita", "10:101", "卷作者", "卷简介", 0, 0, nil)
|
||||
insert("kavita", "10:102", nil, nil, 1, 0, nil)
|
||||
insert("other", "10:100", nil, "", 0, 0, nil)
|
||||
|
||||
local cfg = { base_url = "http://kavita/", api_key = "key" }
|
||||
package.loaded["utils.settings"] = {
|
||||
getSource = function() return cfg end,
|
||||
saveSource = function() end,
|
||||
}
|
||||
package.loaded["source.base"] = {
|
||||
loadMeta = function(id) return { id = id, name = "Kavita", type = "book" } end,
|
||||
capabilities = function() return {} end,
|
||||
defer = function(_self, cb, ...)
|
||||
local args = { ... }
|
||||
cb(unpack(args))
|
||||
return { cancel = function() end }
|
||||
end,
|
||||
}
|
||||
package.loaded["moonsource_kavita.client"] = { new = function(options) return options end }
|
||||
package.loaded["moonsource_kavita.annotation"] = {}
|
||||
package.loaded["moonsource_kavita.position"] = {}
|
||||
package.loaded["moonsource_kavita.stats"] = {}
|
||||
package.loaded["moonsource_kavita.cache"] = { resetShelf = function() end }
|
||||
package.loaded["moonsource_kavita.volume_list"] = {}
|
||||
package.loaded["book.note.normalize"] = {}
|
||||
|
||||
local Source = dofile((debug.getinfo(1, "S").source:match("^@(.-)/tests/") .. "/moonsource-kavita.koplugin/moonsource_kavita") .. "/source.lua")
|
||||
Source.new()
|
||||
|
||||
local function row(source_id, stable_id)
|
||||
local authors, intro, deleted, sync_status, path = DB.rowexec([[
|
||||
SELECT authors, intro, deleted, sync_status, path FROM books
|
||||
WHERE source_id=? AND stable_id=?;
|
||||
]], source_id, stable_id)
|
||||
return authors, intro, tonumber(deleted), tonumber(sync_status), path
|
||||
end
|
||||
|
||||
local authors, intro, deleted, sync_status, path = row("kavita", "10:100")
|
||||
Assert.eq(authors, "容器作者")
|
||||
Assert.eq(intro, "容器简介")
|
||||
Assert.eq(deleted, 1, "卷行从书架隐藏")
|
||||
Assert.eq(sync_status, 1, "迁移后的远端卷行标为已同步")
|
||||
Assert.eq(path, "/books/volume.epub", "保留已下载文件路径")
|
||||
|
||||
authors, intro, deleted, sync_status = row("kavita", "10:101")
|
||||
Assert.eq(authors, "卷作者", "保留已有作者")
|
||||
Assert.eq(intro, "卷简介", "保留已有简介")
|
||||
Assert.eq(deleted, 1, "所有旧卷行都从书架隐藏")
|
||||
Assert.eq(sync_status, 1)
|
||||
|
||||
authors, intro, deleted, sync_status = row("kavita", "10:102")
|
||||
Assert.eq(authors, "容器作者", "已隐藏卷行也补齐元数据")
|
||||
Assert.eq(intro, "容器简介")
|
||||
Assert.eq(deleted, 1)
|
||||
Assert.eq(sync_status, 0, "不改原本已隐藏行的脏状态")
|
||||
|
||||
authors, intro, deleted = row("other", "10:100")
|
||||
Assert.is_nil(authors, "迁移只影响 Kavita")
|
||||
Assert.eq(intro, "")
|
||||
Assert.eq(deleted, 0)
|
||||
|
||||
local state = require("luasettings"):open(
|
||||
require("datastorage"):getSettingsDir() .. "/moonsource_kavita_meta.lua")
|
||||
Assert.eq(tonumber(state:readSetting("schema_version")), 1)
|
||||
|
||||
insert("kavita", "10:103", nil, nil, 0, 0, nil)
|
||||
Source.new()
|
||||
local _, _, still_visible = row("kavita", "10:103")
|
||||
Assert.eq(still_visible, 0, "schema_version 阻止重复迁移")
|
||||
|
||||
DB.close()
|
||||
for _idx, suffix in ipairs({ "", "-wal", "-shm" }) do os.remove(db_path .. suffix) end
|
||||
for _idx, suffix in ipairs({ "", ".old" }) do os.remove(state_path .. suffix) end
|
||||
|
||||
return true
|
||||
@@ -0,0 +1,171 @@
|
||||
--[[--
|
||||
extensions/moonsource-kavita.koplugin 首页组件 On Deck:在线且已配置才拉,5 分钟内复用;
|
||||
两行 × 5 列封面网格(网格尺寸走 CoverCell.denseCoverMetrics / Book.widget,同首页最近阅读),
|
||||
点开走月读开书;失败 / 空列表 / 离线给提示。
|
||||
|
||||
@module tests.moonsource_kavita.on_deck_spec
|
||||
--]]
|
||||
---@diagnostic disable: undefined-field, missing-fields, inject-field
|
||||
|
||||
local Assert = require("support.assert")
|
||||
local Config = require("support.config")
|
||||
local Kit = require("support.widget_stubs")
|
||||
Kit.install("paper")
|
||||
local Themed = require("support.theme_stubs")
|
||||
Themed.install()
|
||||
local Widget = require("ui/widget/widget")
|
||||
|
||||
local TITLE_EXTRA = 26
|
||||
local covers = {}
|
||||
package.preload["ui.widgets.book"] = function()
|
||||
return {
|
||||
captionExtra = function(show_title) return show_title ~= false and TITLE_EXTRA or 0 end,
|
||||
widget = function(_plugin, _source, book, cw, ch, opts)
|
||||
local slot_w = (opts and opts.slot_w) or cw
|
||||
covers[#covers + 1] = { book = book, w = cw, h = ch, slot_w = slot_w, home = opts and opts.home }
|
||||
return Widget:new{ dimen = { w = slot_w, h = ch + TITLE_EXTRA } }
|
||||
end,
|
||||
}
|
||||
end
|
||||
package.preload["ui.widgets.cover"] = function()
|
||||
return {
|
||||
gridCoverMaxH = function() return 320 end,
|
||||
denseCoverMetrics = function(w, _budget, opts)
|
||||
local cols = opts.min_cols or 5
|
||||
local gap, row_gap = 8, 10
|
||||
local slot_w = math.max(1, math.floor((w - gap * (cols - 1)) / cols))
|
||||
local cw = slot_w
|
||||
local ch = math.min(math.floor(cw * 3 / 2), opts.max_h or 320)
|
||||
return slot_w, cw, ch, cols, gap, row_gap, ch + opts.title_extra
|
||||
end,
|
||||
}
|
||||
end
|
||||
local opened = {}
|
||||
package.preload["desktop.open"] = function()
|
||||
return { book = function(_plugin, book) opened[#opened + 1] = book end }
|
||||
end
|
||||
|
||||
local online, configured = true, true
|
||||
package.loaded["ui/network/manager"] = { isConnected = function() return online end }
|
||||
local calls, reply = {}, nil
|
||||
local source = {
|
||||
configured = function() return configured end,
|
||||
client = {
|
||||
json = function(_self, method, path, query, body, cb)
|
||||
calls[#calls + 1] = { method = method, path = path, query = query, body = body }
|
||||
reply = cb
|
||||
return { cancel = function() reply = nil end }
|
||||
end,
|
||||
},
|
||||
}
|
||||
package.loaded["source.registry"] = { resolve = function(id) return id == "kavita" and source or nil end }
|
||||
|
||||
local Deck = dofile((debug.getinfo(1, "S").source:match("^@(.-)/tests/") .. "/moonsource-kavita.koplugin/moonsource_kavita") .. "/on_deck.lua")
|
||||
Assert.eq(Deck.id, "kavita.on_deck")
|
||||
|
||||
local desktop = { plugin = {} }
|
||||
local deck = Deck:new{}
|
||||
deck:build({ desktop = desktop, plugin = desktop.plugin },
|
||||
{ width = 300, height = deck:heightRange(nil, { width = 300 }).height })
|
||||
Assert.contains(Kit.texts(deck.slot), "联网后显示 Kavita 上在读的书")
|
||||
|
||||
-- 激活拉一次:POST on-deck,进度按 pagesRead / pages。
|
||||
deck:activate()
|
||||
Assert.len(calls, 1)
|
||||
Assert.eq(calls[1].method, "POST")
|
||||
Assert.eq(calls[1].path, "/api/Series/on-deck")
|
||||
Assert.eq(calls[1].query.pageSize, 10)
|
||||
local list = {}
|
||||
for i = 1, 12 do list[i] = { id = i, name = "S" .. i, pages = 10, pagesRead = i } end
|
||||
reply(list)
|
||||
Assert.eq(deck.data[3].stable_id, "3")
|
||||
Assert.eq(deck.data[3].source_id, "kavita")
|
||||
Assert.eq(deck.data[3].percent, 30)
|
||||
-- 一页 4 本(跟首页最近阅读一样),12 本分 3 页。
|
||||
Assert.eq(#covers, 4, "一页 4 本")
|
||||
Assert.is_true(covers[1].home, "On Deck 走首页封面策略")
|
||||
Assert.eq(covers[1].book.title, "S1")
|
||||
Assert.contains(Kit.texts(deck.slot), "1 / 3")
|
||||
|
||||
-- 一页 4 本、多的分页:翻到后面不该重画前面的书。
|
||||
covers = {}
|
||||
deck.page = 2
|
||||
deck:refresh()
|
||||
Assert.eq(#covers, 4)
|
||||
Assert.eq(covers[1].book.title, "S5", "第二页从第 5 本开始")
|
||||
Assert.contains(Kit.texts(deck.slot), "2 / 3")
|
||||
deck.page = 3
|
||||
covers = {}
|
||||
deck:refresh()
|
||||
Assert.eq(#covers, 4, "最后一页 4 本")
|
||||
Assert.eq(covers[1].book.title, "S9")
|
||||
deck.page = 1
|
||||
covers = {}
|
||||
deck:refresh()
|
||||
|
||||
-- 5 分钟内重新激活不再请求;过期再拉。
|
||||
deck:deactivate()
|
||||
deck:activate()
|
||||
Assert.len(calls, 1)
|
||||
deck.loaded_at = os.time() - 301
|
||||
deck:deactivate()
|
||||
deck:activate()
|
||||
Assert.len(calls, 2)
|
||||
|
||||
-- 离开首页取消在飞请求;失败显示原因;空列表给提示。
|
||||
deck:deactivate()
|
||||
Assert.is_nil(reply)
|
||||
deck.loaded_at = nil
|
||||
deck:activate()
|
||||
reply(nil, "API Key 无效")
|
||||
Assert.eq(covers[1].book.title, "S1", "失败保留上次的列表")
|
||||
deck.data, deck.loaded_at = nil, nil
|
||||
deck:deactivate()
|
||||
deck:activate()
|
||||
reply(nil, "API Key 无效")
|
||||
Assert.contains(Kit.texts(deck.slot), "API Key 无效")
|
||||
deck.loaded_at = nil
|
||||
deck:deactivate()
|
||||
deck:activate()
|
||||
reply({})
|
||||
Assert.contains(Kit.texts(deck.slot), "Kavita 上没有在读的书")
|
||||
|
||||
-- 离线 / 未配置不请求。
|
||||
local before = #calls
|
||||
deck.loaded_at = nil
|
||||
deck:deactivate()
|
||||
online = false
|
||||
deck:activate()
|
||||
deck:deactivate()
|
||||
online, configured = true, false
|
||||
deck:activate()
|
||||
Assert.len(calls, before)
|
||||
|
||||
-- 点封面走月读开书。
|
||||
deck.data = { { source_id = "kavita", stable_id = "9", title = "九" } }
|
||||
deck:refresh()
|
||||
local taps = Kit.taps(deck.slot)
|
||||
Assert.len(taps, 1)
|
||||
taps[1]:onTapThemeArea()
|
||||
Assert.eq(opened[1].stable_id, "9")
|
||||
|
||||
-- 一页 4 本,封面按宽度分满,槽宽/封面宽一致,10 本分 3 页。
|
||||
covers = {}
|
||||
online, configured = true, true
|
||||
local wide = Deck:new{}
|
||||
local nat = wide:heightRange(nil, { width = 568 }).height
|
||||
wide:build({ desktop = desktop, plugin = desktop.plugin }, { width = 568, height = nat })
|
||||
wide:activate()
|
||||
local ten = {}
|
||||
for i = 1, 10 do ten[i] = { id = i, name = "S" .. i, pages = 10, pagesRead = i } end
|
||||
reply(ten)
|
||||
Assert.len(wide.data, 10)
|
||||
Assert.eq(#covers, 4, "每页 4 本")
|
||||
Assert.contains(Kit.texts(wide.slot), "1 / 3")
|
||||
-- 内容高不能超过 heightRange(超了 widget 会掉出槽位)。
|
||||
Assert.is_true(wide.slot[1]:getSize().h <= nat, "内容高不超过 heightRange")
|
||||
-- 每格用同一个槽宽(Book.widget 把封面居中到 slot_w),不会有一本看着变小 / 错位。
|
||||
for _i, c in ipairs(covers) do
|
||||
Assert.eq(c.slot_w, covers[1].slot_w, "每格槽宽一致")
|
||||
Assert.eq(c.w, covers[1].w, "每格封面宽一致")
|
||||
end
|
||||
@@ -0,0 +1,90 @@
|
||||
--[[--
|
||||
extensions/moonsource-kavita.koplugin:xpointer ↔ Kavita pageNum / bookScrollId 换算。
|
||||
|
||||
@module tests.moonsource_kavita.position_spec
|
||||
--]]
|
||||
---@diagnostic disable: undefined-field, missing-fields, inject-field
|
||||
|
||||
local Assert = require("support.assert")
|
||||
local Config = require("support.config")
|
||||
|
||||
local Position = dofile((debug.getinfo(1, "S").source:match("^@(.-)/tests/") .. "/moonsource-kavita.koplugin/moonsource_kavita") .. "/position.lua")
|
||||
|
||||
-- spine:DocFragment[D] = spine D-1;单 spine 书没有下标。
|
||||
Assert.eq(Position.spine("/body/DocFragment[8]/body/p[2]/text().0"), 7)
|
||||
Assert.eq(Position.spine("/body[1]/DocFragment[1]/body[1]/p"), 0)
|
||||
Assert.eq(Position.spine("/body/DocFragment/body/p"), 0)
|
||||
Assert.is_nil(Position.spine(nil))
|
||||
Assert.is_nil(Position.spine("#_doc_fragment_3"))
|
||||
|
||||
-- 上报:补全 [1]、丢文本偏移;两种 crengine 写法都认。
|
||||
Assert.eq(Position.toScrollId("/body/DocFragment[8]/body/section/p[3]/text().0"), "//body/section[1]/p[3]")
|
||||
Assert.eq(Position.toScrollId("/body[1]/DocFragment[8]/body[1]/div[2]/p/text()[1].5"), "//body/div[2]/p[1]")
|
||||
Assert.eq(Position.toScrollId("/body/DocFragment/body/p[4]"), "//body/p[4]")
|
||||
Assert.is_nil(Position.toScrollId("/body/DocFragment[2]/body"), "body 本身没有章内位置")
|
||||
Assert.is_nil(Position.toScrollId(nil))
|
||||
|
||||
-- 下行:[1] 省略;读完(pageNum == pages)落回最后一个 spine;单 spine 书不带下标。
|
||||
Assert.eq(Position.toXPointer(7, "//body/section[1]/p[3]", 10), "/body/DocFragment[8]/body/section/p[3]")
|
||||
Assert.eq(Position.toXPointer(10, nil, 10), "/body/DocFragment[10]/body")
|
||||
Assert.eq(Position.toXPointer(0, "//body/p[2]", 1), "/body/DocFragment/body/p[2]")
|
||||
Assert.eq(Position.toXPointer(3, "id(\"x\")", 10), "/body/DocFragment[4]/body", "未解析的锚点只按 spine 定位")
|
||||
|
||||
-- 往返:上报出去的锚点拉回来落在同一段。
|
||||
local here = "/body/DocFragment[5]/body/div[2]/p[7]/text().12"
|
||||
Assert.eq(Position.toXPointer(Position.spine(here), Position.toScrollId(here), 9), "/body/DocFragment[5]/body/div[2]/p[7]")
|
||||
|
||||
-- 网页端的 id("X"):读本地 epub 第 spine 个文档找元素路径。
|
||||
local files = {
|
||||
["META-INF/container.xml"] = [[<container><rootfiles><rootfile full-path="OEBPS/content.opf"/></rootfiles></container>]],
|
||||
["OEBPS/content.opf"] = [[<package><manifest>
|
||||
<item id="c1" href="text/one.xhtml" media-type="application/xhtml+xml"/>
|
||||
<item href="text/two.xhtml" id="c2" media-type="application/xhtml+xml"/>
|
||||
</manifest><spine><itemref idref="c1"/><itemref idref="c2"/></spine></package>]],
|
||||
["OEBPS/text/two.xhtml"] = [[<?xml version="1.0"?><html><body>
|
||||
<section><p>a</p><br/><p>b<img src="x"/></p><div><p id="target">c</p></div></section></body></html>]],
|
||||
}
|
||||
local opened, closed = nil, false
|
||||
package.loaded["ffi/archiver"] = {
|
||||
Reader = {
|
||||
new = function()
|
||||
return {
|
||||
open = function(_self, path) opened = path; return path == "/book.epub" end,
|
||||
iterate = function() return function() end end,
|
||||
extractToMemory = function(_self, name) return files[name] end,
|
||||
close = function() closed = true end,
|
||||
}
|
||||
end,
|
||||
},
|
||||
}
|
||||
Assert.eq(Position.resolveScrollId("/book.epub", 1, 'id("target")'), "//body/section[1]/div[1]/p[1]")
|
||||
Assert.eq(opened, "/book.epub")
|
||||
Assert.is_true(closed)
|
||||
Assert.eq(Position.resolveScrollId(nil, 1, "//body/p[2]"), "//body/p[2]", "自己上报的路径原样用")
|
||||
Assert.is_nil(Position.resolveScrollId("/book.epub", 1, 'id("missing")'))
|
||||
Assert.is_nil(Position.resolveScrollId("/book.epub", 5, 'id("target")'), "spine 越界")
|
||||
Assert.is_nil(Position.resolveScrollId(nil, 1, 'id("target")'), "没下载过的书没法解析")
|
||||
Assert.is_nil(Position.resolveScrollId("/other.epub", 1, 'id("target")'), "打不开的文件")
|
||||
-- 划线锚点:按段落文本找路径,忽略空白、实体、脚注标记;跨段用首末行各定一段。
|
||||
files["OEBPS/text/one.xhtml"] = [[<html><body><p>前言</p>
|
||||
<p>甲乙丙&丁 戊己<sup>¹</sup>[3]庚辛壬癸</p><div><p>子丑寅卯辰巳</p></div></body></html>]]
|
||||
local anchor = Position.anchor("丙&丁\n戊己", "/body/DocFragment[1]/body/p[2]/text().2", "/book.epub")
|
||||
Assert.eq(anchor.pageNumber, 0)
|
||||
Assert.eq(anchor.xPath, "//body/p[2]")
|
||||
Assert.eq(anchor.endingXPath, "//body/p[2]")
|
||||
anchor = Position.anchor("戊己庚辛壬癸\n子丑寅", "/body/DocFragment[1]/body/p[2]/text().6", "/book.epub")
|
||||
Assert.eq(anchor.xPath, "//body/p[2]")
|
||||
Assert.eq(anchor.endingXPath, "//body/div[1]/p[1]", "跨段")
|
||||
anchor = Position.anchor("c", "/body/DocFragment[1]/body/p", "/book.epub")
|
||||
Assert.is_nil(anchor, "单字太短,不猜")
|
||||
anchor = Position.anchor("b", "/body/DocFragment[1]/body/p", "/book.epub")
|
||||
Assert.is_nil(anchor)
|
||||
files["OEBPS/text/two.xhtml"] = files["OEBPS/text/two.xhtml"]:gsub("<p>b", "<p>挪到第二章")
|
||||
anchor = Position.anchor("挪到第二章", "/body/DocFragment[1]/body/p[2]", "/book.epub")
|
||||
Assert.eq(anchor.pageNumber, 1, "pos0 所在 spine 没有就去邻近 spine 找")
|
||||
Assert.eq(anchor.xPath, "//body/section[1]/p[2]")
|
||||
Assert.is_nil(Position.anchor("不存在的文字", "/body/DocFragment[1]/body/p", "/book.epub"))
|
||||
Assert.is_nil(Position.anchor("甲乙丙", "/body/DocFragment[1]/body/p", nil), "没下载过")
|
||||
|
||||
files["META-INF/container.xml"] = nil
|
||||
Assert.is_nil(Position.resolveScrollId("/book.epub", 1, 'id("target")'), "坏 epub 降级成只按 spine")
|
||||
@@ -0,0 +1,385 @@
|
||||
--[[--
|
||||
Kavita 统计对账:真实响应 fixture 走「拉取钩子 → replaceSynced 入库 → 展示查询」全链,
|
||||
逐项对 spec 的验收基线。HTTP 与目录缓存打桩,其余全真:源(分页 / 身份判定 / 物化)、
|
||||
统计纯核心、真实 sqlite 的 reading_stats 与 books 库。
|
||||
|
||||
对账基线(research-kavita-stats-pull.md):
|
||||
§2 全量逐日(29 天 / Σ=60,238s)、§3 样本 7453 逐日(13,921 + 316)、§4 系列累计。
|
||||
数字都来自实测响应(fixture 数值逐条未改),不是照实现倒推的。
|
||||
|
||||
@module tests.moonsource_kavita.reconcile_spec
|
||||
--]]
|
||||
|
||||
local Assert = require("support.assert")
|
||||
local Config = require("support.config")
|
||||
local Json = require("support.json_stub")
|
||||
local Stubs = require("support.stubs")
|
||||
|
||||
-- 日 / 时归属按进程时区(POSIX TZ)计算:钉死 CST-8,与 fixture 拉取时用的 Asia/Shanghai 对齐,
|
||||
-- 断言就不会随宿主机时区漂移。
|
||||
local ffi = require("ffi")
|
||||
ffi.cdef[[ int setenv(const char*, const char*, int); void tzset(void); ]]
|
||||
ffi.C.setenv("TZ", "CST-8", 1)
|
||||
ffi.C.tzset()
|
||||
|
||||
local sqlite_ok = pcall(require, "lua-ljsqlite3/init")
|
||||
if not sqlite_ok then
|
||||
Assert.skip("当前离线环境没有 ljsqlite3 Lua 模块")
|
||||
end
|
||||
|
||||
-- 沙箱库:books 与 reading_stats 同库,物化行和统计行一起对账。
|
||||
local db_path = Config.dir() .. "/kavita_reconcile_spec.sqlite3"
|
||||
for _idx, suffix in ipairs({ "", "-wal", "-shm" }) do os.remove(db_path .. suffix) end
|
||||
package.loaded["utils.paths"] = nil
|
||||
package.preload["utils.paths"] = function()
|
||||
return {
|
||||
dbPath = function() return db_path end,
|
||||
ensureSettings = function() end,
|
||||
sanitizeSourceId = function(id) return id end,
|
||||
}
|
||||
end
|
||||
|
||||
-- 响应体 / 分页头走真实编解码(source_spec 的往返桩同形);books 的 meta 列也用它。
|
||||
package.loaded["json"] = nil
|
||||
package.preload["json"] = function()
|
||||
return { encode = Json.encode, decode = Json.decode }
|
||||
end
|
||||
|
||||
-- 设备时钟(POSIX → IANA 映射)与扩展配置;stats_db 也会问 merge_local_stats(本用例默认关)。
|
||||
local clock = { timezone = "CST-8" }
|
||||
local cfg = { base_url = "http://kav/", api_key = " k ", libraries = { ["8"] = true, ["10"] = true } }
|
||||
package.loaded["utils.settings"] = nil
|
||||
package.preload["utils.settings"] = function()
|
||||
local common = { active_source = "local" }
|
||||
return {
|
||||
get = function(key) return key == "features.clock" and clock or common end,
|
||||
getSource = function() return cfg end,
|
||||
}
|
||||
end
|
||||
|
||||
-- 插件模块走 preload:不把插件根塞进 package.path(main.lua 会顶掉月读的 main)。
|
||||
local PLUGIN = (debug.getinfo(1, "S").source:match("^@(.-)/tests/") .. "/moonsource-kavita.koplugin/moonsource_kavita")
|
||||
for _idx, name in ipairs({ "client", "position", "annotation", "cache", "volume_list", "source", "stats" }) do
|
||||
package.preload["moonsource_kavita" .. (name == "source" and ".source" or "." .. name)] = function()
|
||||
return dofile(PLUGIN .. "/" .. (name == "source" and "source" or name) .. ".lua")
|
||||
end
|
||||
end
|
||||
|
||||
-- HTTP:只服务阅读历史;目录全部命中缓存,物化与身份判定不发请求。
|
||||
-- 分页头与 body 同一套编解码(同真服务端:PageSize=200、总页数在响应头里)。
|
||||
local pagination_calls = {}
|
||||
local sample = dofile((debug.getinfo(1, "S").source:match("^@(.*)/")) .. "/fixtures/history_all.lua")
|
||||
local history = sample
|
||||
local function history_pages()
|
||||
local pages = { {}, {} }
|
||||
for _idx, entry in ipairs(history) do
|
||||
local page = #pages[1] < 200 and 1 or 2
|
||||
pages[page][#pages[page] + 1] = entry
|
||||
end
|
||||
return pages
|
||||
end
|
||||
local function query(opts, key) return opts.url:match("[?&]" .. key .. "=([^&]*)") end
|
||||
package.loaded["http.request"] = {
|
||||
ok = function(code)
|
||||
code = tonumber(code)
|
||||
return code ~= nil and code >= 200 and code < 300
|
||||
end,
|
||||
header = function(res, name)
|
||||
for key, value in pairs(res and res.headers or {}) do
|
||||
if type(key) == "string" and key:lower() == name:lower() then return value end
|
||||
end
|
||||
end,
|
||||
request = function(opts, cb)
|
||||
local page = tonumber(query(opts, "PageNumber")) or 1
|
||||
pagination_calls[#pagination_calls + 1] = opts.url
|
||||
-- 只认阅读历史:目录 / 其它接口意外被请求时返回 404(身份判定该走目录缓存,
|
||||
-- 真机也是:判定结果记在状态文件里,不该为身份反复请求目录)。
|
||||
local history_call = opts.url:find("/api/Stats/reading%-history", 1) ~= nil
|
||||
require("ui/uimanager"):nextTick(function()
|
||||
if not history_call then
|
||||
cb({ code = 404, body = "" })
|
||||
return
|
||||
end
|
||||
cb({
|
||||
code = 200,
|
||||
body = Json.encode(history_pages()[page]),
|
||||
headers = { Pagination = Json.encode({
|
||||
currentPage = page,
|
||||
itemsPerPage = 200,
|
||||
totalItems = #history,
|
||||
totalPages = math.max(1, math.ceil(#history / 200)),
|
||||
}) },
|
||||
})
|
||||
end)
|
||||
return { cancel = function() end }
|
||||
end,
|
||||
}
|
||||
|
||||
-- 目录缓存(source.toc)替身:身份判定只关心「1 章还是多章」,物化只用条目 title。
|
||||
-- 7453 用实测目录(4 卷含卷名,research §5 / series-detail);已知实测章数的系列对齐 §5;
|
||||
-- 其余按云端读到的章构造 —— 判定结果只影响单书身份粒度,不影响账户日桶。
|
||||
local CLOUD_TITLES = {
|
||||
["7453"] = {
|
||||
{ chapterId = 11271, title = "2001:太空漫游" },
|
||||
{ chapterId = 11273, title = "2010:太空漫游" },
|
||||
{ chapterId = 11270, title = "2061:太空漫游" },
|
||||
{ chapterId = 11272, title = "3001:太空漫游" },
|
||||
},
|
||||
}
|
||||
local TOC_COUNTS = { ["7453"] = 4, ["10634"] = 27, ["7460"] = 2, ["10720"] = 5, ["8661"] = 1, ["7606"] = 1 }
|
||||
local tocs = {}
|
||||
for _idx, entry in ipairs(sample) do
|
||||
local series_id = tostring(entry.seriesId)
|
||||
local toc = tocs[series_id]
|
||||
if not toc then toc = {}; tocs[series_id] = toc end
|
||||
-- 全量取并:同一系列各条会话可能各读不同章,真目录里这些章都在。
|
||||
for _i, chapter in ipairs(entry.chapters) do
|
||||
if chapter.chapterId then
|
||||
local known = false
|
||||
for _k, item in ipairs(toc) do
|
||||
if item.chapterId == chapter.chapterId then known = true end
|
||||
end
|
||||
if not known then toc[#toc + 1] = { chapterId = chapter.chapterId } end
|
||||
end
|
||||
end
|
||||
end
|
||||
for series_id, entries in pairs(CLOUD_TITLES) do tocs[series_id] = entries end
|
||||
for series_id, count in pairs(TOC_COUNTS) do
|
||||
-- 补齐到实测章数:补齐条目不带 chapterId,只有 #toc 参与单卷 / 多卷判定。
|
||||
while #tocs[series_id] < count do tocs[series_id][#tocs[series_id] + 1] = {} end
|
||||
end
|
||||
package.loaded["source.toc"] = {
|
||||
read = function(_sid, series_id) return tocs[tostring(series_id)] end,
|
||||
put = function(_sid, series_id, list) tocs[tostring(series_id)] = list; return true end,
|
||||
}
|
||||
|
||||
-- 统计状态文件(上次身份 + 章数判定)是上一轮的残留:连 .old 备份一起清,
|
||||
-- 清了才是「首次拉取」(LuaSettings 读不到主文件会回落 .old)。
|
||||
local STATS_STATE = require("datastorage"):getSettingsDir() .. "/moonsource_kavita_stats.lua"
|
||||
local function clearStatsState()
|
||||
for _idx, suffix in ipairs({ "", ".old" }) do os.remove(STATS_STATE .. suffix) end
|
||||
end
|
||||
clearStatsState()
|
||||
|
||||
local Base = require("utils.db")
|
||||
local StatsDB = require("book.stats_db")
|
||||
local BookDB = require("book.books_db")
|
||||
local ProgressDB = require("book.progress_db")
|
||||
local Kavita = require("moonsource_kavita.source")
|
||||
Assert.not_nil(Base.open())
|
||||
|
||||
-- 书架容器行(书架同步的产物):统计侧只当物化标题 / 元数据来源。作者只给断言用到的那本。
|
||||
local function container(id, title, authors)
|
||||
Assert.is_true(BookDB.upsertRemote({ source_id = "kavita", stable_id = id, title = title,
|
||||
authors = authors, deleted = 0 }, false, true))
|
||||
end
|
||||
container("7453", "太空漫游", "阿瑟·克拉克")
|
||||
container("8661", "人类简史")
|
||||
container("7460", "三国演义")
|
||||
container("10634", "大剑")
|
||||
|
||||
-- 本机逐页记录:10-14 已上报(云端会话已含,不能再算一遍);10-17 拉取后才读(未上报)。
|
||||
local L1_T = os.time({ year = 2026, month = 10, day = 14, hour = 21 })
|
||||
Assert.is_true(StatsDB.add({
|
||||
source_id = "kavita", stable_id = "7453:11273", record_type = "page",
|
||||
page = 30, start_time = L1_T, duration = 900, total_pages = 150,
|
||||
}, StatsDB.SYNCED))
|
||||
|
||||
-- 固定拉取时刻(2026-10-16 20:00 本地,晚于全量最后一天):只看 nil 参数的 os.time。
|
||||
local FETCHED = 1792152000
|
||||
local real_time = os.time
|
||||
os.time = function(t)
|
||||
if t == nil then return FETCHED end
|
||||
return real_time(t)
|
||||
end
|
||||
local source = Kavita.new()
|
||||
|
||||
--- 一次完整的统计同步:拉取 → 入库 → commit(状态文件只在入库成功后前进)。
|
||||
---@return BookStatsPullResult
|
||||
local function pull()
|
||||
local result, err
|
||||
source:pullStatsAsync(function(res, pull_err) result, err = res, pull_err end)
|
||||
Stubs.flush()
|
||||
Assert.not_nil(result, err)
|
||||
Assert.not_nil(StatsDB.replaceSynced("kavita", result.replace, result.rows), "入库必须成功")
|
||||
result.commit()
|
||||
return result
|
||||
end
|
||||
|
||||
local pulled = pull()
|
||||
|
||||
--- 逐日聚合(dailyBySource):ymd → { seconds, pages }。
|
||||
local function calendar()
|
||||
local rows = {}
|
||||
for _idx, row in ipairs(StatsDB.dailyBySource("kavita")) do rows[row.ymd] = row end
|
||||
return rows
|
||||
end
|
||||
|
||||
-- ① 单书累计:与云端 Σ 一致(§3 的 7453 两卷 / §4 的系列累计)。
|
||||
-- 10-14 的本地 900s 已含在云端快照里(sync_status=1 且早于拉取时刻):不加第二遍。
|
||||
Assert.eq(StatsDB.summaryByBook("kavita", "7453:11273").total_seconds, 13921, "样本卷累计 = 云端 Σ")
|
||||
Assert.eq(StatsDB.summaryByBook("kavita", "7453:11271").total_seconds, 316, "同系列另一卷(只在其它设备读过)")
|
||||
Assert.eq(StatsDB.summaryByBook("kavita", "7453").total_seconds, 0, "多卷系列不读在容器行上")
|
||||
Assert.eq(StatsDB.summaryByBook("kavita", "8661").total_seconds, 3555, "单卷系列读在 series 行(§4)")
|
||||
Assert.eq(StatsDB.summaryByBook("kavita", "7460:11285").total_seconds, 9517, "多章目录 → 逐卷身份(§4)")
|
||||
-- 页数:云端会话的 pagesRead + 未被会话覆盖的本地页(18 号票)。10-14 的本地 1 页已上报、
|
||||
-- 当天有会话覆盖,不再加;22 是该卷各云端会话 pagesRead 之和。
|
||||
Assert.eq(StatsDB.summaryByBook("kavita", "7453:11273").pages, 22, "单书页数 = 云端会话 pagesRead 之和")
|
||||
|
||||
-- ② 日历逐日与 §2 一致;合计 = __kv:total。
|
||||
-- 页数口径与 §2 的 hist_p 在 9-19 / 9-24 / 9-29 差 1 / 1 / 2 页:那 4 页来自零时长条目,
|
||||
-- 设计上整条丢弃(§4 已记「零时长条目 100 条,其中带页数 4 条合计 4 页」)。
|
||||
local CLOUD_DAYS = {
|
||||
{ "2026-09-18", 920, 5 }, { "2026-09-19", 2824, 10 }, { "2026-09-20", 2813, 25 },
|
||||
{ "2026-09-21", 1183, 18 }, { "2026-09-22", 1682, 25 }, { "2026-09-23", 406, 18 },
|
||||
{ "2026-09-24", 1179, 114 }, { "2026-09-25", 10, 3 }, { "2026-09-26", 1378, 71 },
|
||||
{ "2026-09-27", 755, 0 }, { "2026-09-28", 104, 0 }, { "2026-09-29", 7942, 312 },
|
||||
{ "2026-09-30", 6640, 22 }, { "2026-10-01", 643, 23 }, { "2026-10-03", 1104, 25 },
|
||||
{ "2026-10-04", 638, 1 }, { "2026-10-05", 195, 0 }, { "2026-10-06", 809, 0 },
|
||||
{ "2026-10-07", 503, 0 }, { "2026-10-08", 3663, 10 }, { "2026-10-09", 1092, 93 },
|
||||
{ "2026-10-10", 363, 10 }, { "2026-10-11", 649, 26 }, { "2026-10-12", 1803, 103 },
|
||||
{ "2026-10-13", 4514, 244 }, { "2026-10-14", 11665, 120 }, { "2026-10-15", 4541, 118 },
|
||||
{ "2026-10-16", 220, 6 },
|
||||
}
|
||||
local days = calendar()
|
||||
local day_count = 0
|
||||
for _ymd in pairs(days) do day_count = day_count + 1 end
|
||||
Assert.eq(day_count, #CLOUD_DAYS, "只有有有效时长的日子落桶(10-02 三条会话全零时长)")
|
||||
Assert.is_nil(days["2026-10-02"], "零时长日不留桶")
|
||||
-- 本地逐页记录按条累加;云端日桶显式 0 页不能被补成 1 页。
|
||||
local ZERO_PAGE_DAYS = 0
|
||||
for _idx, expected in ipairs(CLOUD_DAYS) do
|
||||
local row = days[expected[1]]
|
||||
Assert.not_nil(row, "缺日桶 " .. expected[1])
|
||||
Assert.eq(row.seconds, expected[2], "日时长 " .. expected[1])
|
||||
local stored_pages = expected[3] + (expected[1] == "2026-10-14" and 1 or 0)
|
||||
if expected[3] == 0 then ZERO_PAGE_DAYS = ZERO_PAGE_DAYS + 1 end
|
||||
Assert.eq(row.pages, stored_pages, "日页数增量 " .. expected[1])
|
||||
end
|
||||
Assert.eq(ZERO_PAGE_DAYS, 5, "云端 0 页日就 5 天(09-27 / 09-28 / 10-05~10-07)")
|
||||
local calendar_sum, calendar_pages = 0, 0
|
||||
for _ymd, row in pairs(days) do
|
||||
calendar_sum = calendar_sum + row.seconds
|
||||
calendar_pages = calendar_pages + row.pages
|
||||
end
|
||||
Assert.eq(StatsDB.summaryBySource("kavita").total_pages, calendar_pages, "总页数 = 日历逐日之和")
|
||||
Assert.eq(calendar_sum, 60238, "各日之和 = 云端全量 Σ(§2)")
|
||||
local total_row
|
||||
for _idx, row in ipairs(pulled.rows) do
|
||||
if row.record_type == "total" then total_row = row end
|
||||
end
|
||||
Assert.eq(total_row.duration, calendar_sum, "总时长 = __kv:total")
|
||||
Assert.eq(StatsDB.summaryBySource("kavita").total_seconds, calendar_sum, "总览合计 = 日历合计")
|
||||
|
||||
-- 分页:分页头说 2 页就拉 2 页,参数形态同真服务端。
|
||||
Assert.len(pagination_calls, 2)
|
||||
Assert.matches(pagination_calls[1], "Libraries=8")
|
||||
Assert.matches(pagination_calls[1], "Libraries=10")
|
||||
Assert.matches(pagination_calls[1], "PageNumber=1&PageSize=200")
|
||||
Assert.matches(pagination_calls[1], "TimeZoneId=Asia%%2FShanghai")
|
||||
Assert.matches(pagination_calls[2], "PageNumber=2&")
|
||||
|
||||
-- ③ 当日书单:云端读过、本机从没打开过的书也在;单书逐日与云端一致。
|
||||
local by_day_book = {}
|
||||
for _idx, row in ipairs(StatsDB.dailyBooksBySource("kavita")) do
|
||||
by_day_book[row.ymd] = by_day_book[row.ymd] or {}
|
||||
by_day_book[row.ymd][row.stable_id] = row
|
||||
end
|
||||
Assert.eq(by_day_book["2026-09-29"]["7453:11271"].seconds, 316, "只在其它设备读过的卷进当日书单")
|
||||
Assert.eq(by_day_book["2026-09-29"]["7453:11271"].max_total_pages, 0, "只有云端时长的那天没有页坐标")
|
||||
Assert.eq(by_day_book["2026-09-30"]["8661"].seconds, 2885, "单卷系列按 series 身份进当日书单")
|
||||
Assert.eq(by_day_book["2026-10-15"]["10634:17868"].seconds, 531, "多卷按章拆到各卷(210 + 321)")
|
||||
|
||||
-- 12 号票物化的隐藏身份行:书单里的云端书能显示书名(不是裸 ID),且不上架 / 不标脏 / 不写进度。
|
||||
local cloud_only = BookDB.get("kavita", "7453:11271")
|
||||
Assert.eq(cloud_only.title, "太空漫游 · 2001:太空漫游", "标题 = 系列 · 卷名")
|
||||
Assert.eq(cloud_only.authors, "阿瑟·克拉克", "作者继承容器行")
|
||||
Assert.eq(cloud_only.deleted, 1, "隐藏身份行:不进书架")
|
||||
Assert.eq(cloud_only.sync_status, 1, "隐藏身份行:不标脏、不推云端")
|
||||
Assert.is_nil(ProgressDB.get("kavita", "7453:11271"), "统计拉取不写进度:不会因此冒进「最近阅读」")
|
||||
local shelf_ids = BookDB.libraryStableIdsBySource("kavita")
|
||||
local materialized_on_shelf = false
|
||||
for _idx, id in ipairs(shelf_ids) do
|
||||
if id == "7453:11271" or id == "7453:11273" then materialized_on_shelf = true end
|
||||
end
|
||||
Assert.is_false(materialized_on_shelf, "物化行不是书架成员")
|
||||
-- 容器行缺失的系列:物化跳过(12 号票语义),统计行照写。
|
||||
Assert.is_nil(BookDB.get("kavita", "7910:11896"), "没有容器行就不物化")
|
||||
Assert.eq(by_day_book["2026-09-29"]["7910:11896"] ~= nil, true, "不物化不影响统计行")
|
||||
|
||||
-- 单书逐日(详情页「最近几天」)与云端 §3 一致;10-14 = 云端 6734(本地 900 已含,不再加)。
|
||||
local function book_days(stable_id)
|
||||
local rows, count = {}, 0
|
||||
for _idx, row in ipairs(StatsDB.dailyByBook("kavita", stable_id, 40)) do
|
||||
rows[row.ymd] = row.seconds
|
||||
count = count + 1
|
||||
end
|
||||
return rows, count
|
||||
end
|
||||
local sample_days = {
|
||||
["2026-10-05"] = 195, ["2026-10-07"] = 503, ["2026-10-08"] = 2036, ["2026-10-11"] = 512,
|
||||
["2026-10-13"] = 979, ["2026-10-14"] = 6734, ["2026-10-15"] = 2962,
|
||||
}
|
||||
local sample_rows, sample_day_count = book_days("7453:11273")
|
||||
Assert.eq(sample_rows["2026-10-14"], 6734, "云+本地同一天不双计")
|
||||
Assert.eq(sample_day_count, 7, "只列有数据的日子(零时长日不出现)")
|
||||
for ymd, seconds in pairs(sample_days) do Assert.eq(sample_rows[ymd], seconds, "单书逐日 " .. ymd) end
|
||||
Assert.eq(book_days("7453:11271")["2026-09-29"], 316)
|
||||
|
||||
-- ④ 时段:云端时段桶 + 本机逐页记录,合并口径与按天一致。
|
||||
local hourly = StatsDB.hourlyBySource("kavita")
|
||||
local hourly_days = 0
|
||||
for _ymd in pairs(hourly) do hourly_days = hourly_days + 1 end
|
||||
Assert.eq(hourly["2026-10-14"][22], 1043, "10-14 21 点:云端该格 1043s(本机同格已上报,不叠加)")
|
||||
Assert.eq(hourly_days, 28, "有云端时长的每天都有时段分布")
|
||||
Assert.eq(hourly["2026-09-18"][18], 738, "纯云端的日子也有时段(21 点 174 + 17 点 738 …)")
|
||||
-- 日页面「标题时长 = 时段图逐格之和」:逐日必须对得上
|
||||
for _idx, row in ipairs(StatsDB.dailyBySource("kavita")) do
|
||||
local sum = 0
|
||||
for h = 1, 24 do sum = sum + (hourly[row.ymd] and hourly[row.ymd][h] or 0) end
|
||||
Assert.eq(sum, row.seconds, "时段逐日之和 = 日历 " .. row.ymd)
|
||||
end
|
||||
|
||||
-- ⑤ 拉取后本地新读:云端快照 + 增量,两边都不双计。
|
||||
local L2_T = FETCHED + 5 * 3600
|
||||
Assert.is_true(StatsDB.add({
|
||||
source_id = "kavita", stable_id = "7453:11273", record_type = "page",
|
||||
page = 31, start_time = L2_T, duration = 90, total_pages = 150,
|
||||
}, StatsDB.PENDING))
|
||||
Assert.eq(StatsDB.summaryByBook("kavita", "7453:11273").total_seconds, 13921 + 90, "快照 + 拉取后新读")
|
||||
Assert.eq(book_days("7453:11273")["2026-10-17"], 90, "增量单落到它自己的日子")
|
||||
Assert.eq(calendar()["2026-10-17"].seconds, 90, "日历同样叠加增量")
|
||||
Assert.eq(StatsDB.summaryBySource("kavita").total_seconds, 60238 + 90, "总览 = __kv:total + 拉取后新读")
|
||||
Assert.eq(StatsDB.hourlyBySource("kavita")["2026-10-17"][2], 90, "增量进时段(1 点 = 第 2 格)")
|
||||
|
||||
-- 再拉一次(本次只回样本 7453):整本替换不累加,云端消失的日桶清掉,本地逐页记录不动。
|
||||
history = dofile((debug.getinfo(1, "S").source:match("^@(.*)/")) .. "/fixtures/history_7453.lua")
|
||||
pulled = pull()
|
||||
Assert.not_nil(pulled.rows[1])
|
||||
Assert.eq(StatsDB.summaryByBook("kavita", "7453:11273").total_seconds, 13921 + 90, "重拉不累加,增量仍在")
|
||||
Assert.eq(StatsDB.summaryByBook("kavita", "8661").total_seconds, 0, "云端消失的书回落本地(没有本地记录 = 0)")
|
||||
local again = calendar()
|
||||
Assert.is_nil(again["2026-09-18"], "上一轮的云端日桶被全量重拉清掉")
|
||||
Assert.eq(again["2026-10-14"].seconds, 6734, "样本日重写为本次回包值")
|
||||
Assert.eq(again["2026-10-17"].seconds, 90, "本地逐页记录不受替换影响")
|
||||
Assert.eq(StatsDB.hourlyBySource("kavita")["2026-10-14"][22], 716, "时段格重写为本次回包值(本机同格已上报,不叠加)")
|
||||
Assert.is_nil(StatsDB.hourlyBySource("kavita")["2026-09-18"], "回包里消失的时段格清掉")
|
||||
|
||||
-- 12 号票物化标题的第二轮回归:二次拉取时章数已判定(不再读目录),卷名必须取自状态文件里的
|
||||
-- 持久化卷名 —— 不能退容器名,更不能把上一轮物化出的好标题改写成「太空漫游 · 太空漫游」。
|
||||
Assert.eq(BookDB.get("kavita", "7453:11271").title, "太空漫游 · 2001:太空漫游", "二次拉取后标题不回退")
|
||||
Assert.eq(BookDB.get("kavita", "7453:11273").title, "太空漫游 · 2010:太空漫游")
|
||||
|
||||
-- 升级路径:老状态文件只有章数、没有卷名(本机第一轮物化时还没有持久化)。此时兜底标题
|
||||
-- 只能用于新行,不得覆盖既有行的真实标题。
|
||||
local stats_state = require("luasettings"):open(STATS_STATE)
|
||||
stats_state:saveSetting("titles", {})
|
||||
stats_state:flush()
|
||||
pulled = pull()
|
||||
Assert.eq(BookDB.get("kavita", "7453:11271").title, "太空漫游 · 2001:太空漫游",
|
||||
"没有持久化卷名时,兜底标题不覆盖既有标题")
|
||||
|
||||
os.time = real_time
|
||||
Base.close()
|
||||
for _idx, suffix in ipairs({ "", "-wal", "-shm" }) do os.remove(db_path .. suffix) end
|
||||
clearStatsState()
|
||||
@@ -0,0 +1,59 @@
|
||||
--[[-- Kavita 系列书评:章节过滤、归属校验与卷共用缓存。 @module tests.moonsource_kavita.reviews_spec --]]
|
||||
local Assert = require("support.assert")
|
||||
local Stubs = require("support.stubs")
|
||||
package.loaded.json = require("support.json_stub")
|
||||
local Mapper = require("moonsource_kavita.mapper")
|
||||
local wire = { reviews = {
|
||||
{ body = "<p>Book review</p>", tagline = "Title", chapterId = 0, seriesId = 5,
|
||||
username = "Reader", rating = 4, totalVotes = 3, isExternal = false },
|
||||
{ body = "Chapter review", chapterId = 8, seriesId = 5, username = "Reader" },
|
||||
{ body = "External book review", chapterId = 0, seriesId = 0,
|
||||
username = "External", isExternal = true },
|
||||
} }
|
||||
local page, err = Mapper.bookReviewPage(wire, "5")
|
||||
Assert.is_nil(err)
|
||||
Assert.len(page.items, 2)
|
||||
Assert.eq(page.items[1].text, "Title\nBook review")
|
||||
Assert.eq(page.items[1].grade, 4)
|
||||
Assert.eq(page.items[1].likes, 3)
|
||||
Assert.eq(page.items[1].time, "", "协议无日期,不编造日期")
|
||||
Assert.eq(page.items[2].text, "External book review")
|
||||
Assert.len(Mapper.bookReviewPage({ reviews = {} }, "5").items, 0)
|
||||
for _idx, bad in ipairs({
|
||||
{}, { reviews = { { body = "Bad", username = "Reader", chapterId = 0, seriesId = 99 } } },
|
||||
{ reviews = { { body = false } } },
|
||||
}) do
|
||||
local value, reason = Mapper.bookReviewPage(bad, "5")
|
||||
Assert.is_nil(value)
|
||||
Assert.eq(reason, "响应无效")
|
||||
end
|
||||
local source = require("moonsource_kavita.source").new()
|
||||
local connected, requests, failed = true, 0, false
|
||||
package.loaded["ui/network/manager"] = { isConnected = function() return connected end }
|
||||
source.client.json = function(_self, method, path, query, _body, cb)
|
||||
requests = requests + 1
|
||||
Assert.eq(method, "GET")
|
||||
Assert.eq(path, "/api/Metadata/series-detail-plus")
|
||||
Assert.eq(query.seriesId, 5)
|
||||
if failed then cb(nil, "server failed") else cb(wire) end
|
||||
return { cancel = function() end }
|
||||
end
|
||||
source:bookReviewsAsync({ source_id = "kavita", stable_id = "5:8" }, function(value, reason)
|
||||
page, err = value, reason
|
||||
end)
|
||||
Assert.is_nil(err)
|
||||
Assert.len(page.items, 2)
|
||||
connected = false
|
||||
source:bookReviewsAsync({ source_id = "kavita", stable_id = "5:9" }, function(value, reason)
|
||||
page, err = value, reason
|
||||
end)
|
||||
Stubs.flush()
|
||||
Assert.is_nil(err)
|
||||
Assert.len(page.items, 2)
|
||||
Assert.eq(requests, 1, "两个卷使用所属系列的整书缓存")
|
||||
connected, failed = true, true
|
||||
source:bookReviewsAsync({ source_id = "kavita", stable_id = "5" }, function(value, reason)
|
||||
page, err = value, reason
|
||||
end)
|
||||
Assert.is_nil(page)
|
||||
Assert.eq(err, "server failed")
|
||||
@@ -0,0 +1,644 @@
|
||||
--[[--
|
||||
Kavita 设置页:服务器 / API Key / 书库 / 漫画缓存 / 进度心跳 / 请求超时 / 连接测试。
|
||||
|
||||
@module tests.moonsource_kavita.setting_spec
|
||||
--]]
|
||||
---@diagnostic disable: undefined-field, missing-fields, inject-field
|
||||
|
||||
local Assert = require("support.assert")
|
||||
|
||||
local cfg = {}
|
||||
local saved = 0
|
||||
local invalidated = 0
|
||||
local events = {}
|
||||
package.preload["utils.settings"] = function()
|
||||
return {
|
||||
getSource = function() return cfg end,
|
||||
saveSource = function(_, value)
|
||||
cfg = value
|
||||
saved = saved + 1
|
||||
events[#events + 1] = "save"
|
||||
end,
|
||||
}
|
||||
end
|
||||
package.preload["source.registry"] = function()
|
||||
return { invalidate = function() invalidated = invalidated + 1 end }
|
||||
end
|
||||
-- 源模块只在设置行里读两个默认值;真常量由 client_spec / source_spec 钉住。
|
||||
-- 「测试连接」还要走 client:request,返回内容由 request_reply 控制。
|
||||
local request_reply = { version = "0.9.0" }
|
||||
package.preload["moonsource_kavita.client"] = function()
|
||||
return {
|
||||
DEFAULT_TIMEOUT = 60,
|
||||
new = function()
|
||||
return {
|
||||
api_key = "k",
|
||||
configured = function() return true end,
|
||||
request = function(_, _method, _path, _query, _body, callback)
|
||||
callback(request_reply.version, request_reply.err)
|
||||
end,
|
||||
}
|
||||
end,
|
||||
}
|
||||
end
|
||||
package.preload["ui/network/manager"] = function()
|
||||
return { isConnected = function() return true end }
|
||||
end
|
||||
-- 同步删除的忙碌窗会先强制重绘再动手;占用统计在下一拍算(03 E),测试里手动 flush。
|
||||
local repaints = 0
|
||||
local pending_ticks = {}
|
||||
local function flush()
|
||||
while #pending_ticks > 0 do
|
||||
local tick = table.remove(pending_ticks, 1)
|
||||
tick()
|
||||
end
|
||||
end
|
||||
package.preload["ui/uimanager"] = function()
|
||||
return {
|
||||
forceRePaint = function() repaints = repaints + 1 end,
|
||||
nextTick = function(_, fn) pending_ticks[#pending_ticks + 1] = fn end,
|
||||
}
|
||||
end
|
||||
package.preload["moonsource_kavita.source"] = function()
|
||||
return { DEFAULT_HEARTBEAT_INTERVAL = 30 }
|
||||
end
|
||||
package.preload["ui.themes.widgets.row"] = function()
|
||||
return { widget = function(opts) return opts end, note = function(_width, text) return { text = text } end }
|
||||
end
|
||||
package.loaded["ui.themes"] = nil
|
||||
package.preload["ui.themes"] = function()
|
||||
return {
|
||||
current = function()
|
||||
return { space = { md = 8 }, color = { muted = 1, page = 2 } }
|
||||
end,
|
||||
px = function(n) return n end,
|
||||
}
|
||||
end
|
||||
package.loaded["ui/geometry"] = nil
|
||||
package.preload["ui/geometry"] = function()
|
||||
return { new = function(_, opts) return opts end }
|
||||
end
|
||||
package.loaded["ui/widget/container/centercontainer"] = nil
|
||||
package.preload["ui/widget/container/centercontainer"] = function()
|
||||
return { new = function(_, opts) return opts end }
|
||||
end
|
||||
package.loaded["ui.themes.widgets.text"] = nil
|
||||
package.preload["ui.themes.widgets.text"] = function()
|
||||
return {
|
||||
box = function(_, text, _width, _opts)
|
||||
return { text = text, getSize = function() return { h = 10 } end }
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
||||
-- 缓存适配层:探测 / 详情 / 保存后镜像;真实现由 cache_spec 钉住。
|
||||
local probe_result = { ok = false, state = "missing" }
|
||||
local feature_text = "缓存(离线阅读与清理) · 双页拆分 · 裁切边框"
|
||||
local mirror_failed = false
|
||||
local register_calls, register_ok = {}, true
|
||||
local available = {}
|
||||
local summary_result
|
||||
local summary_all_result
|
||||
local chapters_result = {}
|
||||
local delete_calls, delete_all_calls = {}, 0
|
||||
local delete_ok, delete_code = true, nil
|
||||
local delete_all_ok, delete_all_code, delete_all_detail = true, nil, nil
|
||||
-- 占用 / 计划只在详情页各取一次(06 B 的「占用只算一次」)。
|
||||
local summary_calls, summary_all_calls, chapters_calls = 0, 0, 0
|
||||
package.preload["moonsource_kavita.cache"] = function()
|
||||
return {
|
||||
probe = function() return probe_result end,
|
||||
featureText = function() return feature_text end,
|
||||
pluginsDir = function() return "/fake/plugins" end,
|
||||
reprobe = function() return probe_result end,
|
||||
mirrorFailed = function() return mirror_failed end,
|
||||
registerServer = function(base_url, api_key)
|
||||
register_calls[#register_calls + 1] = { base_url = base_url, api_key = api_key }
|
||||
events[#events + 1] = "register"
|
||||
if register_ok then return "srv-1" end
|
||||
return nil, "settings_write_failed"
|
||||
end,
|
||||
available = function(cap) return available[cap] == true end,
|
||||
summary = function()
|
||||
summary_calls = summary_calls + 1
|
||||
return summary_result
|
||||
end,
|
||||
summaryAll = function()
|
||||
summary_all_calls = summary_all_calls + 1
|
||||
return summary_all_result
|
||||
end,
|
||||
chapters = function()
|
||||
chapters_calls = chapters_calls + 1
|
||||
return chapters_result
|
||||
end,
|
||||
plan = function(entries, filter, toc_read)
|
||||
local out = { chapters = 0, bytes = 0, ids = {}, queued = 0, open = false }
|
||||
for __, entry in ipairs(entries or {}) do
|
||||
local pages = tonumber(entry.pages) or 0
|
||||
local server = toc_read and (tonumber(toc_read[tostring(entry.chapterId)]) or 0) or 0
|
||||
local read = entry.read == true or (pages > 0 and server >= pages)
|
||||
if filter ~= "read" or read then
|
||||
out.chapters = out.chapters + 1
|
||||
out.bytes = out.bytes + (tonumber(entry.bytes) or 0)
|
||||
out.ids[#out.ids + 1] = entry.chapterId
|
||||
if entry.queued then out.queued = out.queued + 1 end
|
||||
if entry.open then out.open = true end
|
||||
end
|
||||
end
|
||||
return out
|
||||
end,
|
||||
delete = function(ids)
|
||||
delete_calls[#delete_calls + 1] = ids
|
||||
if not delete_ok then return nil, delete_code, "nope" end
|
||||
local wanted = {}
|
||||
for __, id in ipairs(ids or {}) do wanted[tostring(id)] = true end
|
||||
local kept = {}
|
||||
for __, entry in ipairs(chapters_result) do
|
||||
if not wanted[tostring(entry.chapterId)] then kept[#kept + 1] = entry end
|
||||
end
|
||||
chapters_result = kept
|
||||
return true
|
||||
end,
|
||||
deleteAll = function()
|
||||
delete_all_calls = delete_all_calls + 1
|
||||
if delete_all_ok then return true, nil, nil, delete_all_detail end
|
||||
return nil, delete_all_code, "nope"
|
||||
end,
|
||||
resetShelf = function() end,
|
||||
capabilityNames = function(caps, separator)
|
||||
local names = {}
|
||||
for name, on in pairs(caps or {}) do
|
||||
if on == true then names[#names + 1] = tostring(name) end
|
||||
end
|
||||
table.sort(names)
|
||||
return #names > 0 and table.concat(names, separator or ",") or "none"
|
||||
end,
|
||||
sizeText = function(bytes)
|
||||
local value = tonumber(bytes)
|
||||
if not value then return "未知" end
|
||||
return string.format("%.1f MB", value / (1024 * 1024))
|
||||
end,
|
||||
}
|
||||
end
|
||||
local Themed = require("support.theme_stubs")
|
||||
Themed.install()
|
||||
|
||||
-- kamare 在线更新:设置页只负责把行接上,网络 / 安装流程由 kamare_update_spec 钉住。
|
||||
local kamare_started = 0
|
||||
package.preload["moonsource_kavita.kamare_update"] = function()
|
||||
return {
|
||||
manualCheck = function() kamare_started = kamare_started + 1 end,
|
||||
}
|
||||
end
|
||||
|
||||
local Config = require("support.config")
|
||||
local PLUGIN = (debug.getinfo(1, "S").source:match("^@(.-)/tests/") .. "/moonsource-kavita.koplugin/moonsource_kavita")
|
||||
package.preload["moonsource_kavita.setting"] = function()
|
||||
return dofile(PLUGIN .. "/setting.lua")
|
||||
end
|
||||
package.preload["moonsource_kavita.busy"] = function()
|
||||
return dofile(PLUGIN .. "/busy.lua")
|
||||
end
|
||||
|
||||
local overlays, shelf_events, overlay_updates = {}, {}, 0
|
||||
local fake_desktop = {
|
||||
settings_overlay = nil,
|
||||
onEvent = function(_, event) shelf_events[#shelf_events + 1] = event end,
|
||||
}
|
||||
package.preload["desktop.pages.setting.overlay"] = function()
|
||||
return {
|
||||
push = function(desktop, spec)
|
||||
overlays[#overlays + 1] = spec
|
||||
desktop.settings_overlay = {
|
||||
updateView = function() overlay_updates = overlay_updates + 1 end,
|
||||
}
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
||||
local Setting = require("moonsource_kavita.setting")
|
||||
|
||||
local rows = Setting.rows({ path = PLUGIN, desktop = fake_desktop })
|
||||
-- 顺序用文案钉住(索引不再稳定),「漫画缓存」插在「书库」之后。
|
||||
local titles = {}
|
||||
for _idx, make in ipairs(rows) do titles[#titles + 1] = make(600).title end
|
||||
Assert.eq(#rows, 7, "服务器 / API Key / 书库 / 漫画缓存 / 进度心跳 / 请求超时 / 连接测试")
|
||||
Assert.eq(table.concat(titles, "|"),
|
||||
"服务器地址|API Key|书库|漫画缓存|进度心跳间隔|请求超时|测试连接",
|
||||
"「漫画缓存」紧跟「书库」")
|
||||
|
||||
-- 03 原型的三块分组:连接 / 缓存与同步 / 诊断。
|
||||
local sections = Setting.sections({ path = PLUGIN, desktop = fake_desktop })
|
||||
Assert.eq(#sections, 3, "设置页分三块")
|
||||
local grouped = {}
|
||||
for _idx, section in ipairs(sections) do
|
||||
local names = {}
|
||||
for _row_idx, make in ipairs(section.rows) do names[#names + 1] = make(600).title end
|
||||
grouped[#grouped + 1] = section.title .. ":" .. table.concat(names, ",")
|
||||
end
|
||||
Assert.eq(table.concat(grouped, "|"),
|
||||
"连接:服务器地址,API Key,书库|缓存与同步:漫画缓存,进度心跳间隔,请求超时|诊断:测试连接",
|
||||
"分组与原型一致,扁平的 rows 顺序不变")
|
||||
|
||||
--- 按标题找行(索引会随增删漂移)。
|
||||
---@param title string
|
||||
---@return table
|
||||
local function rowAt(title)
|
||||
for _idx, make in ipairs(rows) do
|
||||
local row = make(600)
|
||||
if row.title == title then return row end
|
||||
end
|
||||
error("没有这一行: " .. title)
|
||||
end
|
||||
|
||||
Assert.eq(Setting.remote[1].key, "base_url")
|
||||
Assert.eq(Setting.remote[2].key, "api_key")
|
||||
Assert.is_true(Setting.remote[2].secret)
|
||||
-- 远程管理网页表单只含连接配置;开关要在设备上调。
|
||||
Assert.len(Setting.remote, 2, "远程管理表单只有服务器地址与 API Key")
|
||||
|
||||
-- 进度心跳:默认 30 秒,可调;0 = 关闭阅读期心跳。
|
||||
local hb = rowAt("进度心跳间隔")
|
||||
Assert.eq(hb.kind, "nav")
|
||||
Assert.eq(hb.status, "30 秒")
|
||||
Assert.is_true(hb.status_on)
|
||||
-- 副标题单行截断(行里有状态 + 箭头,文字位很窄),必须短到放得下;「为什么」在输入框提示里。
|
||||
Assert.eq(hb.subtitle, "阅读时补推进度,0 关闭")
|
||||
hb.callback()
|
||||
local spin = Themed.last("spin")
|
||||
Assert.eq(spin.fields[1].value, 30)
|
||||
Assert.eq(spin.fields[1].step, 10, "10 秒一档")
|
||||
Assert.eq(spin.fields[1].min, 0)
|
||||
Assert.eq(spin.fields[1].max, 600)
|
||||
Assert.eq(spin.fields[1].label, "秒")
|
||||
spin.callback(120)
|
||||
Assert.eq(cfg.heartbeat_interval, 120)
|
||||
Assert.eq(rowAt("进度心跳间隔").status, "120 秒")
|
||||
Assert.eq(spin.shown and saved, 1, "保存一次")
|
||||
|
||||
spin.callback(0)
|
||||
Assert.eq(cfg.heartbeat_interval, 0, "0 落盘成关闭")
|
||||
local off = rowAt("进度心跳间隔")
|
||||
Assert.eq(off.status, "已关闭")
|
||||
Assert.is_false(off.status_on)
|
||||
|
||||
spin.callback(30)
|
||||
Assert.is_nil(cfg.heartbeat_interval, "回到默认值不落盘")
|
||||
|
||||
-- 请求超时:默认 60 秒,10 秒一档。
|
||||
local to = rowAt("请求超时")
|
||||
Assert.eq(to.status, "60 秒")
|
||||
Assert.is_false(to.status_on, "默认值不高亮")
|
||||
to.callback()
|
||||
spin = Themed.last("spin")
|
||||
Assert.eq(spin.fields[1].value, 60)
|
||||
Assert.eq(spin.fields[1].step, 10, "10 秒一档")
|
||||
Assert.eq(spin.fields[1].min, 10)
|
||||
spin.callback(180)
|
||||
Assert.eq(cfg.timeout, 180)
|
||||
Assert.eq(rowAt("请求超时").status, "180 秒")
|
||||
Assert.is_true(rowAt("请求超时").status_on)
|
||||
spin.callback(60)
|
||||
Assert.is_nil(cfg.timeout, "回到默认值不落盘")
|
||||
|
||||
Assert.eq(saved, 5)
|
||||
Assert.eq(invalidated, 5, "每次保存都作废源实例,新配置立即生效,但不广播 SourceChanged")
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- 漫画缓存:七态(含旧接口/镜像失败)+ 只读详情 + 09 手动安装说明。
|
||||
----------------------------------------------------------------------
|
||||
local function checkStatus(probe, expected, on, mirror)
|
||||
probe_result = probe
|
||||
mirror_failed = mirror == true
|
||||
local row = rowAt("漫画缓存")
|
||||
Assert.eq(row.kind, "nav")
|
||||
Assert.eq(row.status, expected)
|
||||
Assert.eq(row.status_on, on, expected)
|
||||
end
|
||||
|
||||
checkStatus({ ok = false, state = "missing" }, "未安装 / 未启用", false)
|
||||
checkStatus({ ok = false, state = "official" }, "官方版(无缓存接口)", false)
|
||||
checkStatus({ ok = false, state = "incompatible", api_version = 2 }, "版本不兼容", false)
|
||||
checkStatus({ ok = true, state = "enhanced", api_version = 1, version = "0.10.0-dev",
|
||||
capabilities = { chapters = true, delete = true, delete_all = true } },
|
||||
"增强版 v0.10.0-dev", true)
|
||||
-- 旧接口:有 kamarecache 但没有 chapters / delete,清理不可用,不高亮。
|
||||
checkStatus({ ok = true, state = "enhanced", api_version = 1, version = "0.9.22",
|
||||
capabilities = { status = true, summary = true } },
|
||||
"增强版 v0.9.22(旧接口)", false)
|
||||
checkStatus({ ok = true, state = "enhanced", api_version = 1 }, "增强版(旧接口)", false)
|
||||
checkStatus({ ok = true, state = "enhanced", api_version = 1, version = "0.10.0-dev" },
|
||||
"配置同步失败", false, true)
|
||||
|
||||
-- 详情页:状态 → 清理;增强态不显示安装说明。
|
||||
local MB = 1024 * 1024
|
||||
cfg.base_url, cfg.api_key = "http://kav", "k"
|
||||
local cache_path = "/fake/plugins/kamare.koplugin/src/kamarecache.lua"
|
||||
probe_result = {
|
||||
ok = true, state = "enhanced", api_version = 1, version = "0.10.0-dev",
|
||||
capabilities = { open = true, index = true, status = true, summary = true,
|
||||
chapters = true, delete = true, delete_all = true },
|
||||
path = cache_path,
|
||||
}
|
||||
mirror_failed = false
|
||||
available = { summary = true }
|
||||
summary_result = { used = 3 * MB, available = 9 * MB, chapters = 12 }
|
||||
summary_all_result = { used = 4 * MB, available = 9 * MB, chapters = 15 }
|
||||
chapters_result = {
|
||||
{ chapterId = 1, pages = 10, bytes = 1 * MB, read = false, queued = false, open = false },
|
||||
{ chapterId = 2, pages = 10, bytes = 2 * MB, read = true, queued = false, open = false },
|
||||
}
|
||||
|
||||
local function findSection(sections, title)
|
||||
for __, section in ipairs(sections or {}) do
|
||||
if section.title == title then return section end
|
||||
end
|
||||
end
|
||||
|
||||
local function sectionRows(sections, title)
|
||||
local section = findSection(sections, title)
|
||||
local out = {}
|
||||
for i, make in ipairs(section and section.rows or {}) do out[i] = make(600) end
|
||||
return out
|
||||
end
|
||||
|
||||
local function statusOf(rows_list, title)
|
||||
for __, row in ipairs(rows_list) do
|
||||
if row.title == title then return row end
|
||||
end
|
||||
end
|
||||
|
||||
--- 最近一次详情页的最终 sections:先取一拍(触发占用统计),flush 后再取一次。
|
||||
---@return BookThemeSection[]
|
||||
local function currentSections()
|
||||
overlays[#overlays].sections()
|
||||
flush()
|
||||
return overlays[#overlays].sections()
|
||||
end
|
||||
|
||||
rowAt("漫画缓存").callback()
|
||||
local page = overlays[#overlays]
|
||||
Assert.not_nil(page, "详情走叠层,不再用 ConfirmBox")
|
||||
Assert.eq(page.title, "漫画缓存")
|
||||
summary_calls, summary_all_calls, chapters_calls = 0, 0, 0
|
||||
overlay_updates = 0
|
||||
local pending_sections = page.sections()
|
||||
Assert.eq(summary_calls + summary_all_calls, 0, "先画「正在统计…」,不在这一拍走盘")
|
||||
Assert.eq(statusOf(sectionRows(pending_sections, "状态"), "缓存占用").subtitle, "正在统计…")
|
||||
Assert.eq(chapters_calls, 1, "清理计划一次 chapters() 取全")
|
||||
flush()
|
||||
Assert.eq(summary_calls, 1, "下一拍算本服务器占用")
|
||||
Assert.eq(summary_all_calls, 1, "「清理全部」的合计也算出来")
|
||||
Assert.eq(overlay_updates, 1, "算完刷新叠层")
|
||||
local sections = page.sections()
|
||||
Assert.eq(chapters_calls, 2, "重画不重算占用,只重取计划")
|
||||
local status_rows = sectionRows(sections, "状态")
|
||||
local version_row = statusOf(status_rows, "kamare 增强版")
|
||||
Assert.eq(version_row.status, "0.10.0-dev")
|
||||
Assert.is_true(version_row.chevron, "版本行可点")
|
||||
Assert.eq(version_row.subtitle, "点按检查 kamare 增强版更新")
|
||||
version_row.callback()
|
||||
Assert.eq(kamare_started, 1, "版本行交给 kamare 在线更新模块")
|
||||
Assert.eq(statusOf(status_rows, "增强版功能").subtitle, feature_text, "功能清单原样显示")
|
||||
|
||||
-- 清单缺失 / 不合法:不显示整行,版本行不受影响。
|
||||
feature_text = nil
|
||||
local without_features = sectionRows(page.sections(), "状态")
|
||||
Assert.is_nil(statusOf(without_features, "增强版功能"), "没有清单隐藏功能行")
|
||||
Assert.not_nil(statusOf(without_features, "kamare 增强版"), "版本行仍在")
|
||||
Assert.eq(statusOf(status_rows, "加载路径").subtitle, cache_path)
|
||||
Assert.eq(statusOf(status_rows, "缓存占用").status, "12 章")
|
||||
Assert.matches(statusOf(status_rows, "缓存占用").subtitle, "已用 3.0 MB,可用 9.0 MB")
|
||||
|
||||
local cleanup_rows = sectionRows(sections, "清理")
|
||||
Assert.eq(cleanup_rows[1].title, "清理已读")
|
||||
Assert.matches(cleanup_rows[1].subtitle, "1 章")
|
||||
Assert.eq(cleanup_rows[2].title, "清理本服务器")
|
||||
Assert.matches(cleanup_rows[2].subtitle, "2 章")
|
||||
Assert.eq(cleanup_rows[3].title, "清理全部")
|
||||
Assert.matches(cleanup_rows[3].subtitle, "含未关联服务器 · 15 章", "全部清理用合计,不用本服务器")
|
||||
Assert.is_nil(findSection(sections, "获取增强版"), "增强态不显示安装说明")
|
||||
|
||||
-- 维护组已移除:更新入口只在诊断页。
|
||||
Assert.is_nil(findSection(sections, "维护"))
|
||||
|
||||
-- 清理已读:确认 → 忙碌窗 → 删除 → 复查 → 刷新。
|
||||
delete_calls = {}
|
||||
cleanup_rows[1].callback()
|
||||
local read_confirm = Themed.last("confirm")
|
||||
Assert.not_nil(read_confirm)
|
||||
Assert.matches(read_confirm.text, "将删除 1 章")
|
||||
local repaints_before = repaints
|
||||
read_confirm.ok_callback()
|
||||
local busy = Themed.last("progress_dialog")
|
||||
Assert.not_nil(busy, "同步删除先弹忙碌窗")
|
||||
Assert.eq(busy.title, "清理已读")
|
||||
Assert.eq(busy.text, "正在清理…")
|
||||
Assert.is_true(busy.dismissable == false, "忙碌窗不可关")
|
||||
Assert.is_true(busy.shown, "先显示再删除")
|
||||
Assert.is_true(busy.closed, "删完关闭")
|
||||
Assert.eq(repaints, repaints_before + 1, "删除前强制重绘一次")
|
||||
Assert.eq(#delete_calls, 1, "清理已读调用一次批量删除")
|
||||
Assert.eq(#delete_calls[1], 1, "只删已读完的那一章")
|
||||
Assert.matches(Themed.last("toast").text, "已清理 1 章")
|
||||
Assert.eq(shelf_events[#shelf_events], "shelf_changed", "删除后刷新书架")
|
||||
|
||||
-- 删除后占用必须重算(03 E):只 updateView 会留下删前的数字。
|
||||
summary_result = { used = 2 * MB, available = 9 * MB, chapters = 11 }
|
||||
summary_all_result = { used = 3 * MB, available = 9 * MB, chapters = 14 }
|
||||
local usage_calls_before = summary_calls + summary_all_calls
|
||||
local after_cleanup = page.sections()
|
||||
Assert.eq(statusOf(sectionRows(after_cleanup, "状态"), "缓存占用").subtitle,
|
||||
"正在统计…", "删除后先画「正在统计…」")
|
||||
flush()
|
||||
Assert.eq(summary_calls + summary_all_calls, usage_calls_before + 2, "删除后重算本服务器与合计")
|
||||
Assert.eq(statusOf(sectionRows(page.sections(), "状态"), "缓存占用").status,
|
||||
"11 章", "占用数字跟着删除刷新")
|
||||
Assert.matches(sectionRows(page.sections(), "清理")[3].subtitle,
|
||||
"含未关联服务器 · 14 章", "清理全部的数字也刷新")
|
||||
|
||||
-- 空缓存:三项都置灰(03 待确认 3),清理全部不再可点。
|
||||
cfg.base_url, cfg.api_key = "http://kav", "k"
|
||||
probe_result = {
|
||||
ok = true, state = "enhanced", api_version = 1, version = "0.10.0-dev",
|
||||
capabilities = { summary = true, chapters = true, delete = true, delete_all = true },
|
||||
path = cache_path,
|
||||
}
|
||||
available = { summary = true }
|
||||
local saved_chapters = chapters_result
|
||||
chapters_result = {}
|
||||
summary_result = { used = 0, available = 9 * MB, chapters = 0 }
|
||||
summary_all_result = { used = 0, available = 9 * MB, chapters = 0 }
|
||||
rowAt("漫画缓存").callback()
|
||||
local empty_rows = sectionRows(currentSections(), "清理")
|
||||
for idx = 1, 3 do
|
||||
Assert.is_false(empty_rows[idx].enabled, "空缓存置灰:" .. empty_rows[idx].title)
|
||||
Assert.is_false(empty_rows[idx].chevron, "空缓存不显示箭头:" .. empty_rows[idx].title)
|
||||
Assert.eq(empty_rows[idx].subtitle, "没有可清理的缓存", "空缓存文案:" .. empty_rows[idx].title)
|
||||
end
|
||||
chapters_result = saved_chapters
|
||||
summary_result = { used = 3 * MB, available = 9 * MB, chapters = 12 }
|
||||
summary_all_result = { used = 4 * MB, available = 9 * MB, chapters = 15 }
|
||||
|
||||
-- 旧接口:不出清理项,只写升级说明;设置行也不承诺清理。
|
||||
probe_result = {
|
||||
ok = true, state = "enhanced", api_version = 1, version = "0.9.22",
|
||||
capabilities = { status = true, summary = true }, path = cache_path,
|
||||
}
|
||||
Assert.eq(rowAt("漫画缓存").subtitle, "状态与获取增强版", "旧接口不承诺清理")
|
||||
Assert.eq(rowAt("漫画缓存").status, "增强版 v0.9.22(旧接口)")
|
||||
rowAt("漫画缓存").callback()
|
||||
local old_rows = sectionRows(currentSections(), "清理")
|
||||
Assert.eq(#old_rows, 1, "旧接口只有一段说明")
|
||||
Assert.eq(old_rows[1].title, "当前 kamare 没有清理接口")
|
||||
Assert.matches(old_rows[1].subtitle, "chapters / delete_all", "说明要升级到什么")
|
||||
probe_result = {
|
||||
ok = true, state = "enhanced", api_version = 1, version = "0.10.0-dev",
|
||||
capabilities = { open = true, index = true, status = true, summary = true,
|
||||
chapters = true, delete = true, delete_all = true },
|
||||
path = cache_path,
|
||||
}
|
||||
|
||||
-- 清理全部:没有服务器也能用,确认文案含未关联。
|
||||
cfg.base_url, cfg.api_key = "", ""
|
||||
probe_result = {
|
||||
ok = true, state = "enhanced", api_version = 1, version = "0.10.0-dev",
|
||||
capabilities = { summary = true, chapters = true, delete = true, delete_all = true },
|
||||
path = cache_path,
|
||||
}
|
||||
available = { summary = true }
|
||||
rowAt("漫画缓存").callback()
|
||||
summary_all_calls, summary_calls = 0, 0
|
||||
local unconfigured = currentSections()
|
||||
Assert.eq(sectionRows(unconfigured, "清理")[1].title, "未配置服务器")
|
||||
Assert.eq(summary_all_calls, 1, "没有服务器时占用取合计")
|
||||
Assert.eq(summary_calls, 0, "没有服务器时不查单服务器")
|
||||
Assert.matches(statusOf(sectionRows(unconfigured, "状态"), "缓存占用").subtitle, "含未关联服务器")
|
||||
sectionRows(unconfigured, "清理")[2].callback()
|
||||
local all_confirm = Themed.last("confirm")
|
||||
Assert.matches(all_confirm.text, "含未关联服务器")
|
||||
Assert.matches(all_confirm.text, "共 15 章", "确认框用所有服务器的合计,不用本服务器")
|
||||
all_confirm.ok_callback()
|
||||
Assert.eq(Themed.last("progress_dialog").title, "清理全部缓存", "全部清理同样有忙碌窗")
|
||||
Assert.eq(delete_all_calls, 1, "清理全部走 deleteAll")
|
||||
|
||||
-- 未安装:安装说明;路径归一;不显示占用。
|
||||
probe_result = { ok = false, state = "missing" }
|
||||
available = {}
|
||||
cfg.base_url = ""
|
||||
rowAt("漫画缓存").callback()
|
||||
local missing = currentSections()
|
||||
local missing_version = statusOf(sectionRows(missing, "状态"), "kamare 增强版")
|
||||
Assert.eq(missing_version.status, "未安装")
|
||||
Assert.eq(missing_version.subtitle, "点按检查并安装 kamare 增强版", "没有 kamare 时引导点版本行")
|
||||
local install = findSection(missing, "获取增强版")
|
||||
Assert.not_nil(install, "非增强态显示安装说明")
|
||||
local install_text = install.rows[1](600).text or ""
|
||||
Assert.matches(install_text, "releases/latest")
|
||||
Assert.matches(install_text, "kamarecache.lua")
|
||||
Assert.matches(install_text, "增强版功能随版本不同")
|
||||
Assert.matches(install_text, "上方「kamare 增强版」")
|
||||
Assert.matches(install_text, "koreader/plugins", "手动安装路径带 koreader/ 前缀")
|
||||
Assert.is_nil(findSection(missing, "清理"), "未安装不显示清理")
|
||||
|
||||
-- 版本不兼容:安装说明前先讲清 API 不兼容(03 原型)。
|
||||
probe_result = { ok = false, state = "incompatible", api_version = 2 }
|
||||
rowAt("漫画缓存").callback()
|
||||
local incompatible = sectionRows(currentSections(), "版本与获取")
|
||||
Assert.eq(incompatible[1].title, "版本不兼容")
|
||||
Assert.matches(incompatible[1].subtitle, "API v2")
|
||||
Assert.not_nil(incompatible[2].text, "后面仍是安装说明")
|
||||
|
||||
-- 镜像失败:状态区给出警告 + 重试同步。
|
||||
probe_result = {
|
||||
ok = true, state = "enhanced", api_version = 1, version = "0.10.0-dev",
|
||||
capabilities = { summary = true, chapters = true, delete = true, delete_all = true },
|
||||
path = "/fake/plugins//kamare.koplugin/kamarecache.lua",
|
||||
}
|
||||
mirror_failed = true
|
||||
available = { summary = true }
|
||||
rowAt("漫画缓存").callback()
|
||||
local mirrored = currentSections()
|
||||
local mirror_row = statusOf(sectionRows(mirrored, "状态"), "配置同步失败")
|
||||
Assert.not_nil(mirror_row, "镜像失败在状态区")
|
||||
Assert.eq(mirror_row.status, "重试同步")
|
||||
Assert.is_nil(statusOf(sectionRows(mirrored, "状态"), "加载路径").subtitle:find("//", 1, true),
|
||||
"加载路径归一成单斜杠")
|
||||
mirror_failed = false
|
||||
|
||||
-- 保存后镜像:先落 moon 自己的配置,再 register_server;失败 toast 但不阻断。
|
||||
cfg.base_url, cfg.api_key = "http://kav", "k"
|
||||
probe_result = { ok = true, state = "enhanced", api_version = 1, version = "0.10.0" }
|
||||
register_calls, register_ok, events = {}, true, {}
|
||||
local before = saved
|
||||
rowAt("进度心跳间隔").callback()
|
||||
Themed.last("spin").callback(70)
|
||||
Assert.eq(saved, before + 1)
|
||||
Assert.eq(register_calls[1].base_url, "http://kav")
|
||||
Assert.eq(register_calls[1].api_key, "k")
|
||||
Assert.eq(events[#events - 1], "save", "先存 moon 自己的配置")
|
||||
Assert.eq(events[#events], "register", "镜像失败也不影响 moon 保存")
|
||||
|
||||
register_ok = false
|
||||
before = saved
|
||||
rowAt("进度心跳间隔").callback()
|
||||
Themed.last("spin").callback(60)
|
||||
Assert.eq(Themed.last("toast").text, "无法同步配置到 kamare", "用户主动保存失败要提示")
|
||||
Assert.eq(saved, before + 1, "toast 不阻断 moon 自己的保存")
|
||||
|
||||
-- 未安装:不假装能镜像。
|
||||
probe_result = { ok = false, state = "missing" }
|
||||
register_calls = {}
|
||||
rowAt("进度心跳间隔").callback()
|
||||
Themed.last("spin").callback(30)
|
||||
Assert.len(register_calls, 0, "没有缓存接口时跳过镜像")
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- 测试连接:只测 Kavita,不碰 kamare。
|
||||
----------------------------------------------------------------------
|
||||
Assert.eq(rowAt("测试连接").kind, "action")
|
||||
Assert.eq(rowAt("测试连接").subtitle, "检查 Kavita 服务器连接与版本")
|
||||
|
||||
---@param probe table
|
||||
---@param mirror boolean|nil
|
||||
---@param version string|nil
|
||||
---@param err string|nil
|
||||
---@return string
|
||||
local function connectToast(probe, mirror, version, err)
|
||||
probe_result = probe
|
||||
mirror_failed = mirror == true
|
||||
request_reply = { version = version, err = err }
|
||||
rowAt("测试连接").callback()
|
||||
return Themed.last("toast").text
|
||||
end
|
||||
|
||||
local enhanced = { ok = true, state = "enhanced", api_version = 1, version = "0.10.0-dev",
|
||||
capabilities = { chapters = true, delete = true, delete_all = true } }
|
||||
Assert.eq(connectToast(enhanced, false, "0.9.0"), "连接正常\nKavita 0.9.0")
|
||||
Assert.eq(connectToast(enhanced, true, "0.9.0"), "连接正常\nKavita 0.9.0",
|
||||
"kamare 镜像失败不影响 Kavita 连接结果")
|
||||
Assert.eq(connectToast({ ok = false, state = "missing" }, false, "0.9.0"),
|
||||
"连接正常\nKavita 0.9.0", "测试连接不碰 kamare")
|
||||
Assert.eq(connectToast({ ok = false, state = "incompatible", api_version = 2 }, false, "0.9.0"),
|
||||
"连接正常\nKavita 0.9.0")
|
||||
-- 版本过旧 / 请求失败仍报真正原因,不能让缓存状态盖过去。
|
||||
Assert.eq(connectToast(enhanced, false, "0.8.9"),
|
||||
"连接正常\nKavita 0.8.9 过旧,需要 0.9 及以上")
|
||||
Assert.eq(connectToast(enhanced, false, nil, "HTTP 401"), "连接失败\nHTTP 401")
|
||||
Assert.eq(connectToast(enhanced, false, nil, nil), "连接正常\n无法识别 Kavita 版本")
|
||||
|
||||
-- 换服务器清理失败:共享配置、磁盘、kamare 镜像都必须保持旧值。
|
||||
do
|
||||
cfg.base_url, cfg.api_key = "http://old", "old-key"
|
||||
local saved_before, mirrored_before = saved, #register_calls
|
||||
package.loaded["source.logout"] = {
|
||||
replaceLibrary = function() return false end,
|
||||
}
|
||||
rowAt("服务器地址").callback()
|
||||
Themed.last("input").callback("http://new")
|
||||
Assert.eq(cfg.base_url, "http://old")
|
||||
Assert.eq(cfg.api_key, "old-key")
|
||||
Assert.eq(saved, saved_before)
|
||||
Assert.eq(#register_calls, mirrored_before)
|
||||
Assert.eq(Themed.last("toast").text, "准备本地同步失败")
|
||||
end
|
||||
@@ -0,0 +1,237 @@
|
||||
--[[--
|
||||
Kavita 源的书架缓存钩子:shelf_cache 能力、shelfCache 同步返回投影、
|
||||
syncBooksAsync 同步后预热(05 A1)、coverRequest 优先本地封面(05 A8)。
|
||||
|
||||
不复用 source_spec 的整套书架夹具:这里只碰钩子本身,HTTP / 书库 / 目录都最小打桩。
|
||||
|
||||
@module tests.moonsource_kavita.shelf_cache_spec
|
||||
--]]
|
||||
---@diagnostic disable: undefined-field, missing-fields, inject-field
|
||||
|
||||
local Assert = require("support.assert")
|
||||
local Config = require("support.config")
|
||||
local Stubs = require("support.stubs")
|
||||
Stubs.install()
|
||||
|
||||
-- 日志:pcall 的失败必须被检查并记录,不能静默吞掉(项目审计口径)。
|
||||
local warns = {}
|
||||
package.loaded["utils.log"] = {
|
||||
dbg = function() end,
|
||||
info = function() end,
|
||||
error = function() end,
|
||||
warn = function(...)
|
||||
local parts = {}
|
||||
for index = 1, select("#", ...) do
|
||||
parts[#parts + 1] = tostring(select(index, ...))
|
||||
end
|
||||
warns[#warns + 1] = table.concat(parts, " ")
|
||||
end,
|
||||
}
|
||||
|
||||
local PLUGIN = (debug.getinfo(1, "S").source:match("^@(.-)/tests/") .. "/moonsource-kavita.koplugin/moonsource_kavita")
|
||||
-- 走 preload 不改 package.path:插件根上的 main.lua 会顶掉月读的 main。
|
||||
for _idx, name in ipairs({ "client", "position", "annotation", "source", "cache", "volume_list", "stats" }) do
|
||||
package.preload["moonsource_kavita" .. (name == "source" and ".source" or "." .. name)] = function()
|
||||
return dofile(PLUGIN .. "/" .. (name == "source" and "source" or name) .. ".lua")
|
||||
end
|
||||
end
|
||||
|
||||
-- 往返桩:encode 登记表并发令牌,decode 凭令牌取回(不是令牌就报错,同真解析器)。
|
||||
local encoded = {}
|
||||
package.preload["json"] = function()
|
||||
return {
|
||||
encode = function(value)
|
||||
encoded[#encoded + 1] = value
|
||||
return "\0json" .. #encoded
|
||||
end,
|
||||
decode = function(text)
|
||||
return encoded[tonumber(text:match("^%z?json(%d+)$"))] or error("not json: " .. text)
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
||||
local cfg = { base_url = "http://kav/", api_key = "k", libraries = { ["1"] = true } }
|
||||
package.preload["utils.settings"] = function()
|
||||
return {
|
||||
get = function() return { active_source = "local" } end,
|
||||
save = function() end,
|
||||
getSource = function() return cfg end,
|
||||
saveSource = function() end,
|
||||
}
|
||||
end
|
||||
|
||||
-- HTTP:只有书架快照这一个路由。
|
||||
local routes, requested = {}, {}
|
||||
package.preload["http.request"] = function()
|
||||
return {
|
||||
ok = function(code)
|
||||
code = tonumber(code)
|
||||
return code ~= nil and code >= 200 and code < 300
|
||||
end,
|
||||
header = function() end,
|
||||
request = function(opts, cb)
|
||||
requested[#requested + 1] = opts
|
||||
local route = routes[opts.method .. " " .. opts.url:match("^http://kav(/[^?]*)")]
|
||||
require("ui/uimanager"):nextTick(function()
|
||||
cb(route and route(opts) or { code = 404, body = "" })
|
||||
end)
|
||||
return { cancel = function() end }
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
||||
-- 本地库:钩子只需要「取一本书」与「已同步身份」。
|
||||
local books = {}
|
||||
package.loaded["book.books_db"] = {
|
||||
get = function(_source_id, stable_id) return books[stable_id] end,
|
||||
libraryStableIdsBySource = function() return {} end,
|
||||
}
|
||||
package.loaded["book.progress_db"] = {
|
||||
get = function() return nil end,
|
||||
}
|
||||
package.loaded["book.store"] = { rememberMany = function() end }
|
||||
|
||||
local sequence = {}
|
||||
package.loaded["source.shelf"] = {
|
||||
reconcile = function(_source_id, list)
|
||||
sequence[#sequence + 1] = "reconcile"
|
||||
return { pulled = #list, pushed = 0, hidden = 0, conflicts = 0, skipped = false }
|
||||
end,
|
||||
}
|
||||
|
||||
-- 封面路径只关心「本地缓存 / 在线地址」的分支:目录查不到卷时退回系列封面(卷封面见 source_spec)。
|
||||
package.loaded["source.toc"] = { read = function() return nil end }
|
||||
local SourceMod = require("moonsource_kavita.source")
|
||||
local Cache = require("moonsource_kavita.cache")
|
||||
local source = SourceMod.new()
|
||||
|
||||
-- 能力:声明 shelf_cache,UI 据此决定断网时是否收窄书架(05 A2)。
|
||||
local caps = source:capabilities()
|
||||
Assert.is_true(caps.shelf_cache, "Kavita 声明书架缓存能力")
|
||||
Assert.is_true(caps.stats_pull, "原有能力不受影响")
|
||||
|
||||
-- shelfCache:同步返回适配层记忆的投影;未配置不触盘。
|
||||
local projection = { series_ids = { ["700"] = true }, mark = { ["700"] = true }, cover = {} }
|
||||
local shelf_calls = 0
|
||||
local real_shelf = Cache.shelf
|
||||
Cache.shelf = function()
|
||||
shelf_calls = shelf_calls + 1
|
||||
return projection
|
||||
end
|
||||
Assert.eq(source:shelfCache(), projection, "shelfCache 原样交回适配层投影")
|
||||
Assert.eq(shelf_calls, 1)
|
||||
cfg.base_url = ""
|
||||
Assert.is_nil(SourceMod.new():shelfCache(), "未配置返回 nil")
|
||||
Assert.eq(shelf_calls, 1, "未配置不读投影")
|
||||
cfg.base_url = "http://kav/"
|
||||
|
||||
-- coverRequest:投影里有本地封面且文件存在 → 本地路径,不再走鉴权 URL(05 A8)。
|
||||
local cover_path = Config.dir() .. "/shelf_cover_700.jpg"
|
||||
local file = assert(io.open(cover_path, "wb"))
|
||||
file:write("jpg")
|
||||
file:close()
|
||||
Cache.shelf = function() return { series_ids = {}, mark = {}, cover = { ["700"] = cover_path } } end
|
||||
local req = select(1, source:coverRequest({ source_id = "kavita", stable_id = "700" }))
|
||||
Assert.eq(req.url, cover_path, "已缓存系列用本地封面")
|
||||
Assert.is_nil(req.headers, "本地文件不需要鉴权头")
|
||||
Assert.eq(req.authoritative, true, "源封面压过本地抽页缓存")
|
||||
-- 卷身份同样借系列封面(chapter-cover 是扫描页,不能当封面)。
|
||||
req = select(1, source:coverRequest({ source_id = "kavita", stable_id = "700:7001" }))
|
||||
Assert.eq(req.url, cover_path, "卷身份也用已缓存系列封面")
|
||||
-- 投影给了路径但文件没了 → 维持在线系列封面。
|
||||
Cache.shelf = function() return { series_ids = {}, mark = {}, cover = { ["700"] = cover_path .. ".gone" } } end
|
||||
req = select(1, source:coverRequest({ source_id = "kavita", stable_id = "700" }))
|
||||
Assert.is_true(req.url:find("series-cover", 1, true) ~= nil, "文件不存在退回在线封面")
|
||||
Assert.not_nil(req.headers)
|
||||
req = select(1, source:coverRequest({ source_id = "kavita", stable_id = "700:7001" }))
|
||||
Assert.is_true(req.url:find("series-cover", 1, true) ~= nil, "卷身份也走系列封面")
|
||||
-- 适配层没给投影(无 index):照旧在线封面。
|
||||
Cache.shelf = function() return nil end
|
||||
req = select(1, source:coverRequest({ source_id = "kavita", stable_id = "700" }))
|
||||
Assert.is_true(req.url:find("series-cover", 1, true) ~= nil)
|
||||
Cache.shelf = real_shelf
|
||||
|
||||
-- syncBooksAsync 预热:对账后、回调前把投影建好,进书架时 O(1)(05 A1)。
|
||||
sequence, requested = {}, {}
|
||||
Cache.shelf = function()
|
||||
sequence[#sequence + 1] = "shelf"
|
||||
return projection
|
||||
end
|
||||
routes["POST /api/Series/all-v2"] = function()
|
||||
return { code = 200, body = require("json").encode({
|
||||
{ id = 700, name = "漫画一", libraryName = "漫画", wordCount = 10 },
|
||||
}) }
|
||||
end
|
||||
source.backfillMeta = function() end
|
||||
local synced
|
||||
source:syncBooksAsync(nil, function(result, err)
|
||||
sequence[#sequence + 1] = "cb"
|
||||
synced = { result = result, err = err }
|
||||
end)
|
||||
Stubs.flush()
|
||||
Assert.not_nil(synced)
|
||||
Assert.is_nil(synced.err)
|
||||
Assert.eq(synced.result.pulled, 1, "对账结果照旧回调")
|
||||
Assert.eq(table.concat(sequence, ","), "reconcile,shelf,cb", "预热排在回调之前")
|
||||
|
||||
-- 手动刷新 / 书库重扫(force)必须让投影失效并重建;后台同步沿用记忆(05 A1)。
|
||||
-- 拉回的新缓存状态看不见 = 用户点了刷新但书架标记不更新。
|
||||
sequence, requested = {}, {}
|
||||
local resets = 0
|
||||
local real_reset = Cache.resetShelf
|
||||
Cache.resetShelf = function()
|
||||
resets = resets + 1
|
||||
sequence[#sequence + 1] = "reset"
|
||||
end
|
||||
Cache.shelf = function()
|
||||
sequence[#sequence + 1] = "shelf"
|
||||
return projection
|
||||
end
|
||||
local background
|
||||
source:syncBooksAsync(nil, function(result, err) background = { result = result, err = err } end)
|
||||
Stubs.flush()
|
||||
Assert.not_nil(background and background.result)
|
||||
Assert.eq(resets, 0, "后台同步不丢投影")
|
||||
Assert.eq(table.concat(sequence, ","), "reconcile,shelf", "后台同步只预热现有记忆")
|
||||
sequence = {}
|
||||
local forced
|
||||
source:syncBooksAsync({ force = true }, function(result, err) forced = { result = result, err = err } end)
|
||||
Stubs.flush()
|
||||
Assert.not_nil(forced and forced.result)
|
||||
Assert.eq(resets, 1, "手动刷新让投影失效")
|
||||
Assert.eq(table.concat(sequence, ","), "reset,reconcile,shelf", "重扫先失效再重建,回调前投影已就绪")
|
||||
sequence = {}
|
||||
Cache.resetShelf = real_reset
|
||||
|
||||
-- 预热失败不拖垮同步:投影只是书架标记,缓存模块异常照样要回调对账结果。
|
||||
sequence, requested = {}, {}
|
||||
warns = {}
|
||||
local broken_sequence = sequence
|
||||
Cache.shelf = function()
|
||||
broken_sequence[#broken_sequence + 1] = "shelf"
|
||||
error("kamare index broken")
|
||||
end
|
||||
local second
|
||||
source:syncBooksAsync(nil, function(result, err) second = { result = result, err = err } end)
|
||||
Stubs.flush()
|
||||
Assert.not_nil(second and second.result, "预热异常不影响同步结果")
|
||||
Assert.eq(table.concat(sequence, ","), "reconcile,shelf")
|
||||
-- 第二次仍失败:不能每次同步都刷一行日志(一次性),但也不能静默。
|
||||
source:syncBooksAsync(nil, function(result, err) second = { result = result, err = err } end)
|
||||
Stubs.flush()
|
||||
Assert.eq(#warns, 1, "投影预热失败检查并只记一次")
|
||||
Assert.matches(warns[1] or "", "shelf")
|
||||
Cache.shelf = real_shelf
|
||||
|
||||
-- Registry.reload() 会重建源实例:新实例顺手丢掉旧服务器的投影(05 A1 的第三类失效点)。
|
||||
local resets = 0
|
||||
local real_reset = Cache.resetShelf
|
||||
Cache.resetShelf = function()
|
||||
resets = resets + 1
|
||||
return real_reset()
|
||||
end
|
||||
SourceMod.new()
|
||||
Assert.eq(resets, 1, "重建源实例即失效书架投影")
|
||||
Cache.resetShelf = real_reset
|
||||
|
||||
return true
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,664 @@
|
||||
--[[--
|
||||
moonsource_kavita.stats:reading-history 条目 → reading_stats 行 / 替换指令 / 身份与时区映射。
|
||||
|
||||
对账基线 = research-kavita-stats-pull.md §3(样本 series 7453:64 条会话 / 14,237s)。
|
||||
|
||||
@module tests.moonsource_kavita.stats_spec
|
||||
--]]
|
||||
|
||||
local Assert = require("support.assert")
|
||||
local Config = require("support.config")
|
||||
|
||||
-- 日 / 时归属按进程时区(POSIX TZ)计算:钉死 CST-8,与 fixture 拉取时用的 Asia/Shanghai 对齐,
|
||||
-- 断言就不会随宿主机时区漂移。
|
||||
local ffi = require("ffi")
|
||||
ffi.cdef[[ int setenv(const char*, const char*, int); void tzset(void); ]]
|
||||
ffi.C.setenv("TZ", "CST-8", 1)
|
||||
ffi.C.tzset()
|
||||
|
||||
local warnings = {}
|
||||
package.preload["utils.log"] = function()
|
||||
return {
|
||||
dbg = function() end,
|
||||
info = function() end,
|
||||
warn = function(...) warnings[#warnings + 1] = table.concat({ ... }, " ") end,
|
||||
error = function() end,
|
||||
}
|
||||
end
|
||||
|
||||
local PLUGIN = (debug.getinfo(1, "S").source:match("^@(.-)/tests/") .. "/moonsource-kavita.koplugin/moonsource_kavita")
|
||||
package.preload["moonsource_kavita.stats"] = function()
|
||||
return dofile(PLUGIN .. "/stats.lua")
|
||||
end
|
||||
local Stats = require("moonsource_kavita.stats")
|
||||
|
||||
-- 固定拉取时刻(2026-10-16T12:00:00Z,晚于样本最后一天):last_time / book_total.start_time 都对它断言
|
||||
local FETCHED = 1792152000
|
||||
|
||||
--- 当天设备本地零点。日期本身来自服务端;期望时差另有 research §3 表兜底。
|
||||
local function dayTs(y, m, d)
|
||||
return os.time({ year = y, month = m, day = d, hour = 0 })
|
||||
end
|
||||
|
||||
--- 当天设备本地整点(时段桶键)。
|
||||
local function hourTs(y, m, d, h)
|
||||
return os.time({ year = y, month = m, day = d, hour = h })
|
||||
end
|
||||
|
||||
--- 按记录身份找行(不依赖 rows 顺序)。
|
||||
local function find(rows, record_type, stable_id, start_time)
|
||||
for _idx, row in ipairs(rows) do
|
||||
if row.record_type == record_type and row.stable_id == stable_id
|
||||
and (start_time == nil or row.start_time == start_time) then
|
||||
return row
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--- 需要跨日断言时看日归属是否真是「服务端那一天」。
|
||||
local function ymd(ts)
|
||||
return os.date("%Y-%m-%d", ts)
|
||||
end
|
||||
|
||||
do
|
||||
-- 对账:样本《太空漫游 · 2010》64 条会话。逐日时长 / 页数为 research §3 的已知值。
|
||||
local history = dofile((debug.getinfo(1, "S").source:match("^@(.*)/")) .. "/fixtures/history_7453.lua")
|
||||
local result = Stats.fromHistory(history, {
|
||||
source_id = "kavita",
|
||||
fetched_at = FETCHED,
|
||||
volumes = { [7453] = 4 },
|
||||
seen = { "7453:11270" },
|
||||
})
|
||||
|
||||
local total = find(result.rows, "total", "__kv:total", 0)
|
||||
Assert.not_nil(total, "账户累计行必须存在")
|
||||
Assert.eq(total.duration, 14237, "样本全量时长")
|
||||
Assert.eq(total.last_time, FETCHED, "累计行 last_time = 拉取时刻")
|
||||
|
||||
local days = {
|
||||
{ 2026, 9, 29, 316, 2 },
|
||||
{ 2026, 10, 5, 195, 0 },
|
||||
{ 2026, 10, 7, 503, 0 },
|
||||
{ 2026, 10, 8, 2036, 0 },
|
||||
{ 2026, 10, 11, 512, 0 },
|
||||
{ 2026, 10, 13, 979, 0 },
|
||||
{ 2026, 10, 14, 6734, 0 }, -- 当天 +1 / -1 分属两条会话:先求和再钳制,相抵为净 0 页
|
||||
{ 2026, 10, 15, 2962, 16 },
|
||||
}
|
||||
local day_rows = 0
|
||||
local day_sum = 0
|
||||
local day_ts = {}
|
||||
for _idx, d in ipairs(days) do
|
||||
local ts = dayTs(d[1], d[2], d[3])
|
||||
day_ts[ts] = true
|
||||
local row = find(result.rows, "day", "__kv:day:" .. ts, ts)
|
||||
Assert.not_nil(row, "缺少日桶 " .. d[1] .. "-" .. d[2] .. "-" .. d[3])
|
||||
Assert.eq(row.duration, d[4], "日桶时长 " .. ymd(ts))
|
||||
Assert.eq(row.event_count, d[5], "日桶页数增量 " .. ymd(ts))
|
||||
Assert.eq(row.last_time, FETCHED, "日桶 last_time = 拉取时刻")
|
||||
day_rows = day_rows + 1
|
||||
day_sum = day_sum + row.duration
|
||||
end
|
||||
Assert.eq(day_rows, 8, "只有有有效时长的日子落桶")
|
||||
Assert.eq(day_sum, 14237, "账户累计 = 各日之和")
|
||||
|
||||
-- 时段桶:每条活动行按自己的本地起始小时归档(跨零点的活动行取小时、仍记在条目那天)。
|
||||
local hour_rows, hour_total = 0, 0
|
||||
local hour_by_day = {}
|
||||
for _idx, row in ipairs(result.rows) do
|
||||
if row.record_type == "hour" then
|
||||
hour_rows = hour_rows + 1
|
||||
hour_total = hour_total + row.duration
|
||||
Assert.eq(row.stable_id, "__kv:hour:" .. row.start_time, "时段桶按整点做身份")
|
||||
Assert.eq(row.last_time, FETCHED, "时段桶 last_time = 拉取时刻")
|
||||
local d = os.date("%Y-%m-%d", row.start_time)
|
||||
hour_by_day[d] = (hour_by_day[d] or 0) + row.duration
|
||||
end
|
||||
end
|
||||
Assert.eq(hour_rows, 27, "样本 27 个整点有阅读")
|
||||
Assert.eq(hour_total, 14237, "时段之和 = 账户累计")
|
||||
Assert.eq(find(result.rows, "hour", "__kv:hour:" .. hourTs(2026, 10, 14, 11)).duration, 1352, "10-14 11 点")
|
||||
Assert.eq(find(result.rows, "hour", "__kv:hour:" .. hourTs(2026, 10, 14, 14)).duration, 1812, "10-14 14 点")
|
||||
Assert.eq(find(result.rows, "hour", "__kv:hour:" .. hourTs(2026, 9, 29, 18)).duration, 316, "9-29 18 点")
|
||||
Assert.eq(find(result.rows, "hour", "__kv:hour:" .. hourTs(2026, 10, 15, 21)).duration, 845, "10-15 21 点")
|
||||
-- 日页面「标题时长 = 时段图逐格之和」:逐日必须对得上
|
||||
for _idx, d in ipairs(days) do
|
||||
Assert.eq(hour_by_day[ymd(dayTs(d[1], d[2], d[3]))], d[4],
|
||||
"时段逐日之和 = 日桶 " .. d[1] .. "-" .. d[2] .. "-" .. d[3])
|
||||
end
|
||||
-- 零时长会话(10-06 的 4 条等)整条丢弃,不留日桶
|
||||
for _idx, d in ipairs({ { 2026, 10, 6 }, { 2026, 10, 9 }, { 2026, 10, 10 }, { 2026, 10, 12 } }) do
|
||||
local ts = dayTs(d[1], d[2], d[3])
|
||||
Assert.is_nil(find(result.rows, "day", "__kv:day:" .. ts, ts), "零时长日不留桶")
|
||||
end
|
||||
|
||||
-- 多卷系列:章节 4 卷 → 逐卷身份;11271 只在 9-29 读过,11273 是其余各日。
|
||||
local book_total = find(result.rows, "book_total", "7453:11273", FETCHED)
|
||||
Assert.not_nil(book_total, "卷累计行")
|
||||
Assert.eq(book_total.duration, 13921)
|
||||
Assert.eq(find(result.rows, "book_total", "7453:11271", FETCHED).duration, 316)
|
||||
|
||||
Assert.eq(find(result.rows, "book_day", "7453:11271", dayTs(2026, 9, 29)).duration, 316)
|
||||
local book_days, book_totals = 0, 0
|
||||
for _idx, row in ipairs(result.rows) do
|
||||
if row.record_type == "book_day" then
|
||||
book_days = book_days + 1
|
||||
Assert.is_true(row.duration > 0, "单书日行也必须正时长")
|
||||
Assert.is_true(day_ts[row.start_time] == true, "单书日行 start_time = 服务端那天的本地零点")
|
||||
elseif row.record_type == "book_total" then
|
||||
book_totals = book_totals + 1
|
||||
Assert.eq(row.start_time, FETCHED, "单书累计行的 start_time = 拉取时刻")
|
||||
end
|
||||
-- 云端快照没有页坐标,所有行 page / total_pages 恒为 0
|
||||
Assert.eq(row.page, 0, "云端行 page=0")
|
||||
Assert.eq(row.total_pages, 0, "云端行 total_pages=0")
|
||||
Assert.eq(row.source_id, "kavita")
|
||||
end
|
||||
Assert.eq(book_days, 8, "11271 一天 + 11273 七天")
|
||||
Assert.eq(book_totals, 2, "每卷一条累计快照")
|
||||
|
||||
-- 本次身份:持久化后下次当「上次身份」用于清孤儿行。
|
||||
Assert.eq(#result.identities, 2)
|
||||
Assert.contains(result.identities, "7453:11271")
|
||||
Assert.contains(result.identities, "7453:11273")
|
||||
|
||||
-- 替换:账户桶按前缀 + 覆盖全量重拉窗口的时间窗;单书按上次 ∪ 本次身份精确清。
|
||||
Assert.eq(result.replace.mode, "ranges")
|
||||
Assert.eq(#result.replace.ranges, 3)
|
||||
local ranges = {}
|
||||
for _idx, range in ipairs(result.replace.ranges) do ranges[range.stable_prefix] = range end
|
||||
local day_range, hour_range, total_range =
|
||||
ranges["__kv:day:"], ranges["__kv:hour:"], ranges["__kv:total"]
|
||||
Assert.not_nil(day_range, "日桶清理范围")
|
||||
Assert.not_nil(hour_range, "时段桶清理范围")
|
||||
Assert.not_nil(total_range, "总量行清理范围")
|
||||
Assert.eq(day_range.from_ts, 0)
|
||||
Assert.eq(day_range.to_ts, FETCHED)
|
||||
Assert.eq(hour_range.from_ts, 0)
|
||||
Assert.eq(hour_range.to_ts, FETCHED)
|
||||
Assert.eq(total_range.from_ts, 0)
|
||||
Assert.eq(total_range.to_ts, 0)
|
||||
-- 全量重拉的清理窗口必须盖住本次写出的每个桶,否则消失的桶会残留
|
||||
for _idx, row in ipairs(result.rows) do
|
||||
if row.record_type == "day" then
|
||||
Assert.is_true(row.start_time <= day_range.to_ts, "日桶落在清理窗口内")
|
||||
elseif row.record_type == "hour" then
|
||||
Assert.is_true(row.start_time <= hour_range.to_ts, "时段桶落在清理窗口内")
|
||||
end
|
||||
end
|
||||
Assert.eq(#result.replace.books, 3, "上次身份 ∪ 本次身份(含漂移孤儿)")
|
||||
Assert.contains(result.replace.books, "7453:11270")
|
||||
Assert.contains(result.replace.books, "7453:11271")
|
||||
Assert.contains(result.replace.books, "7453:11273")
|
||||
end
|
||||
|
||||
do
|
||||
-- 多章会话(跨卷)按章拆到各卷;单卷系列读在 series 行(research §5 的身份约定)。
|
||||
local result = Stats.fromHistory({
|
||||
{ seriesId = 55, localDate = "2026-10-10T00:00:00", chapters = {
|
||||
{ chapterId = 11, durationSeconds = 100, pagesRead = 2 },
|
||||
{ chapterId = 12, durationSeconds = 50, pagesRead = -1 },
|
||||
} },
|
||||
{ seriesId = 66, localDate = "2026-10-10T00:00:00", chapters = {
|
||||
{ chapterId = 21, durationSeconds = 70, pagesRead = 0 },
|
||||
} },
|
||||
}, { source_id = "kavita", fetched_at = 2000, volumes = { [55] = 2, [66] = 1 } })
|
||||
local day = dayTs(2026, 10, 10)
|
||||
Assert.eq(find(result.rows, "book_day", "55:11", day).duration, 100)
|
||||
Assert.eq(find(result.rows, "book_day", "55:12", day).duration, 50)
|
||||
Assert.eq(find(result.rows, "book_day", "66", day).duration, 70, "单卷记 series 身份")
|
||||
Assert.eq(find(result.rows, "book_total", "55:11", 2000).duration, 100)
|
||||
Assert.eq(find(result.rows, "book_total", "66", 2000).duration, 70)
|
||||
local day_row = find(result.rows, "day", "__kv:day:" .. day, day)
|
||||
Assert.eq(day_row.duration, 220, "账户日是各章之和")
|
||||
Assert.eq(day_row.event_count, 1, "当天页数先求和:2 + (-1) + 0")
|
||||
Assert.eq(find(result.rows, "total", "__kv:total", 0).duration, 220)
|
||||
-- 没有 startTimeUtc 的条目退回 localDate 分日;造不出小时就不造,绝不凭空补一个整点。
|
||||
for _idx, row in ipairs(result.rows) do
|
||||
Assert.is_true(row.record_type ~= "hour", "缺 startTimeUtc 不造时段桶")
|
||||
end
|
||||
Assert.len(result.identities, 3)
|
||||
Assert.contains(result.identities, "55:11")
|
||||
Assert.contains(result.identities, "55:12")
|
||||
Assert.contains(result.identities, "66")
|
||||
end
|
||||
|
||||
do
|
||||
-- 分日 / 分时按服务端 UTC 时刻在设备本地(CST-8)换算,不信服务端按请求时区给的 localDate。
|
||||
local result = Stats.fromHistory({
|
||||
-- 本地 10-16 07:59(UTC 10-15 23:59):服务端若按 UTC 算 localDate 会给 10-15,差一天。
|
||||
{ seriesId = 31, startTimeUtc = "2026-10-15T23:59:00.1", localDate = "2026-10-15T00:00:00",
|
||||
chapters = { { chapterId = 1, startTimeUtc = "2026-10-15T23:59:00.1", durationSeconds = 60, pagesRead = 1 } } },
|
||||
-- 本地 10-17 00:30 起、23:50 又读了一段:日桶在 10-17,两个时段格也都算 10-17 这天。
|
||||
{ seriesId = 32, startTimeUtc = "2026-10-16T16:30:00", localDate = "2026-10-17T00:00:00",
|
||||
chapters = {
|
||||
{ chapterId = 1, startTimeUtc = "2026-10-16T16:30:00", durationSeconds = 40, pagesRead = 0 },
|
||||
{ chapterId = 1, startTimeUtc = "2026-10-17T15:50:00", durationSeconds = 60, pagesRead = 0 },
|
||||
} },
|
||||
}, { source_id = "kavita", fetched_at = FETCHED, volumes = { [31] = 2, [32] = 2, [33] = 2 } })
|
||||
local d16, d17 = dayTs(2026, 10, 16), dayTs(2026, 10, 17)
|
||||
Assert.eq(find(result.rows, "day", "__kv:day:" .. d16, d16).duration, 60, "本地 07:59 落本地当天")
|
||||
Assert.eq(find(result.rows, "hour", "__kv:hour:" .. hourTs(2026, 10, 16, 7)).duration, 60, "本地 7 点格")
|
||||
Assert.eq(find(result.rows, "day", "__kv:day:" .. d17, d17).duration, 100, "本地 0:30 起的那条落 10-17")
|
||||
Assert.eq(find(result.rows, "hour", "__kv:hour:" .. hourTs(2026, 10, 17, 0)).duration, 40, "0 点格")
|
||||
Assert.eq(find(result.rows, "hour", "__kv:hour:" .. hourTs(2026, 10, 17, 23)).duration, 60, "23 点格")
|
||||
Assert.is_nil(find(result.rows, "hour", "__kv:hour:" .. hourTs(2026, 10, 18, 0)),
|
||||
"跨零点前的活动行不另起一天")
|
||||
end
|
||||
|
||||
do
|
||||
-- 负页数:按天先求和再钳制。逐条钳制会让 +5 / -5 相抵的日子凭空多出 5 页。
|
||||
local d1, d2 = dayTs(2026, 10, 1), dayTs(2026, 10, 2)
|
||||
local result = Stats.fromHistory({
|
||||
{ seriesId = 7, localDate = "2026-10-01T00:00:00", chapters = {
|
||||
{ chapterId = 1, durationSeconds = 10, pagesRead = 5 } } },
|
||||
{ seriesId = 7, localDate = "2026-10-01T00:00:00", chapters = {
|
||||
{ chapterId = 1, durationSeconds = 10, pagesRead = -5 } } },
|
||||
{ seriesId = 7, localDate = "2026-10-02T00:00:00", chapters = {
|
||||
{ chapterId = 1, durationSeconds = 10, pagesRead = -3 },
|
||||
{ chapterId = 1, durationSeconds = 10, pagesRead = -4 } } },
|
||||
}, { source_id = "kavita", fetched_at = 3000, volumes = { [7] = 2 } })
|
||||
Assert.eq(find(result.rows, "day", "__kv:day:" .. d1, d1).event_count, 0, "正负相抵为净 0")
|
||||
Assert.eq(find(result.rows, "day", "__kv:day:" .. d2, d2).event_count, 0, "负和钳制到 0")
|
||||
Assert.eq(find(result.rows, "day", "__kv:day:" .. d1, d1).duration, 20)
|
||||
Assert.eq(find(result.rows, "day", "__kv:day:" .. d2, d2).duration, 20)
|
||||
end
|
||||
|
||||
do
|
||||
-- 时区回退(UTC)下服务端的「日」可能晚于设备本地的拉取时刻(设备为负偏移):
|
||||
-- 日桶清理窗口的上界要盖到最后观测日的日终,否则当天桶清不掉,会残留到下一轮。
|
||||
local last_day = dayTs(2026, 10, 16)
|
||||
local fetched = last_day - 600 -- 设备本地 23:50,比最后观测日的零点还早
|
||||
local result = Stats.fromHistory({
|
||||
{ seriesId = 21, localDate = "2026-10-16T00:00:00",
|
||||
chapters = { { chapterId = 1, durationSeconds = 300, pagesRead = 1 } } },
|
||||
}, { source_id = "kavita", fetched_at = fetched, volumes = { [21] = 2 } })
|
||||
local day_range
|
||||
for _idx, range in ipairs(result.replace.ranges) do
|
||||
if range.stable_prefix == "__kv:day:" then day_range = range end
|
||||
end
|
||||
Assert.not_nil(day_range)
|
||||
Assert.eq(day_range.from_ts, 0, "窗口下界仍是 0(全量重拉)")
|
||||
Assert.eq(day_range.to_ts, last_day + 86399, "上界盖到最后观测日的日终")
|
||||
for _idx, row in ipairs(result.rows) do
|
||||
if row.record_type == "day" then
|
||||
Assert.is_true(row.start_time <= day_range.to_ts, "日桶落在清理窗口内")
|
||||
end
|
||||
end
|
||||
Assert.eq(day_range.stable_prefix:sub(1, 5), "__kv:", "范围只匹配本源的合成行,本地记录不受影响")
|
||||
end
|
||||
|
||||
do
|
||||
-- 零时长条目整条丢弃(连页数一起):Kavita 会给「打开没读」建 0 时长会话。
|
||||
-- 本次身份照交回,好让 replace.books 清掉它上次留下的行。
|
||||
local d = dayTs(2026, 10, 3)
|
||||
local before = #warnings
|
||||
local result = Stats.fromHistory({
|
||||
{ seriesId = 8, localDate = "2026-10-03T00:00:00", chapters = {
|
||||
{ chapterId = 1, durationSeconds = 0, pagesRead = 9 } } },
|
||||
{ seriesId = 8, localDate = "2026-10-03T00:00:00", chapters = {
|
||||
{ chapterId = 1, durationSeconds = 60, pagesRead = 0 } } },
|
||||
-- 目录拿不到章数的系列判不出身份:整体跳过,不猜单卷 / 多卷
|
||||
{ seriesId = 999, localDate = "2026-10-03T00:00:00", chapters = {
|
||||
{ chapterId = 1, durationSeconds = 100, pagesRead = 1 } } },
|
||||
}, { source_id = "kavita", fetched_at = 4000, volumes = { [8] = 2 }, seen = { "8:1" } })
|
||||
Assert.eq(find(result.rows, "book_day", "8:1", d).duration, 60)
|
||||
Assert.eq(find(result.rows, "day", "__kv:day:" .. d, d).event_count, 0, "零时长条目的页数不算")
|
||||
Assert.eq(find(result.rows, "total", "__kv:total", 0).duration, 60, "跳过的系列不进总量")
|
||||
Assert.eq(#result.identities, 1)
|
||||
Assert.contains(result.identities, "8:1")
|
||||
Assert.eq(#result.replace.books, 1)
|
||||
Assert.contains(result.replace.books, "8:1")
|
||||
local mentioned = false
|
||||
for i = before + 1, #warnings do
|
||||
if warnings[i]:find("999", 1, true) then mentioned = true end
|
||||
end
|
||||
Assert.is_true(mentioned, "跳过的系列要能被日志定位")
|
||||
|
||||
-- 空回包不炸:仍给出完整的替换指令(全量重拉窗口照旧清)
|
||||
local empty = Stats.fromHistory(nil, { source_id = "kavita", fetched_at = 4000 })
|
||||
Assert.len(empty.rows, 0)
|
||||
Assert.len(empty.identities, 0)
|
||||
Assert.len(empty.replace.books, 0)
|
||||
Assert.eq(#empty.replace.ranges, 3)
|
||||
end
|
||||
|
||||
do
|
||||
-- seen 的重复 / 空串不进 books;并集按 stable_id 精确去重(4 / 42 互为前缀,不能用 LIKE)
|
||||
local result = Stats.fromHistory({
|
||||
{ seriesId = 9, localDate = "2026-10-04T00:00:00", chapters = {
|
||||
{ chapterId = 1, durationSeconds = 5, pagesRead = 0 } } },
|
||||
}, { source_id = "kavita", fetched_at = 5000, volumes = { [9] = 2 },
|
||||
seen = { "9:1", "", "9:1", "stale" } })
|
||||
Assert.eq(#result.replace.books, 2)
|
||||
Assert.contains(result.replace.books, "9:1")
|
||||
Assert.contains(result.replace.books, "stale")
|
||||
end
|
||||
|
||||
do
|
||||
-- 时区映射全表:设备时钟的 19 项 POSIX 串 → IANA(Kavita 的 TimeZoneId)
|
||||
local expected = {
|
||||
["HST10"] = "Pacific/Honolulu",
|
||||
["AKST9AKDT,M3.2.0,M11.1.0"] = "America/Anchorage",
|
||||
["PST8PDT,M3.2.0,M11.1.0"] = "America/Los_Angeles",
|
||||
["MST7MDT,M3.2.0,M11.1.0"] = "America/Denver",
|
||||
["CST6CDT,M3.2.0,M11.1.0"] = "America/Chicago",
|
||||
["EST5EDT,M3.2.0,M11.1.0"] = "America/New_York",
|
||||
["<-03>3"] = "America/Sao_Paulo",
|
||||
["UTC0"] = "UTC",
|
||||
["GMT0BST,M3.5.0/1,M10.5.0"] = "Europe/London",
|
||||
["CET-1CEST,M3.5.0,M10.5.0/3"] = "Europe/Berlin",
|
||||
["EET-2EEST,M3.5.0/3,M10.5.0/4"] = "Europe/Athens",
|
||||
["MSK-3"] = "Europe/Moscow",
|
||||
["<+04>-4"] = "Asia/Dubai",
|
||||
["IST-5:30"] = "Asia/Kolkata",
|
||||
["<+07>-7"] = "Asia/Bangkok",
|
||||
["CST-8"] = "Asia/Shanghai",
|
||||
["JST-9"] = "Asia/Tokyo",
|
||||
["AEST-10AEDT,M10.1.0,M4.1.0/3"] = "Australia/Sydney",
|
||||
["NZST-12NZDT,M9.5.0,M4.1.0/3"] = "Pacific/Auckland",
|
||||
}
|
||||
local n = 0
|
||||
for posix, iana in pairs(expected) do
|
||||
n = n + 1
|
||||
Assert.eq(Stats.ianaTimezone(posix), iana, posix)
|
||||
end
|
||||
Assert.eq(n, 19)
|
||||
|
||||
-- 与设置页的时区表保持同步(读源码不 require UI 依赖):时钟加项时必须同步映射
|
||||
local file = assert(io.open(Config.root() .. "/book.koplugin/features/clock/init.lua", "r"))
|
||||
local source = file:read("*a")
|
||||
file:close()
|
||||
local in_block, covered = false, 0
|
||||
for line in source:gmatch("[^\n]+") do
|
||||
if line:match("Clock%.TIMEZONES%s*=") then
|
||||
in_block = true
|
||||
elseif in_block then
|
||||
if line:match("^}") then break end
|
||||
local posix = line:match('tz%s*=%s*"([^"]*)"')
|
||||
if posix and posix ~= "" then
|
||||
covered = covered + 1
|
||||
Assert.not_nil(expected[posix], "时钟时区缺少 IANA 映射:" .. posix)
|
||||
end
|
||||
end
|
||||
end
|
||||
Assert.eq(covered, 19, "时钟时区表全部覆盖")
|
||||
|
||||
-- 未知 / 空串(跟随系统)回退 UTC 并 warn,不做地区默认
|
||||
local before = #warnings
|
||||
Assert.eq(Stats.ianaTimezone(""), "UTC")
|
||||
Assert.eq(Stats.ianaTimezone("NOPE-1"), "UTC")
|
||||
Assert.eq(Stats.ianaTimezone(nil), "UTC")
|
||||
Assert.eq(#warnings, before + 3, "每次回退都记一条日志")
|
||||
end
|
||||
|
||||
do
|
||||
-- 阅读会话行:每个「会话 × 章」切片的真实起始时刻 / 时长 / 页数,供详情「阅读记录」列出时段。
|
||||
-- 它只进列表,不参与日 / 时段 / 总量汇总。
|
||||
local day = dayTs(2026, 10, 10)
|
||||
local result = Stats.fromHistory({
|
||||
{ seriesId = 66, startTimeUtc = "2026-10-10T09:00:00.0000000", chapters = {
|
||||
{ chapterId = 1, durationSeconds = 600, pagesRead = 12,
|
||||
startTimeUtc = "2026-10-10T09:00:00.0000000" },
|
||||
{ chapterId = 2, durationSeconds = 300, pagesRead = 3,
|
||||
startTimeUtc = "2026-10-10T09:20:00.0000000" },
|
||||
} },
|
||||
}, { source_id = "kavita", fetched_at = 2000, volumes = { [66] = 1 } })
|
||||
|
||||
local first = find(result.rows, "cloud_session", "66", hourTs(2026, 10, 10, 17))
|
||||
Assert.not_nil(first, "会话行按章切片的本地起始时刻落行")
|
||||
Assert.eq(first.duration, 600)
|
||||
Assert.eq(first.event_count, 12, "页数记在 event_count")
|
||||
Assert.eq(first.last_time, 2000, "会话行 last_time = 拉取时刻")
|
||||
local second = find(result.rows, "cloud_session", "66", hourTs(2026, 10, 10, 17) + 20 * 60)
|
||||
Assert.not_nil(second)
|
||||
Assert.eq(second.duration, 300)
|
||||
Assert.eq(second.event_count, 3)
|
||||
|
||||
-- 会话行不影响任何汇总桶:日桶 / 总量仍是 900,且不会多出 hour 之外的重复
|
||||
Assert.eq(find(result.rows, "day", "__kv:day:" .. day, day).duration, 900)
|
||||
Assert.eq(find(result.rows, "total", "__kv:total", 0).duration, 900)
|
||||
Assert.eq(find(result.rows, "book_day", "66", day).duration, 900)
|
||||
|
||||
-- 零时长会话不落会话行
|
||||
local zero = Stats.fromHistory({
|
||||
{ seriesId = 66, startTimeUtc = "2026-10-10T10:00:00.0000000", chapters = {
|
||||
{ chapterId = 1, durationSeconds = 0, pagesRead = 0,
|
||||
startTimeUtc = "2026-10-10T10:00:00.0000000" },
|
||||
} },
|
||||
}, { source_id = "kavita", fetched_at = 2000, volumes = { [66] = 1 } })
|
||||
Assert.is_nil(find(zero.rows, "cloud_session", "66"), "打开没读的会话不落行")
|
||||
end
|
||||
|
||||
do
|
||||
-- 漫画(seriesFormat 0 Image / 1 Archive)的会话行补真实页坐标:page = endPage(读到哪)、
|
||||
-- total_pages = chapter.totalPages(卷级,汇总处继续 MAX);event_count 是**本次新推进的页数**
|
||||
-- (不是 pagesRead —— 重读会重复计入,见下方进度用例)。pagesRead = 0 是合法值,不是缺数据。
|
||||
local result = Stats.fromHistory({
|
||||
{ seriesId = 70, seriesFormat = 0, startTimeUtc = "2026-10-10T09:00:00.0000000", chapters = {
|
||||
{ chapterId = 1, durationSeconds = 300, pagesRead = 12, startPage = 3, endPage = 15,
|
||||
totalPages = 194, startTimeUtc = "2026-10-10T09:00:00.0000000" },
|
||||
} },
|
||||
-- Archive 同样算漫画;同一系列两卷各自的卷级总页数不同,不能被条目级 totalPages 抹平。
|
||||
{ seriesId = 71, seriesFormat = 1, startTimeUtc = "2026-10-10T10:00:00.0000000", chapters = {
|
||||
{ chapterId = 2, durationSeconds = 60, pagesRead = 0, startPage = 1, endPage = 1,
|
||||
totalPages = 40, startTimeUtc = "2026-10-10T10:00:00.0000000" },
|
||||
{ chapterId = 3, durationSeconds = 90, pagesRead = 7, startPage = 20, endPage = 30,
|
||||
totalPages = 52, startTimeUtc = "2026-10-10T10:30:00.0000000" },
|
||||
} },
|
||||
-- epub 的 Chapter.Pages 是 spine 数、与渲染页无关:页坐标保持 0,不因带 endPage 就填。
|
||||
{ seriesId = 72, seriesFormat = 3, startTimeUtc = "2026-10-10T11:00:00.0000000", chapters = {
|
||||
{ chapterId = 4, durationSeconds = 600, pagesRead = 7, startPage = 15, endPage = 15,
|
||||
totalPages = 22, startTimeUtc = "2026-10-10T11:00:00.0000000" },
|
||||
} },
|
||||
}, { source_id = "kavita", fetched_at = 2000, volumes = { [70] = 1, [71] = 1, [72] = 1 } })
|
||||
|
||||
local image = find(result.rows, "cloud_session", "70", hourTs(2026, 10, 10, 17))
|
||||
Assert.not_nil(image, "Image 漫画的会话行")
|
||||
Assert.eq(image.page, 15, "page = chapter.endPage")
|
||||
Assert.eq(image.total_pages, 194, "total_pages = chapter.totalPages")
|
||||
Assert.eq(image.event_count, 15, "event_count = 本次新推进的页数(0 → 15)")
|
||||
|
||||
local archive_zero = find(result.rows, "cloud_session", "71", hourTs(2026, 10, 10, 18))
|
||||
Assert.not_nil(archive_zero, "Archive 漫画的会话行")
|
||||
Assert.eq(archive_zero.page, 1, "page = endPage(未翻页也合法)")
|
||||
Assert.eq(archive_zero.total_pages, 40, "卷级总页数")
|
||||
Assert.eq(archive_zero.event_count, 1, "推进到第 1 页即 1 页,与 pagesRead = 0 无关")
|
||||
local archive_more = find(result.rows, "cloud_session", "71", hourTs(2026, 10, 10, 18) + 30 * 60)
|
||||
Assert.not_nil(archive_more, "同一条目里的第二卷")
|
||||
Assert.eq(archive_more.page, 30)
|
||||
Assert.eq(archive_more.total_pages, 52, "逐章取自己的卷级总页数")
|
||||
Assert.eq(archive_more.event_count, 29, "1 → 30 只推进 29 页(不是 pagesRead 7)")
|
||||
|
||||
local epub = find(result.rows, "cloud_session", "72", hourTs(2026, 10, 10, 19))
|
||||
Assert.not_nil(epub, "epub 的会话行照旧落")
|
||||
Assert.eq(epub.page, 0, "epub 不填 page")
|
||||
Assert.eq(epub.total_pages, 0, "epub 不填 total_pages")
|
||||
Assert.eq(epub.event_count, 7, "epub 仍用 pagesRead")
|
||||
|
||||
-- 页坐标只加在会话行上:日 / 单书桶维持「云端快照没有页坐标」的语义(汇总另算)。
|
||||
local day = dayTs(2026, 10, 10)
|
||||
for _idx, row in ipairs(result.rows) do
|
||||
if row.record_type ~= "cloud_session" then
|
||||
Assert.eq(row.page, 0, row.record_type .. " 行 page 仍为 0")
|
||||
Assert.eq(row.total_pages, 0, row.record_type .. " 行 total_pages 仍为 0")
|
||||
end
|
||||
end
|
||||
-- 当天页数 = 15(70)+ 1(71 卷 2)+ 29(71 卷 3)+ 7(epub 仍是 pagesRead)
|
||||
Assert.eq(find(result.rows, "day", "__kv:day:" .. day, day).event_count, 52)
|
||||
Assert.eq(find(result.rows, "book_day", "70", day).duration, 300)
|
||||
end
|
||||
|
||||
do
|
||||
-- 漫画的已读页数按「最远进度」算,不按页次累加:pagesRead 是「这次翻了多少页」,
|
||||
-- 重读会重复计入(实测 194 页的卷 6 条会话 pagesRead 合计 284,已读页数超过了总页数)。
|
||||
-- 样本:大剑 Vol.10,总 194 页;依次读到 3 → 91 → 42(重读)→ 94 → 126 → 194。
|
||||
local sessions = {
|
||||
{ end_page = 3, pages_read = 3 },
|
||||
{ end_page = 91, pages_read = 87 },
|
||||
{ end_page = 42, pages_read = 42 },
|
||||
{ end_page = 94, pages_read = 48 },
|
||||
{ end_page = 126, pages_read = 34 },
|
||||
{ end_page = 194, pages_read = 70 },
|
||||
}
|
||||
local expected = { 3, 88, 0, 3, 32, 68 } -- 每次都只是「比此前更远」的那一段;合计 194
|
||||
|
||||
local function history()
|
||||
local entries = {}
|
||||
for i, s in ipairs(sessions) do
|
||||
-- UTC 01..06 点 → 本地(CST-8)09..14 点,同一本地的天。
|
||||
local utc = string.format("2026-10-10T%02d:00:00", i)
|
||||
entries[#entries + 1] = { seriesId = 100, seriesFormat = 0, startTimeUtc = utc, chapters = {
|
||||
{ chapterId = 1, durationSeconds = 60, pagesRead = s.pages_read, startPage = 0,
|
||||
endPage = s.end_page, totalPages = 194, startTimeUtc = utc } } }
|
||||
end
|
||||
return entries
|
||||
end
|
||||
|
||||
local day = dayTs(2026, 10, 10)
|
||||
local function check(entries, label)
|
||||
local result = Stats.fromHistory(entries,
|
||||
{ source_id = "kavita", fetched_at = 2000, volumes = { [100] = 1 } })
|
||||
local sum = 0
|
||||
local session_rows = 0
|
||||
for _idx, row in ipairs(result.rows) do
|
||||
if row.record_type == "cloud_session" and row.stable_id == "100" then
|
||||
session_rows = session_rows + 1
|
||||
end
|
||||
end
|
||||
Assert.eq(session_rows, #sessions, label .. ":每条有时长的会话各落一行,不多不少")
|
||||
for i, want in ipairs(expected) do
|
||||
local row = find(result.rows, "cloud_session", "100", hourTs(2026, 10, 10, 8 + i))
|
||||
Assert.not_nil(row, label .. ":第 " .. i .. " 条会话行")
|
||||
Assert.eq(row.event_count, want, label .. ":第 " .. i .. " 条只算新推进的页数")
|
||||
-- 重读(第 3 条 endPage 42 < 已到达 91)页数为 0,但 page 仍如实记 42。
|
||||
Assert.eq(row.page, sessions[i].end_page, label .. ":第 " .. i .. " 条 page 仍记 endPage")
|
||||
Assert.eq(row.total_pages, 194, label .. ":第 " .. i .. " 条卷级总页数")
|
||||
sum = sum + row.event_count
|
||||
end
|
||||
Assert.eq(sum, 194, label .. ":合计 = 读到的最远页码 = 总页数")
|
||||
Assert.eq(find(result.rows, "day", "__kv:day:" .. day, day).event_count, 194,
|
||||
label .. ":当天页数也是进度而不是页次")
|
||||
end
|
||||
|
||||
check(history(), "正序")
|
||||
-- 回包可能是新→旧:按章起始时刻排序,结果不受遍历顺序影响。
|
||||
local reversed = {}
|
||||
local forward = history()
|
||||
for i = #forward, 1, -1 do reversed[#reversed + 1] = forward[i] end
|
||||
check(reversed, "倒序")
|
||||
end
|
||||
|
||||
do
|
||||
-- durationSeconds = 0 但有推进的章行照样发行:Kavita 的会话是「两次进度写入之间」,
|
||||
-- 只写一次就是 0 秒,可推进的页数是真的(详情页「已读页数 / 上次阅读」靠它)。
|
||||
-- 它同时要参与进度序列与当天页数,否则这段跳读会从当天页面消失、
|
||||
-- 而后续会话又因为 reached 更高而少算,合计就对不上读到的最远页码。
|
||||
local d = dayTs(2026, 10, 11)
|
||||
local result = Stats.fromHistory({
|
||||
{ seriesId = 101, seriesFormat = 0, startTimeUtc = "2026-10-11T02:00:00", chapters = {
|
||||
{ chapterId = 1, durationSeconds = 0, pagesRead = 20, startPage = 5, endPage = 60,
|
||||
totalPages = 100, startTimeUtc = "2026-10-11T02:00:00" } } },
|
||||
{ seriesId = 101, seriesFormat = 0, startTimeUtc = "2026-10-11T03:00:00", chapters = {
|
||||
{ chapterId = 1, durationSeconds = 120, pagesRead = 5, startPage = 60, endPage = 70,
|
||||
totalPages = 100, startTimeUtc = "2026-10-11T03:00:00" } } },
|
||||
}, { source_id = "kavita", fetched_at = 2000, volumes = { [101] = 1 } })
|
||||
|
||||
local jump = find(result.rows, "cloud_session", "101", hourTs(2026, 10, 11, 10))
|
||||
Assert.not_nil(jump, "零时长但有推进的章行也发行(页数是真推进)")
|
||||
Assert.eq(jump.duration, 0)
|
||||
Assert.eq(jump.event_count, 60)
|
||||
local read = find(result.rows, "cloud_session", "101", hourTs(2026, 10, 11, 11))
|
||||
Assert.not_nil(read)
|
||||
Assert.eq(read.event_count, 10, "跳读已把进度推到 60,本次只推进 10 页")
|
||||
Assert.eq(read.page, 70)
|
||||
Assert.eq(find(result.rows, "day", "__kv:day:" .. d, d).event_count, 70,
|
||||
"当天页数 = 最远页码(含零时长跳读推进的 60)")
|
||||
|
||||
-- 登记身份用于清孤儿行:零时长条目照旧算见过(它上次可能留下过行)。
|
||||
Assert.contains(result.identities, "101")
|
||||
end
|
||||
|
||||
do
|
||||
-- endPage 超过总页数(不同版本页数不一致)时钳到总页数:已读页数不可能超过总页数。
|
||||
local d = dayTs(2026, 10, 12)
|
||||
local result = Stats.fromHistory({
|
||||
{ seriesId = 102, seriesFormat = 1, startTimeUtc = "2026-10-12T02:00:00", chapters = {
|
||||
{ chapterId = 1, durationSeconds = 60, pagesRead = 40, startPage = 0, endPage = 250,
|
||||
totalPages = 194, startTimeUtc = "2026-10-12T02:00:00" } } },
|
||||
}, { source_id = "kavita", fetched_at = 2000, volumes = { [102] = 1 } })
|
||||
local row = find(result.rows, "cloud_session", "102", hourTs(2026, 10, 12, 10))
|
||||
Assert.not_nil(row)
|
||||
Assert.eq(row.event_count, 194, "推进钳到总页数")
|
||||
Assert.eq(row.total_pages, 194)
|
||||
Assert.eq(find(result.rows, "day", "__kv:day:" .. d, d).event_count, 194, "当天页数也被钳")
|
||||
|
||||
-- 拿不到总页数(totalPages = 0 / 缺字段)时不假设上界:按 endPage 原样算。
|
||||
local unknown = Stats.fromHistory({
|
||||
{ seriesId = 103, seriesFormat = 0, startTimeUtc = "2026-10-12T05:00:00", chapters = {
|
||||
{ chapterId = 1, durationSeconds = 60, pagesRead = 9, endPage = 77,
|
||||
startTimeUtc = "2026-10-12T05:00:00" } } },
|
||||
}, { source_id = "kavita", fetched_at = 2000, volumes = { [103] = 1 } })
|
||||
local no_total = find(unknown.rows, "cloud_session", "103", hourTs(2026, 10, 12, 13))
|
||||
Assert.not_nil(no_total)
|
||||
Assert.eq(no_total.event_count, 77, "缺总页数就照 endPage 算")
|
||||
Assert.eq(no_total.total_pages, 0)
|
||||
end
|
||||
|
||||
do
|
||||
-- 多卷:每卷(stable_id = seriesId:chapterId)各自从 0 起算进度,互不影响;
|
||||
-- 合计 = 各卷进度之和(≤ 各卷总页数之和)。
|
||||
local d = dayTs(2026, 10, 13)
|
||||
local result = Stats.fromHistory({
|
||||
{ seriesId = 80, seriesFormat = 0, startTimeUtc = "2026-10-13T02:00:00", chapters = {
|
||||
{ chapterId = 1, durationSeconds = 60, pagesRead = 10, endPage = 10, totalPages = 40,
|
||||
startTimeUtc = "2026-10-13T02:00:00" } } },
|
||||
{ seriesId = 80, seriesFormat = 0, startTimeUtc = "2026-10-13T03:00:00", chapters = {
|
||||
{ chapterId = 1, durationSeconds = 60, pagesRead = 20, endPage = 30, totalPages = 40,
|
||||
startTimeUtc = "2026-10-13T03:00:00" } } },
|
||||
{ seriesId = 80, seriesFormat = 0, startTimeUtc = "2026-10-13T04:00:00", chapters = {
|
||||
{ chapterId = 2, durationSeconds = 60, pagesRead = 5, endPage = 5, totalPages = 60,
|
||||
startTimeUtc = "2026-10-13T04:00:00" } } },
|
||||
{ seriesId = 80, seriesFormat = 0, startTimeUtc = "2026-10-13T05:00:00", chapters = {
|
||||
{ chapterId = 2, durationSeconds = 60, pagesRead = 45, endPage = 50, totalPages = 60,
|
||||
startTimeUtc = "2026-10-13T05:00:00" } } },
|
||||
}, { source_id = "kavita", fetched_at = 2000, volumes = { [80] = 2 } })
|
||||
|
||||
Assert.eq(find(result.rows, "cloud_session", "80:1", hourTs(2026, 10, 13, 10)).event_count, 10)
|
||||
Assert.eq(find(result.rows, "cloud_session", "80:1", hourTs(2026, 10, 13, 11)).event_count, 20)
|
||||
Assert.eq(find(result.rows, "cloud_session", "80:2", hourTs(2026, 10, 13, 12)).event_count, 5)
|
||||
Assert.eq(find(result.rows, "cloud_session", "80:2", hourTs(2026, 10, 13, 13)).event_count, 45)
|
||||
Assert.eq(find(result.rows, "day", "__kv:day:" .. d, d).event_count, 80, "10 + 20 + 5 + 45")
|
||||
Assert.eq(find(result.rows, "cloud_session", "80:1", hourTs(2026, 10, 13, 10)).total_pages, 40)
|
||||
Assert.eq(find(result.rows, "cloud_session", "80:2", hourTs(2026, 10, 13, 13)).total_pages, 60)
|
||||
end
|
||||
|
||||
do
|
||||
-- epub / PDF 不受进度口径影响:pagesRead 照旧累加(重读同一页也算,这是「翻页数」语义),
|
||||
-- 页坐标仍为 0。
|
||||
local d = dayTs(2026, 10, 14)
|
||||
local result = Stats.fromHistory({
|
||||
{ seriesId = 202, seriesFormat = 3, startTimeUtc = "2026-10-14T02:00:00", chapters = {
|
||||
{ chapterId = 1, durationSeconds = 60, pagesRead = 7, startPage = 15, endPage = 15,
|
||||
totalPages = 22, startTimeUtc = "2026-10-14T02:00:00" } } },
|
||||
{ seriesId = 202, seriesFormat = 3, startTimeUtc = "2026-10-14T03:00:00", chapters = {
|
||||
{ chapterId = 1, durationSeconds = 60, pagesRead = 7, startPage = 15, endPage = 15,
|
||||
totalPages = 22, startTimeUtc = "2026-10-14T03:00:00" } } },
|
||||
-- PDF(4)同样不是渲染页,口径与 epub 一致。
|
||||
{ seriesId = 203, seriesFormat = 4, startTimeUtc = "2026-10-14T04:00:00", chapters = {
|
||||
{ chapterId = 1, durationSeconds = 60, pagesRead = 4, endPage = 99,
|
||||
totalPages = 120, startTimeUtc = "2026-10-14T04:00:00" } } },
|
||||
}, { source_id = "kavita", fetched_at = 2000, volumes = { [202] = 1, [203] = 1 } })
|
||||
|
||||
local first = find(result.rows, "cloud_session", "202", hourTs(2026, 10, 14, 10))
|
||||
local again = find(result.rows, "cloud_session", "202", hourTs(2026, 10, 14, 11))
|
||||
Assert.eq(first.event_count, 7, "epub 仍是 pagesRead")
|
||||
Assert.eq(again.event_count, 7, "epub 重读不折成 0(不是进度口径)")
|
||||
Assert.eq(first.page, 0)
|
||||
Assert.eq(first.total_pages, 0)
|
||||
local pdf = find(result.rows, "cloud_session", "203", hourTs(2026, 10, 14, 12))
|
||||
Assert.eq(pdf.event_count, 4, "PDF 仍是 pagesRead")
|
||||
Assert.eq(pdf.page, 0)
|
||||
Assert.eq(pdf.total_pages, 0)
|
||||
Assert.eq(find(result.rows, "day", "__kv:day:" .. d, d).event_count, 18, "7 + 7 + 4")
|
||||
end
|
||||
@@ -0,0 +1,282 @@
|
||||
--[[--
|
||||
端到端:卷列表里「缓存整部」→ 真实缓存适配层 → 真实后台任务队列 → 顶栏读到的任务 → 收尾提示。
|
||||
|
||||
用假的 kamare 模块(真缓存适配层 + 真队列 + 真卷列表 + 真轮询),只把「下载」外包出去,
|
||||
其余全走产品代码:这是跨仓 E2E 在离线环境里能做到的最大范围(模拟器 / 真机另做手工冒烟)。
|
||||
|
||||
@module tests.moonsource_kavita.tasks_e2e_spec
|
||||
--]]
|
||||
---@diagnostic disable: undefined-field, missing-fields, inject-field, redundant-parameter
|
||||
|
||||
local Assert = require("support.assert")
|
||||
local Config = require("support.config")
|
||||
local Kit = require("support.widget_stubs")
|
||||
Kit.install("paper")
|
||||
local Themed = require("support.theme_stubs")
|
||||
Themed.install()
|
||||
-- 真实的卷列表与二级菜单:Themed 的 list 桩会把 item.widget 丢掉,也就点不了行。
|
||||
package.preload["ui.themes.widgets.list"] = nil
|
||||
package.loaded["ui.themes.widgets.list"] = nil
|
||||
|
||||
local PLUGIN = (debug.getinfo(1, "S").source:match("^@(.-)/tests/") .. "/moonsource-kavita.koplugin/moonsource_kavita")
|
||||
|
||||
-- 源配置:真 cache.lua 只读 base_url / api_key;其余键仍走 Kit 的主题设置桩。
|
||||
local cfg = { base_url = "http://kavita.local", api_key = "key" }
|
||||
package.preload["utils.settings"] = function()
|
||||
return {
|
||||
get = function(owner)
|
||||
local name = owner:match("[^.]+$")
|
||||
if name == "ui" then return Kit.display end
|
||||
return Kit.sections[name]
|
||||
end,
|
||||
getSource = function() return cfg end,
|
||||
saveSource = function() end,
|
||||
}
|
||||
end
|
||||
package.preload["utils.log"] = function()
|
||||
return { info = function() end, warn = function() end, err = function() end, dbg = function() end }
|
||||
end
|
||||
package.preload["ui/network/manager"] = function()
|
||||
return { isConnected = function() return true end }
|
||||
end
|
||||
package.preload["ui.guard"] = function()
|
||||
return {
|
||||
call = function(_label, fn, ...) return fn(...) end,
|
||||
wrap = function(_label, fn) return fn end,
|
||||
}
|
||||
end
|
||||
|
||||
-- 假 kamare:队列与章状态都在内存里,由用例推进。
|
||||
local statuses, queue = {}, {}
|
||||
--- 重置假 kamare 的队列与章状态。
|
||||
local function resetKamare()
|
||||
statuses, queue = {}, {}
|
||||
queue = { state = "idle", entries = {} }
|
||||
end
|
||||
local kamare = {
|
||||
api_version = 1,
|
||||
capabilities = {
|
||||
status = true, resume_page = true, queue = true, queue_control = true,
|
||||
index = true, enqueue = true, delete = true, estimate = true, server = true,
|
||||
},
|
||||
}
|
||||
function kamare.register_server() return "server-key" end
|
||||
function kamare.status(_base_url, chapter_id) return statuses[tostring(chapter_id)] end
|
||||
function kamare.queue_state() return queue end
|
||||
function kamare.estimate(_base_url, entries)
|
||||
return { ok = true, chapters = #entries, bytes = #entries * 1024 * 1024,
|
||||
available = 4096 * 1024 * 1024 }
|
||||
end
|
||||
function kamare.enqueue(_base_url, entries)
|
||||
for _idx, entry in ipairs(entries) do
|
||||
queue.entries[tostring(entry.chapterId)] = { chapterId = entry.chapterId, state = "queued" }
|
||||
end
|
||||
queue.state = "downloading"
|
||||
return true, nil, { chapters = #entries }
|
||||
end
|
||||
package.loaded["kamarecache"] = kamare
|
||||
|
||||
--- kamare 开始下某一卷。
|
||||
local function startChapter(id)
|
||||
queue.entries[tostring(id)] = { chapterId = id, state = "downloading" }
|
||||
queue.current_chapter_id = id
|
||||
queue.state = "downloading"
|
||||
end
|
||||
|
||||
--- kamare 下完某一卷:章状态变 complete,队列项消失。
|
||||
local function finishChapter(id)
|
||||
statuses[tostring(id)] = { state = "complete", bytes = 1024 * 1024 }
|
||||
queue.entries[tostring(id)] = nil
|
||||
queue.current_chapter_id = nil
|
||||
if next(queue.entries) == nil then queue.state = "idle" end
|
||||
end
|
||||
|
||||
package.preload["moonsource_kavita.cache"] = function()
|
||||
return dofile(PLUGIN .. "/cache.lua")
|
||||
end
|
||||
package.preload["moonsource_kavita.cache_task"] = function()
|
||||
return dofile(PLUGIN .. "/cache_task.lua")
|
||||
end
|
||||
package.preload["moonsource_kavita.volume_list"] = function()
|
||||
return dofile(PLUGIN .. "/volume_list.lua")
|
||||
end
|
||||
|
||||
local Cache = require("moonsource_kavita.cache")
|
||||
local Tasks = require("workers.tasks")
|
||||
local VolumeList = require("moonsource_kavita.volume_list")
|
||||
|
||||
local series = { stable_id = "900", title = "测试系列" }
|
||||
local function entry(id, title, pages_read)
|
||||
return { chapterId = id, volumeId = id, seriesId = 900, libraryId = 1, format = 1,
|
||||
title = title, pages = 100, pagesRead = pages_read or 0 }
|
||||
end
|
||||
local toc = { entry(601, "第 1 卷", 100), entry(602, "第 2 卷", 40), entry(603, "第 3 卷", 0) }
|
||||
|
||||
--- Kit 的 unschedule 只记录、不从已排列表里删;真实 UIManager 会删,这里按记录过滤。
|
||||
---@param item table
|
||||
---@return boolean
|
||||
local function alive(item)
|
||||
for _idx, fn in ipairs(Kit.unscheduled) do
|
||||
if fn == item.fn then return false end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
--- 结清队列的变更拍(pause_auto_suspend)。
|
||||
local function changes()
|
||||
while true do
|
||||
local fired = false
|
||||
for index, item in ipairs(Kit.scheduled) do
|
||||
if item.delay < 1 and alive(item) then
|
||||
table.remove(Kit.scheduled, index)
|
||||
item.fn()
|
||||
fired = true
|
||||
break
|
||||
end
|
||||
end
|
||||
if not fired then return end
|
||||
end
|
||||
end
|
||||
|
||||
--- 跑一拍所有 1 秒以上的定时器(页面轮询 + 后台任务轮询各一拍)。
|
||||
local function round()
|
||||
local now, rest = {}, {}
|
||||
for _idx, item in ipairs(Kit.scheduled) do
|
||||
if item.delay >= 1 and alive(item) then now[#now + 1] = item else rest[#rest + 1] = item end
|
||||
end
|
||||
Kit.scheduled = rest
|
||||
for _idx, item in ipairs(now) do item.fn() end
|
||||
end
|
||||
|
||||
--- 顶栏「后台任务」的读数(与 desktop/topbar 同一口径:running / 未结束总数)。
|
||||
local function topbarText()
|
||||
local list = Tasks.tasks()
|
||||
if #list == 0 then return "空闲" end
|
||||
local running = 0
|
||||
for _idx, task in ipairs(list) do
|
||||
if task.state == "running" then running = running + 1 end
|
||||
end
|
||||
return running .. "/" .. #list
|
||||
end
|
||||
|
||||
---@param list table
|
||||
---@param widget table
|
||||
local function tap(list, widget)
|
||||
local size = widget.dimen
|
||||
local ges = Kit.tap(size.x + math.floor(size.w / 2), size.y + math.floor(size.h / 2))
|
||||
ges.ges = "tap"
|
||||
list:handleEvent(require("ui/event"):new("Gesture", ges))
|
||||
end
|
||||
|
||||
--- 打开卷列表并走「缓存整部」(菜单第一项)。第 1 卷已缓存,本批只下 2 卷。
|
||||
local function openAndCacheAll()
|
||||
statuses["601"] = { state = "complete", bytes = 1024 }
|
||||
local list = assert(VolumeList.pick(series, toc, function() end))
|
||||
list:show()
|
||||
list:paintTo(Kit.canvas(), 0, 0)
|
||||
list.left_callback()
|
||||
local menu = Kit.shown[#Kit.shown]
|
||||
menu:paintTo(Kit.canvas(), 0, 0)
|
||||
local rows = Kit.taps(menu)
|
||||
Assert.is_true(#rows >= 1, "有「缓存整部」")
|
||||
tap(menu, rows[1])
|
||||
local confirm = Themed.last("confirm")
|
||||
Assert.not_nil(confirm, "确认框")
|
||||
confirm.ok_callback()
|
||||
return list
|
||||
end
|
||||
|
||||
local function cleanup()
|
||||
for _idx, item in ipairs(Tasks.tasks()) do
|
||||
local live = Tasks.get(item.key)
|
||||
if live then live.cancel() end
|
||||
end
|
||||
changes()
|
||||
Kit.scheduled, Kit.unscheduled = {}, {}
|
||||
Themed.made = {}
|
||||
Cache.reset()
|
||||
resetKamare()
|
||||
end
|
||||
|
||||
-- 页面开着:入队 → 顶栏看得到 → 进度跟着 kamare 走 → 页面自己的进度框收尾(只提示一次)。
|
||||
do
|
||||
cleanup()
|
||||
local list = openAndCacheAll()
|
||||
|
||||
local tracked = Tasks.tasks()
|
||||
Assert.len(tracked, 1, "缓存进了后台任务队列")
|
||||
Assert.eq(tracked[1].kind, "cache")
|
||||
Assert.eq(tracked[1].title, "测试系列")
|
||||
Assert.eq(topbarText(), "1/1", "顶栏读到「1/1」")
|
||||
changes()
|
||||
Assert.is_true(require("pluginshare").pause_auto_suspend, "缓存期间不自动休眠")
|
||||
|
||||
startChapter(602)
|
||||
round()
|
||||
Assert.eq(Tasks.tasks()[1].text, "第 2 卷", "任务说明行跟 kamare 的当前卷")
|
||||
Assert.eq(Tasks.tasks()[1].total, 2, "只数本批(601 已缓存)")
|
||||
|
||||
finishChapter(602)
|
||||
startChapter(603)
|
||||
round()
|
||||
Assert.eq(Tasks.tasks()[1].count, 1, "下完一卷进度 +1")
|
||||
|
||||
finishChapter(603)
|
||||
round()
|
||||
Assert.len(Tasks.tasks(), 0, "全部落地后离开队列")
|
||||
Assert.eq(topbarText(), "空闲")
|
||||
changes()
|
||||
Assert.is_false(require("pluginshare").pause_auto_suspend, "结束放行自动休眠")
|
||||
local toasts = Themed.all("toast")
|
||||
Assert.eq(#toasts, 1, "页面进度框收尾,只提示一次")
|
||||
Assert.eq(toasts[1].text, "已缓存 2 卷")
|
||||
list:close()
|
||||
end
|
||||
|
||||
-- 页面提前关掉:后台任务继续跑,完成时由任务提示(不再有页面轮询)。
|
||||
do
|
||||
cleanup()
|
||||
local list = openAndCacheAll()
|
||||
startChapter(602)
|
||||
round()
|
||||
list:close()
|
||||
Assert.is_true(#Kit.unscheduled > 0, "关页撤掉页面轮询")
|
||||
|
||||
finishChapter(602)
|
||||
startChapter(603)
|
||||
round()
|
||||
Assert.eq(Tasks.tasks()[1].count, 1, "关页后任务仍在推进")
|
||||
|
||||
finishChapter(603)
|
||||
round()
|
||||
Assert.len(Tasks.tasks(), 0)
|
||||
local toasts = Themed.all("toast")
|
||||
Assert.eq(#toasts, 1, "关页后由任务报完成")
|
||||
Assert.eq(toasts[1].text, "已缓存 2 卷")
|
||||
Assert.eq(topbarText(), "空闲")
|
||||
end
|
||||
|
||||
-- 队列因空间不足暂停:任务留在列表里、报暂停原因、不再压制自动休眠;恢复后继续。
|
||||
do
|
||||
cleanup()
|
||||
local list = openAndCacheAll()
|
||||
startChapter(602)
|
||||
round()
|
||||
queue.state = "paused"
|
||||
queue.pause_reason = "low_space"
|
||||
round()
|
||||
Assert.eq(Tasks.tasks()[1].text, "空间不足,已暂停")
|
||||
changes()
|
||||
Assert.is_false(require("pluginshare").pause_auto_suspend, "暂停时允许自动休眠")
|
||||
|
||||
queue.state = "downloading"
|
||||
queue.pause_reason = nil
|
||||
round()
|
||||
changes()
|
||||
Assert.is_true(require("pluginshare").pause_auto_suspend, "恢复后继续撑住")
|
||||
finishChapter(602)
|
||||
finishChapter(603)
|
||||
round()
|
||||
Assert.len(Tasks.tasks(), 0, "恢复后照常收尾")
|
||||
list:close()
|
||||
end
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user