diff --git a/moonsource-weread.koplugin/moonsource_weread/_meta.lua b/moonsource-weread.koplugin/moonsource_weread/_meta.lua
index 9eb0369..6f76f7a 100644
--- a/moonsource-weread.koplugin/moonsource_weread/_meta.lua
+++ b/moonsource-weread.koplugin/moonsource_weread/_meta.lua
@@ -7,7 +7,7 @@
local _ = require("l10n").get("moonsource_weread")
return {
- id = "ext.weread",
+ id = "weread",
name = _("微信读书"),
type = "chapter",
description = _("微信读书书架与在线阅读"),
diff --git a/moonsource-weread.koplugin/moonsource_weread/assets.lua b/moonsource-weread.koplugin/moonsource_weread/assets.lua
index 70b969d..f62776c 100644
--- a/moonsource-weread.koplugin/moonsource_weread/assets.lua
+++ b/moonsource-weread.koplugin/moonsource_weread/assets.lua
@@ -317,7 +317,7 @@ end
function Assets.localizeAsync(book_id, chapter, html, referer, fetch_style, cb)
local cancelled = false
local jobs = {}
- local work_dir = Paths.bookWorkDir(book_id, "ext.weread")
+ local work_dir = Paths.bookWorkDir(book_id, "weread")
local images_dir = work_dir .. "/images"
--- 图片落地后再补样式表;已取消则丢弃。
diff --git a/moonsource-weread.koplugin/moonsource_weread/auth.lua b/moonsource-weread.koplugin/moonsource_weread/auth.lua
index 8da8117..568dae6 100644
--- a/moonsource-weread.koplugin/moonsource_weread/auth.lua
+++ b/moonsource-weread.koplugin/moonsource_weread/auth.lua
@@ -232,7 +232,7 @@ local function sessionRequest(method, url, body, opts, cb)
attempt(true)
elseif rejected then
if renew_err then logger.warn("wechat auth renew rejected", renew_err) end
- cb(nil, require("source.auth").expire("ext.weread", _("点这个提示上的「重新登录」。二维码出来以后,打开手机微信,点右上角「+」,再点「扫一扫」,对准屏幕上的二维码,在手机上点确认。")), res)
+ cb(nil, require("source.auth").expire("weread", _("点这个提示上的「重新登录」。二维码出来以后,打开手机微信,点右上角「+」,再点「扫一扫」,对准屏幕上的二维码,在手机上点确认。")), res)
else
cb(nil, renew_err or _("请求失败"), res)
end
@@ -246,7 +246,7 @@ local function sessionRequest(method, url, body, opts, cb)
if opts.no_expire then
cb(nil, _("微信读书拒绝了请求,请稍后再试"), res)
else
- cb(nil, require("source.auth").expire("ext.weread", _("点这个提示上的「重新登录」。二维码出来以后,打开手机微信,点右上角「+」,再点「扫一扫」,对准屏幕上的二维码,在手机上点确认。")), res)
+ cb(nil, require("source.auth").expire("weread", _("点这个提示上的「重新登录」。二维码出来以后,打开手机微信,点右上角「+」,再点「扫一扫」,对准屏幕上的二维码,在手机上点确认。")), res)
end
return
end
@@ -254,7 +254,7 @@ local function sessionRequest(method, url, body, opts, cb)
cb(nil, "HTTP " .. tostring(code), res)
return
end
- if not opts.skip_auth_retry then require("source.auth").ok("ext.weread") end
+ if not opts.skip_auth_retry then require("source.auth").ok("weread") end
if res then res.json = data end
cb(raw, nil, res)
end)
diff --git a/moonsource-weread.koplugin/moonsource_weread/chapter.lua b/moonsource-weread.koplugin/moonsource_weread/chapter.lua
index eb8bb93..92a85c3 100644
--- a/moonsource-weread.koplugin/moonsource_weread/chapter.lua
+++ b/moonsource-weread.koplugin/moonsource_weread/chapter.lua
@@ -207,7 +207,7 @@ function Chapter.primeBatchAsync(bookId, chapters, opts, cb)
end
local param = Package.formatChaptersParam(uids)
return downloadPackageAsync(bookId, param, book_type, function(files)
- local work_dir = Paths.bookWorkDir(bookId, "ext.weread")
+ local work_dir = Paths.bookWorkDir(bookId, "weread")
Paths.ensureDir(work_dir .. "/images")
for name, data in pairs(files) do
local base = name:match("^Images/([^/]+)$")
@@ -399,7 +399,7 @@ Chapter._noteTexts = noteTexts
---@return string[] uids
local function noteChapterUids(bookId)
local uids = {}
- for _idx, ch in ipairs(Toc.read("ext.weread", bookId) or {}) do
+ for _idx, ch in ipairs(Toc.read("weread", bookId) or {}) do
if tostring(ch.title or ""):find("注", 1, true) then uids[#uids + 1] = ch.uid end
end
return uids
@@ -411,7 +411,7 @@ local note_files = {}
---@param bookId string
---@return string
local function notesPath(bookId)
- return Paths.bookWorkDir(bookId, "ext.weread") .. "/notes.json"
+ return Paths.bookWorkDir(bookId, "weread") .. "/notes.json"
end
---@param bookId string
@@ -537,7 +537,7 @@ function Chapter.fetchContentAsync(bookId, chapter, cb)
cb({ title = title, html = "
" .. Text.xmlEscape(title) .. "
" .. html })
return
end
- local work_dir = Paths.bookWorkDir(bookId, "ext.weread")
+ local work_dir = Paths.bookWorkDir(bookId, "weread")
asset_job = Assets.localizeAsync(bookId, chapter, html, reader_url, function(done)
-- 章包里已有样式就不再打整书包;整书包才带公共背景图。
if type(style) == "string" and style ~= "" then
diff --git a/moonsource-weread.koplugin/moonsource_weread/eink.lua b/moonsource-weread.koplugin/moonsource_weread/eink.lua
index 45e1ae0..9c54d96 100644
--- a/moonsource-weread.koplugin/moonsource_weread/eink.lua
+++ b/moonsource-weread.koplugin/moonsource_weread/eink.lua
@@ -49,15 +49,15 @@ local VERSION_HEADERS = {
--- wechat 源配置(会话字段与用户信息都在这里)。
---@return table
function Eink.config()
- return require("utils.settings").getSource("ext.weread")
+ return require("utils.settings").getSource("weread")
end
---@param patch table 合并进 wechat 源配置并落盘
function Eink.save(patch)
local MoonSettings = require("utils.settings")
- local c = MoonSettings.getSource("ext.weread")
+ local c = MoonSettings.getSource("weread")
for k, v in pairs(patch) do c[k] = v end
- MoonSettings.saveSource("ext.weread", c)
+ MoonSettings.saveSource("weread", c)
end
--- 令牌就是网页会话(wr_vid/wr_skey 当 Cookie 可用),只落一份;eink 表只放续期要的两项。
@@ -80,7 +80,7 @@ local function saveSession(vid, access_token, refresh_token, device_id)
})
end
if current.wr_vid ~= vid then
- return require("source.logout").replaceLibrary("ext.weread", commit)
+ return require("source.logout").replaceLibrary("weread", commit)
end
commit()
return true
diff --git a/moonsource-weread.koplugin/moonsource_weread/extras.lua b/moonsource-weread.koplugin/moonsource_weread/extras.lua
index 0771bc4..93fe3a4 100644
--- a/moonsource-weread.koplugin/moonsource_weread/extras.lua
+++ b/moonsource-weread.koplugin/moonsource_weread/extras.lua
@@ -56,6 +56,6 @@ Ext.add("desktop.account_feeds", {
client = function() return require(PREFIX .. "client") end,
})
-Ext.add("reader.paragraph_lender", { id = "ext.weread", label = L("微信读书") })
+Ext.add("reader.paragraph_lender", { id = "weread", label = L("微信读书") })
return {}
diff --git a/moonsource-weread.koplugin/moonsource_weread/mapper.lua b/moonsource-weread.koplugin/moonsource_weread/mapper.lua
index 9c74513..6ad2012 100644
--- a/moonsource-weread.koplugin/moonsource_weread/mapper.lua
+++ b/moonsource-weread.koplugin/moonsource_weread/mapper.lua
@@ -10,7 +10,7 @@ local Text = require("utils.text")
local Mapper = {}
-local SOURCE_ID = "ext.weread"
+local SOURCE_ID = "weread"
--- 从嵌套 book/bookInfo 行解出书籍对象。
---@param row table|nil
diff --git a/moonsource-weread.koplugin/moonsource_weread/mp.lua b/moonsource-weread.koplugin/moonsource_weread/mp.lua
index 3186746..ae61efa 100644
--- a/moonsource-weread.koplugin/moonsource_weread/mp.lua
+++ b/moonsource-weread.koplugin/moonsource_weread/mp.lua
@@ -36,9 +36,9 @@ end
---@return integer removed
function Mp.dropLegacyBooks(BookDB)
local n = 0
- for _idx, id in ipairs(BookDB.stableIdsBySource("ext.weread") or {}) do
+ for _idx, id in ipairs(BookDB.stableIdsBySource("weread") or {}) do
if Mp.isMp(id) then
- BookDB.remove("ext.weread", id)
+ BookDB.remove("weread", id)
n = n + 1
end
end
diff --git a/moonsource-weread.koplugin/moonsource_weread/progress.lua b/moonsource-weread.koplugin/moonsource_weread/progress.lua
index 8c43acb..0cf11d0 100644
--- a/moonsource-weread.koplugin/moonsource_weread/progress.lua
+++ b/moonsource-weread.koplugin/moonsource_weread/progress.lua
@@ -18,7 +18,7 @@ local _ = require("l10n").get("moonsource_weread")
local Position = {}
local function cachePath(book_id, idx)
- return Paths.bookWorkDir(book_id, "ext.weread") .. "/" .. idx .. ".position.json"
+ return Paths.bookWorkDir(book_id, "weread") .. "/" .. idx .. ".position.json"
end
---@param book_id string
diff --git a/moonsource-weread.koplugin/moonsource_weread/setting.lua b/moonsource-weread.koplugin/moonsource_weread/setting.lua
index c627c08..b0197ff 100644
--- a/moonsource-weread.koplugin/moonsource_weread/setting.lua
+++ b/moonsource-weread.koplugin/moonsource_weread/setting.lua
@@ -1,6 +1,6 @@
--[[--
微信读书源设置 UI(扫码登录由本模块自绘)。
-读写:utils.settings.getSource / saveSource("ext.weread")
+读写:utils.settings.getSource / saveSource("weread")
@module koplugin.book.moonsource_weread.setting
--]]
@@ -8,7 +8,7 @@
local _ = require("l10n").get("moonsource_weread")
local T = require("ffi/util").template
-local SOURCE_ID = "ext.weread"
+local SOURCE_ID = "weread"
local Setting = {}
diff --git a/moonsource-weread.koplugin/moonsource_weread/shelf_import.lua b/moonsource-weread.koplugin/moonsource_weread/shelf_import.lua
index 2ff4f76..7c85a55 100644
--- a/moonsource-weread.koplugin/moonsource_weread/shelf_import.lua
+++ b/moonsource-weread.koplugin/moonsource_weread/shelf_import.lua
@@ -11,7 +11,7 @@
local Paths = require("utils.paths")
local _ = require("l10n").get("moonsource_weread")
-local SOURCE_ID = "ext.weread"
+local SOURCE_ID = "weread"
local ShelfImport = {}
diff --git a/moonsource-weread.koplugin/moonsource_weread/source.lua b/moonsource-weread.koplugin/moonsource_weread/source.lua
index ef4d35b..7a49573 100644
--- a/moonsource-weread.koplugin/moonsource_weread/source.lua
+++ b/moonsource-weread.koplugin/moonsource_weread/source.lua
@@ -51,7 +51,7 @@ Source.__index = Source
--- 构造微信读书源实例。
---@return WechatSource
function WeChat.new()
- local cfg = require("utils.settings").getSource("ext.weread")
+ local cfg = require("utils.settings").getSource("weread")
local meta = WeChat.meta()
---@type WechatSource
return setmetatable({
@@ -945,7 +945,7 @@ end
local function openSerial(source_id, stable_id)
local book = require("book.books_db").get(source_id, stable_id)
local meta = book and book.meta
- local data = meta and meta.source and meta.source["ext.weread"]
+ local data = meta and meta.source and meta.source["weread"]
local pay = tonumber(data and data.pay_type or meta and meta.weread_pay) or 0
local typ = tonumber(data and data.book_type or meta and meta.weread_type)
local ended = data and data.ended
diff --git a/tests/weread/assets_spec.lua b/tests/weread/assets_spec.lua
index 60a13e3..8cdc65a 100644
--- a/tests/weread/assets_spec.lua
+++ b/tests/weread/assets_spec.lua
@@ -118,7 +118,7 @@ end
-- 拉不到时去掉坏相对 link,注入 .content 兜底缩进(否则段首顶格)。
do
local Paths = require("utils.paths")
- local work_dir = Paths.bookWorkDir("book-3", "ext.weread")
+ local work_dir = Paths.bookWorkDir("book-3", "weread")
os.remove(work_dir .. "/stylesheets.css")
local head = ''
local link = ''
@@ -178,7 +178,7 @@ end
-- 章首页:body.bgimg-1 的开头出血图丢掉,连续 h1 包进整页容器;样式表里 ../Images/ 改指工作目录 images/
do
local Paths = require("utils.paths")
- local work_dir = Paths.bookWorkDir("book-4", "ext.weread")
+ local work_dir = Paths.bookWorkDir("book-4", "weread")
Paths.ensureDir(work_dir)
os.remove(work_dir .. "/stylesheets.css")
local src = ''
@@ -224,7 +224,7 @@ do
local icon = out:match('src="(images/[0-9a-f]+%.png)"')
Assert.is_true(icon ~= nil, "脚注图标落地: " .. case.src)
Assert.is_nil(out:find(case.src, 1, true), "原路径被改写: " .. case.src)
- local work_dir = Paths.bookWorkDir(case.book, "ext.weread")
+ local work_dir = Paths.bookWorkDir(case.book, "weread")
local f = assert(io.open(work_dir .. "/" .. icon, "rb"))
Assert.eq(f:read(4), "\137PNG")
f:close()
diff --git a/tests/weread/auth_spec.lua b/tests/weread/auth_spec.lua
index bb5839b..b6951a1 100644
--- a/tests/weread/auth_spec.lua
+++ b/tests/weread/auth_spec.lua
@@ -522,7 +522,7 @@ do
-- 普通接口照旧判失效
auth.webGetAsync("https://weread.qq.com/web/shelf/sync", nil, function(_d, e) err = e end)
Assert.matches(err, "扫一扫")
- Assert.eq(table.concat(expired, ","), "ext.weread")
+ Assert.eq(table.concat(expired, ","), "weread")
end
package.loaded["source.auth"] = real_source_auth
diff --git a/tests/weread/core/note_mutate_spec.lua b/tests/weread/core/note_mutate_spec.lua
index 27ec357..a14be45 100644
--- a/tests/weread/core/note_mutate_spec.lua
+++ b/tests/weread/core/note_mutate_spec.lua
@@ -68,9 +68,9 @@ end
package.loaded["source.registry"] = {
resolve = function(id)
- if id == "ext.weread" then
+ if id == "weread" then
return {
- id = "ext.weread",
+ id = "weread",
cleanAnnotations = wechat_notes.cleanAnnotations,
prepareLocalAnnotations = function(_, prev, cur)
return wechat_notes.prepareLocalAnnotations(prev, cur)
@@ -150,10 +150,10 @@ Assert.is_nil(got[1].note)
-- 微信:删除带 bookmark id 的划线必须留下 wr_deleted 墓碑,不能只从快照抹掉。
local wr = item({ wr_bookmark_id = "bm-1", wr_range = "10-20", text = "微信句子" })
-save("ext.weread", "wr-book", 3, { wr })
-local wr_key = Note.itemKey("ext.weread", "wr-book", 3, wr)
+save("weread", "wr-book", 3, { wr })
+local wr_key = Note.itemKey("weread", "wr-book", 3, wr)
Assert.is_true(Note.mutate({ key = wr_key, remove = true }))
-local wr_items = Normalize.decode(NoteDB.get("ext.weread", "wr-book", 3).payload)
+local wr_items = Normalize.decode(NoteDB.get("weread", "wr-book", 3).payload)
local tombs, visible = 0, 0
for _idx, it in ipairs(wr_items) do
if it.wr_deleted then
@@ -186,10 +186,10 @@ do
local Registry = require("source.registry")
local resolve = Registry.resolve
local pending = { datetime = wr.datetime, wr_bookmark_id = "pending", wr_deleted = true }
- save("ext.weread", "unavailable", 0, { wr, pending }, true)
- local before = NoteDB.get("ext.weread", "unavailable", 0)
+ save("weread", "unavailable", 0, { wr, pending }, true)
+ local before = NoteDB.get("weread", "unavailable", 0)
Registry.resolve = function() return nil, "source unavailable" end
- local unavailable_key = Note.itemKey("ext.weread", "unavailable", 0, wr)
+ local unavailable_key = Note.itemKey("weread", "unavailable", 0, wr)
for _idx, opts in ipairs({
{ key = unavailable_key, note = "不能保存" },
{ key = unavailable_key, remove = true },
@@ -197,7 +197,7 @@ do
local changed, change_err = Note.mutate(opts)
Assert.is_false(changed)
Assert.eq(change_err, "source unavailable")
- local after = NoteDB.get("ext.weread", "unavailable", 0)
+ local after = NoteDB.get("weread", "unavailable", 0)
Assert.eq(after.payload, before.payload)
Assert.eq(after.updated_at, before.updated_at)
Assert.eq(after.sync_status, before.sync_status)
diff --git a/tests/weread/core/note_sync_spec.lua b/tests/weread/core/note_sync_spec.lua
index 596bcf6..7352727 100644
--- a/tests/weread/core/note_sync_spec.lua
+++ b/tests/weread/core/note_sync_spec.lua
@@ -865,15 +865,15 @@ do -- 微信同文异位的离线笔记不能在开书时丢失,也不能落
drawer = "lighten", text = "重复原文", note = "想法二" },
}
local wechat = {
- id = "ext.weread",
+ id = "weread",
cleanAnnotations = function(_self, items, total) return Notes.cleanAnnotations(items, total) end,
mergeAnnotations = function(_self, remote, live, paging, authoritative)
return Notes.mergeAnnotations(remote, live, paging, authoritative)
end,
}
- local ref = { source_id = "ext.weread", stable_id = "offline-notes", source = wechat }
+ local ref = { source_id = "weread", stable_id = "offline-notes", source = wechat }
open_files["/offline-notes.epub"] = ref
- rows["ext.weread:offline-notes:0"] = { payload = JSON.encode({}), updated_at = 1, sync_status = 0 }
+ rows["weread:offline-notes:0"] = { payload = JSON.encode({}), updated_at = 1, sync_status = 0 }
local flushed = 0
local reader = {
document = { file = "/offline-notes.epub", getPageCount = function() return 10 end },
@@ -888,7 +888,7 @@ do -- 微信同文异位的离线笔记不能在开书时丢失,也不能落
Assert.eq(current[2].note, "想法二")
Assert.eq(flushed, 0, "不能把误判为重复的丢线结果刷新到 sidecar")
SessionNote.save(reader, ref)
- local stored = JSON.decode(rows["ext.weread:offline-notes:0"].payload)
+ local stored = JSON.decode(rows["weread:offline-notes:0"].payload)
Assert.len(stored, 2)
Assert.eq(stored[1].note, "想法一")
Assert.eq(stored[2].note, "想法二")
diff --git a/tests/weread/core/stats_db_book_total_spec.lua b/tests/weread/core/stats_db_book_total_spec.lua
index a88a0a7..c648f4e 100644
--- a/tests/weread/core/stats_db_book_total_spec.lua
+++ b/tests/weread/core/stats_db_book_total_spec.lua
@@ -49,10 +49,10 @@ end
--- 走真实入库路径:mapper → replaceSynced。
local function pull(annual_days, books, fetched_at)
- local result = WStats.fromWires("ext.weread", {},
+ local result = WStats.fromWires("weread", {},
annual_days and { { baseTime = D0, dailyReadTimes = annual_days } } or {},
nil, books, fetched_at)
- Assert.not_nil(StatsDB.replaceSynced("ext.weread", result.replace, result.rows))
+ Assert.not_nil(StatsDB.replaceSynced("weread", result.replace, result.rows))
end
local function byYmd(rows)
@@ -62,13 +62,13 @@ local function byYmd(rows)
end
-- 本地:D0 已上传 100(快照前)、D1 未上传 50、D1 快照后已上传 30
-page("ext.weread", "42", D0 + 3600, 100, true)
-page("ext.weread", "42", D1 + 3600, 50, false)
-page("ext.weread", "42", T1 + 3600, 30, true)
+page("weread", "42", D0 + 3600, 100, true)
+page("weread", "42", D1 + 3600, 50, false)
+page("weread", "42", T1 + 3600, 30, true)
-- 无云端:全本地
-Assert.eq(StatsDB.summaryByBook("ext.weread", "42").total_seconds, 180)
-Assert.eq(byYmd(StatsDB.dailyByBook("ext.weread", "42", 30))[YMD0], 100)
+Assert.eq(StatsDB.summaryByBook("weread", "42").total_seconds, 180)
+Assert.eq(byYmd(StatsDB.dailyByBook("weread", "42", 30))[YMD0], 100)
pull({ [tostring(D1)] = 195 }, {
{ id = "42", reading_time = 2578, wire = { readDetail = { data = {
@@ -80,23 +80,23 @@ pull({ [tostring(D1)] = 195 }, {
}, T1)
-- 单书累计:快照 + 未上传 50 + 快照后 30;快照前已上传的 100 已含在快照里
-Assert.eq(StatsDB.summaryByBook("ext.weread", "42").total_seconds, 2578 + 50 + 30)
-Assert.eq(StatsDB.summaryByBook("ext.weread", "42").pages, 3, "页数只数本地逐页记录")
-Assert.eq(StatsDB.summaryByBook("ext.weread", "phone_only").total_seconds, 300)
+Assert.eq(StatsDB.summaryByBook("weread", "42").total_seconds, 2578 + 50 + 30)
+Assert.eq(StatsDB.summaryByBook("weread", "42").pages, 3, "页数只数本地逐页记录")
+Assert.eq(StatsDB.summaryByBook("weread", "phone_only").total_seconds, 300)
-- 单书按日:D0 以云端 440 为准(本地 100 已含),D1 = 134 + 50 + 30
-local daily = StatsDB.dailyByBook("ext.weread", "42", 30)
+local daily = StatsDB.dailyByBook("weread", "42", 30)
Assert.len(daily, 2)
Assert.eq(daily[1].ymd, YMD1, "最近在前")
Assert.eq(daily[1].seconds, 214)
Assert.eq(daily[2].seconds, 440)
-Assert.len(StatsDB.dailyByBook("ext.weread", "42", 1), 1)
-Assert.eq(byYmd(StatsDB.dailyByBook("ext.weread", "phone_only", 30))[YMD0], 300,
+Assert.len(StatsDB.dailyByBook("weread", "42", 1), 1)
+Assert.eq(byYmd(StatsDB.dailyByBook("weread", "phone_only", 30))[YMD0], 300,
"只在其他设备读过的书也有按日时长")
-- 洞察当日书单:只有云端的书页坐标为 0
local found
-for _, row in ipairs(StatsDB.dailyBooksBySource("ext.weread")) do
+for _, row in ipairs(StatsDB.dailyBooksBySource("weread")) do
if row.stable_id == "phone_only" then found = row end
end
Assert.eq(found.ymd, YMD0)
@@ -104,17 +104,17 @@ Assert.eq(found.seconds, 300)
Assert.eq(found.max_total_pages, 0)
-- 账单:书单与书数含其他设备读过的书
-local books = StatsDB.periodBooks("ext.weread", D0, D1 + 86400, 5)
+local books = StatsDB.periodBooks("weread", D0, D1 + 86400, 5)
Assert.len(books, 2)
Assert.eq(books[1].stable_id, "42")
Assert.eq(books[1].seconds, 440 + 214)
Assert.eq(books[2].stable_id, "phone_only")
-local period = StatsDB.periodSummary("ext.weread", D0, D1 + 86400)
+local period = StatsDB.periodSummary("weread", D0, D1 + 86400)
Assert.eq(period.book_count, 2)
Assert.eq(period.pages, 3)
-- 账户日历:D1 云端 195 + 拉取后本地新读 80;D0 无云端日桶 → 本地 100
-local account = byYmd(StatsDB.dailyBySource("ext.weread"))
+local account = byYmd(StatsDB.dailyBySource("weread"))
Assert.eq(account[YMD1], 195 + 50 + 30)
Assert.eq(account[YMD0], 100)
Assert.eq(period.total_seconds, 100 + 275)
@@ -124,21 +124,21 @@ local T2 = D1 + 14 * 3600
pull(nil, { { id = "42", reading_time = 2700, wire = { readDetail = { data = {
{ readDate = D1, readTime = 500 },
} } } } }, T2)
-Assert.eq(StatsDB.summaryByBook("ext.weread", "42").total_seconds, 2700 + 50)
-local again = byYmd(StatsDB.dailyByBook("ext.weread", "42", 30))
+Assert.eq(StatsDB.summaryByBook("weread", "42").total_seconds, 2700 + 50)
+local again = byYmd(StatsDB.dailyByBook("weread", "42", 30))
Assert.eq(again[YMD1], 500 + 50)
Assert.eq(again[YMD0], 100, "旧云端日明细被整本替换掉,回落本地")
-Assert.eq(StatsDB.summaryByBook("ext.weread", "phone_only").total_seconds, 300, "其他书不受影响")
+Assert.eq(StatsDB.summaryByBook("weread", "phone_only").total_seconds, 300, "其他书不受影响")
-- 按书精确替换:书 id 互为前缀也不误删
pull(nil, { { id = "4", reading_time = 60, wire = {} } }, T2)
-Assert.eq(StatsDB.summaryByBook("ext.weread", "42").total_seconds, 2750)
-Assert.eq(StatsDB.summaryByBook("ext.weread", "4").total_seconds, 60)
+Assert.eq(StatsDB.summaryByBook("weread", "42").total_seconds, 2750)
+Assert.eq(StatsDB.summaryByBook("weread", "4").total_seconds, 60)
-- 云端累计清零:旧快照与明细一并清掉,回落本地
pull(nil, { { id = "phone_only", reading_time = 0, wire = {} } }, T2)
-Assert.eq(StatsDB.summaryByBook("ext.weread", "phone_only").total_seconds, 0)
-Assert.len(StatsDB.dailyByBook("ext.weread", "phone_only", 30), 0)
+Assert.eq(StatsDB.summaryByBook("weread", "phone_only").total_seconds, 0)
+Assert.len(StatsDB.dailyByBook("weread", "phone_only", 30), 0)
-- 旧版拉取的日桶没有 last_time:只补未上传的,已上传的不再加(宁可少算不双计)
Assert.is_true(StatsDB.add({
@@ -151,8 +151,8 @@ Assert.eq(byYmd(StatsDB.dailyBySource("legacy"))[YMD1], 620)
-- 账户级统计拉取的区间清理(只删 day/book/total)不碰单书明细
pull({ [tostring(D1)] = 195 }, nil, T2)
-Assert.eq(StatsDB.summaryByBook("ext.weread", "42").total_seconds, 2750)
-Assert.eq(byYmd(StatsDB.dailyByBook("ext.weread", "42", 30))[YMD1], 550)
+Assert.eq(StatsDB.summaryByBook("weread", "42").total_seconds, 2750)
+Assert.eq(byYmd(StatsDB.dailyByBook("weread", "42", 30))[YMD1], 550)
Base.close()
for _, suffix in ipairs({ "", "-wal", "-shm" }) do os.remove(db_path .. suffix) end
diff --git a/tests/weread/core/stats_db_merge_spec.lua b/tests/weread/core/stats_db_merge_spec.lua
index 97c7283..8842c94 100644
--- a/tests/weread/core/stats_db_merge_spec.lua
+++ b/tests/weread/core/stats_db_merge_spec.lua
@@ -39,7 +39,7 @@ local PREV = DAY - 86400
local FETCHED = DAY + 22 * 3600
local function page(start_time, duration)
- Assert.is_true(StatsDB.add({ source_id = "ext.weread", stable_id = "b1", record_type = "page",
+ Assert.is_true(StatsDB.add({ source_id = "weread", stable_id = "b1", record_type = "page",
page = 1, start_time = start_time, duration = duration, total_pages = 9, chapter_idx = 1 }, StatsDB.SYNCED))
end
@@ -47,19 +47,19 @@ end
page(DAY + 9 * 3600, 5700)
page(DAY + 14 * 3600, 7200)
page(PREV + 10 * 3600, 600)
-local result = WStats.fromWires("ext.weread", { totalReadTime = 5700 }, {},
+local result = WStats.fromWires("weread", { totalReadTime = 5700 }, {},
{ { readTimes = { [tostring(DAY)] = 5700 } } }, {}, FETCHED)
-Assert.not_nil(StatsDB.replaceSynced("ext.weread", result.replace, result.rows))
+Assert.not_nil(StatsDB.replaceSynced("weread", result.replace, result.rows))
page(FETCHED + 3600, 100)
local function day(ymd)
- for _idx, row in ipairs(StatsDB.dailyBySource("ext.weread")) do
+ for _idx, row in ipairs(StatsDB.dailyBySource("weread")) do
if row.ymd == ymd then return row.seconds end
end
end
-- 云端优先(默认):有日桶的日期 = 云端 + 拉取后新读;总时长 = 云端 total + 拉取后新读。
-Assert.eq(StatsDB.summaryBySource("ext.weread").total_seconds, 5700 + 100)
+Assert.eq(StatsDB.summaryBySource("weread").total_seconds, 5700 + 100)
Assert.eq(day("2026-10-10"), 5700 + 100)
Assert.eq(day("2026-10-09"), 600, "没有云端日桶的日期本来就用本地")
@@ -67,7 +67,7 @@ Assert.eq(day("2026-10-09"), 600, "没有云端日桶的日期本来就用本地
cfg.merge_local_stats = true
Assert.eq(day("2026-10-10"), 5700 + 7200 + 100)
Assert.eq(day("2026-10-09"), 600)
-Assert.eq(StatsDB.summaryBySource("ext.weread").total_seconds, 5700 + 7200 + 600 + 100)
+Assert.eq(StatsDB.summaryBySource("weread").total_seconds, 5700 + 7200 + 600 + 100)
-- 云端比本地多(挂机不翻页心跳照报)时仍用云端,不往下压。
cfg.merge_local_stats = true
@@ -79,7 +79,7 @@ Assert.eq(day("2026-10-10"), 20000 + 100)
-- (云端没有这一格)、22 点拉取后新读 300s(补在云端格上)。
local H = os.time({ year = 2026, month = 10, day = 10, hour = 0 })
local function cloudHour(hour, duration)
- Assert.is_true(StatsDB.add({ source_id = "ext.weread", stable_id = "__wx:hour:" .. (H + hour * 3600),
+ Assert.is_true(StatsDB.add({ source_id = "weread", stable_id = "__wx:hour:" .. (H + hour * 3600),
record_type = "hour", page = 0, start_time = H + hour * 3600, duration = duration,
total_pages = 0, last_time = FETCHED }, StatsDB.SYNCED))
end
@@ -90,12 +90,12 @@ page(H + 7 * 3600 + 1800, 300) -- 云端没有这一格(离线读)
page(FETCHED + 300, 300) -- 拉取之后才读的 22:05
cfg.merge_local_stats = false
-local by_hour = StatsDB.hourlyBySource("ext.weread")["2026-10-10"]
+local by_hour = StatsDB.hourlyBySource("weread")["2026-10-10"]
Assert.eq(by_hour[6], 600, "05 点:云端 600,本机已上报的 900 不叠加")
Assert.eq(by_hour[8], 300, "07 点:没有云端格,用本机离线 300")
Assert.eq(by_hour[23], 700, "22 点:云端 400 + 拉取后新读 300")
cfg.merge_local_stats = true
-by_hour = StatsDB.hourlyBySource("ext.weread")["2026-10-10"]
+by_hour = StatsDB.hourlyBySource("weread")["2026-10-10"]
Assert.eq(by_hour[6], 900, "合并打开:05 点取本机 900")
Assert.eq(by_hour[8], 300, "合并打开:07 点仍是本机 300")
Assert.eq(by_hour[23], 700, "合并打开:22 点云端 + 增量比本机大,不往下压")
diff --git a/tests/weread/core/stats_db_total_spec.lua b/tests/weread/core/stats_db_total_spec.lua
index d4a5c1b..10005f8 100644
--- a/tests/weread/core/stats_db_total_spec.lua
+++ b/tests/weread/core/stats_db_total_spec.lua
@@ -37,42 +37,42 @@ local FETCHED = os.time() - 3600
local ID = "book-1"
local function pull(total, fetched_at)
- local result = WStats.fromWires("ext.weread", { totalReadTime = total }, {}, {}, {}, fetched_at)
- Assert.not_nil(StatsDB.replaceSynced("ext.weread", result.replace, result.rows))
+ local result = WStats.fromWires("weread", { totalReadTime = total }, {}, {}, {}, fetched_at)
+ Assert.not_nil(StatsDB.replaceSynced("weread", result.replace, result.rows))
end
local function page(start_time, duration, synced)
- Assert.is_true(StatsDB.add({ source_id = "ext.weread", stable_id = ID, record_type = "page",
+ Assert.is_true(StatsDB.add({ source_id = "weread", stable_id = ID, record_type = "page",
page = 1, start_time = start_time, duration = duration, total_pages = 9, chapter_idx = 1 }, synced and StatsDB.SYNCED or StatsDB.PENDING))
end
-- 拉取前已上传的已含在快照里;拉取后读的(已上传或未上传)都要补上。
page(FETCHED - 600, 50, true)
pull(7200, FETCHED)
-Assert.eq(StatsDB.summaryBySource("ext.weread").total_seconds, 7200)
+Assert.eq(StatsDB.summaryBySource("weread").total_seconds, 7200)
page(FETCHED + 60, 30, false)
page(FETCHED + 120, 40, true)
-Assert.eq(StatsDB.summaryBySource("ext.weread").total_seconds, 7200 + 30 + 40, "总时长随本地新读增长")
+Assert.eq(StatsDB.summaryBySource("weread").total_seconds, 7200 + 30 + 40, "总时长随本地新读增长")
-- 先推后拉:新快照已含之前读的,替换旧 total、不累加。
Assert.is_true(Base.exec("UPDATE reading_stats SET sync_status=1 WHERE record_type='page';") ~= nil)
pull(7300, FETCHED + 600)
-Assert.eq(StatsDB.summaryBySource("ext.weread").total_seconds, 7300)
+Assert.eq(StatsDB.summaryBySource("weread").total_seconds, 7300)
-- 旧版拉取没记拉取时间:只补未上传的,宁可少算也不双计。
Assert.is_true(Base.exec("UPDATE reading_stats SET last_time=0 WHERE record_type='total';") ~= nil)
page(FETCHED + 900, 20, false)
-Assert.eq(StatsDB.summaryBySource("ext.weread").total_seconds, 7300 + 20)
+Assert.eq(StatsDB.summaryBySource("weread").total_seconds, 7300 + 20)
-- 清除列表:源含合成桶;书只留真实 stable_id,已删/未上架没有标题。
local sources = StatsDB.distinctSources()
-Assert.eq(sources[1], "ext.weread")
+Assert.eq(sources[1], "weread")
local recorded, seen = StatsDB.distinctBooks(), {}
for _idx, book in ipairs(recorded) do
Assert.is_true(book.stable_id:sub(1, 2) ~= "__", book.stable_id)
seen[book.stable_id] = book
end
-Assert.eq(seen[ID].source_id, "ext.weread")
+Assert.eq(seen[ID].source_id, "weread")
Assert.is_nil(seen[ID].title)
Base.close()
diff --git a/tests/weread/eink_spec.lua b/tests/weread/eink_spec.lua
index 6505702..a7a2f3e 100644
--- a/tests/weread/eink_spec.lua
+++ b/tests/weread/eink_spec.lua
@@ -12,7 +12,7 @@ local sha256 = require("ffi/sha2").sha256
local state = { cfg = {}, requests = {}, responder = nil }
local switches = 0
require("source.logout").replaceLibrary = function(id, commit)
- Assert.eq(id, "ext.weread")
+ Assert.eq(id, "weread")
switches = switches + 1
commit()
return true
diff --git a/tests/weread/mapper_spec.lua b/tests/weread/mapper_spec.lua
index eb88426..036f645 100644
--- a/tests/weread/mapper_spec.lua
+++ b/tests/weread/mapper_spec.lua
@@ -27,7 +27,7 @@ do
cover = "http://x/c.jpg",
progressPercent = 42,
})
- Assert.eq(b.source_id, "ext.weread")
+ Assert.eq(b.source_id, "weread")
Assert.eq(b.stable_id, "wx-1")
Assert.eq(b.title, "三体")
Assert.eq(b.percent, 42)
@@ -61,9 +61,9 @@ end
do
local b = Mapper.book({ bookId = "1", finished = 1, progress = 20, payType = 2, type = 0 })
Assert.eq(b.percent, 20)
- Assert.eq(b.meta.source["ext.weread"].pay_type, 2)
- Assert.eq(b.meta.source["ext.weread"].book_type, 0)
- Assert.eq(b.meta.source["ext.weread"].ended, true)
+ Assert.eq(b.meta.source["weread"].pay_type, 2)
+ Assert.eq(b.meta.source["weread"].book_type, 0)
+ Assert.eq(b.meta.source["weread"].ended, true)
end
do
@@ -97,9 +97,9 @@ end
do
local Settings = require("utils.settings")
- local cfg = Settings.getSource("ext.weread")
+ local cfg = Settings.getSource("weread")
cfg.category_as_group = true
- Settings.saveSource("ext.weread", cfg)
+ Settings.saveSource("weread", cfg)
local list = Mapper.shelfList({
books = {
{ bookId = "1", title = "A", category = "官方" },
@@ -115,7 +115,7 @@ do
Assert.is_true(list.data[1].category_authoritative)
Assert.is_true(list.data[2].category_authoritative, "没进组也是这次快照的分类口径")
cfg.category_as_group = false
- Settings.saveSource("ext.weread", cfg)
+ Settings.saveSource("weread", cfg)
local genre = Mapper.shelfList({
books = {
{ bookId = "1", title = "A", category = "官方" },
@@ -298,7 +298,7 @@ do
cover = "http://x/c.jpg",
progressPercent = 42,
})
- Assert.eq(b.source_id, "ext.weread")
+ Assert.eq(b.source_id, "weread")
Assert.eq(b.stable_id, "wx-1")
Assert.eq(b.title, "三体")
Assert.eq(b.percent, 42)
@@ -332,9 +332,9 @@ end
do
local b = Mapper.book({ bookId = "1", finished = 1, progress = 20, payType = 2, type = 0 })
Assert.eq(b.percent, 20)
- Assert.eq(b.meta.source["ext.weread"].pay_type, 2)
- Assert.eq(b.meta.source["ext.weread"].book_type, 0)
- Assert.eq(b.meta.source["ext.weread"].ended, true)
+ Assert.eq(b.meta.source["weread"].pay_type, 2)
+ Assert.eq(b.meta.source["weread"].book_type, 0)
+ Assert.eq(b.meta.source["weread"].ended, true)
end
do
@@ -368,9 +368,9 @@ end
do
local Settings = require("utils.settings")
- local cfg = Settings.getSource("ext.weread")
+ local cfg = Settings.getSource("weread")
cfg.category_as_group = true
- Settings.saveSource("ext.weread", cfg)
+ Settings.saveSource("weread", cfg)
local list = Mapper.shelfList({
books = {
{ bookId = "1", title = "A", category = "官方" },
@@ -386,7 +386,7 @@ do
Assert.is_true(list.data[1].category_authoritative)
Assert.is_true(list.data[2].category_authoritative, "没进组也是这次快照的分类口径")
cfg.category_as_group = false
- Settings.saveSource("ext.weread", cfg)
+ Settings.saveSource("weread", cfg)
local genre = Mapper.shelfList({
books = {
{ bookId = "1", title = "A", category = "官方" },
diff --git a/tests/weread/mp_spec.lua b/tests/weread/mp_spec.lua
index c3df129..6f50db4 100644
--- a/tests/weread/mp_spec.lua
+++ b/tests/weread/mp_spec.lua
@@ -316,9 +316,9 @@ end
do
local removed = {}
local n = Mp.dropLegacyBooks({
- stableIdsBySource = function(source) Assert.eq(source, "ext.weread"); return { "100", "MP_WXS_1", "MP_WXS_2" } end,
+ stableIdsBySource = function(source) Assert.eq(source, "weread"); return { "100", "MP_WXS_1", "MP_WXS_2" } end,
remove = function(source, id) removed[#removed + 1] = source .. ":" .. id end,
})
Assert.eq(n, 2)
- Assert.eq(table.concat(removed, ","), "ext.weread:MP_WXS_1,ext.weread:MP_WXS_2")
+ Assert.eq(table.concat(removed, ","), "weread:MP_WXS_1,weread:MP_WXS_2")
end
diff --git a/tests/weread/notes_push_spec.lua b/tests/weread/notes_push_spec.lua
index 4468ac4..741b42a 100644
--- a/tests/weread/notes_push_spec.lua
+++ b/tests/weread/notes_push_spec.lua
@@ -35,7 +35,7 @@ local function fakeClient(replies)
return client
end
-local identity = { source_id = "ext.weread", stable_id = "b1", chapter_idx = 1 }
+local identity = { source_id = "weread", stable_id = "b1", chapter_idx = 1 }
do -- 删除墓碑:先删想法再删划线,删完从注解里移除,后续无事可做即成功
local client = fakeClient({ bookmarkListAsync = { updated = {} }, myReviewsAsync = { reviews = {} } })
diff --git a/tests/weread/progress_spec.lua b/tests/weread/progress_spec.lua
index 4940ef4..952f872 100644
--- a/tests/weread/progress_spec.lua
+++ b/tests/weread/progress_spec.lua
@@ -20,7 +20,7 @@ package.preload["moonsource_weread.chapter"] = function()
end
local Position = require("moonsource_weread.progress")
local Paths = require("utils.paths")
-local identity = { source_id = "ext.weread", stable_id = "progress-coordinate-spec" }
+local identity = { source_id = "weread", stable_id = "progress-coordinate-spec" }
local chapter = { idx = 1, uid = "old", title = "章名" }
local path = Paths.bookWorkDir(identity.stable_id, identity.source_id) .. "/1.position.json"
local local_path = Paths.chapterPath(identity.stable_id, 1, identity.source_id)
@@ -93,7 +93,7 @@ do
.. '