♻️ 书源 id 去掉 ext. 前缀,沿用旧内置源数据

Co-authored-by: Copilot <[email protected]>
This commit is contained in:
GarfieldandCopilot committed 2026-11-16 14:07:45 +08:00
1 parent 1698ed8412
commit c029847ffd
10 files changed
+23 -23

No files matched your search

+1 -1
View File
@@ -3,7 +3,7 @@
--]]
-- 本源的段评可借给本地书(reader.paragraph_lender)
require("utils.extension").add("reader.paragraph_lender", { id = "ext.douban", label = require("moonsource_douban._meta").name })
require("utils.extension").add("reader.paragraph_lender", { id = "douban", label = require("moonsource_douban._meta").name })
local function lazy(module)
return setmetatable({}, { __index = function(_, key) return require(module)[key] end })
@@ -9,7 +9,7 @@
local _ = require("l10n").get("moonsource_douban")
return {
id = "ext.douban",
id = "douban",
name = _("豆瓣阅读"),
type = "chapter",
description = _("豆瓣阅读书架与在线阅读"),
@@ -16,7 +16,7 @@ local _ = require("l10n").get("moonsource_douban")
local Client = {}
local SOURCE_ID = "ext.douban"
local SOURCE_ID = "douban"
local READ_HOST = "read.douban.com"
local ACCOUNT_HOST = "accounts.arkread.com"
local READ = "https://" .. READ_HOST
@@ -16,7 +16,7 @@ local _ = require("l10n").get("moonsource_douban")
local Mapper = {}
local SOURCE_ID = "ext.douban"
local SOURCE_ID = "douban"
Mapper.TOC_VERSION = 2
Mapper.SEARCH_HASH = "sha256:92911ffc68782f44a56764094edc0068f283c29fb447277f8ed2911af6bbd0a0"
@@ -7,7 +7,7 @@
local _ = require("l10n").get("moonsource_douban")
local CookieLogin = require("source.cookie_login")
local SOURCE_ID = "ext.douban"
local SOURCE_ID = "douban"
local Setting = {}
local LOGIN_URL = "https://read.douban.com/oidc/login"
+2 -2
View File
@@ -56,7 +56,7 @@ function source:loadTocAsync(_identity, cb)
return { cancel = function() end }
end
local page, err
source:bookReviewsAsync({ source_id = "ext.douban", stable_id = "101" }, function(value, reason)
source:bookReviewsAsync({ source_id = "douban", stable_id = "101" }, function(value, reason)
page, err = value, reason
end)
Assert.is_nil(err)
@@ -65,7 +65,7 @@ Assert.matches(page.items[1].text, "Review")
Assert.is_false(page.items[1].text:find("<p>", 1, true) ~= nil)
Assert.is_nil(requests[1].opts.headers.Cookie)
Assert.eq(JSON.decode(requests[1].opts.body).variables.worksId, "101")
local identity = { source_id = "ext.douban", stable_id = "101", chapter_idx = 1 }
local identity = { source_id = "douban", stable_id = "101", chapter_idx = 1 }
source:paragraphReviewPageAsync(identity, "chapter", 0, function(value, reason) page, err = value, reason end)
Assert.is_nil(err)
Assert.len(page.items, 20)
+1 -1
View File
@@ -43,7 +43,7 @@ function source:loadTocAsync(_identity, cb)
return { cancel = function() end }
end
for _idx, method in ipairs({ "paragraphHotspotsAsync", "paragraphReviewPageAsync" }) do
local identity = { source_id = "ext.douban", stable_id = "test", chapter_idx = 1 }
local identity = { source_id = "douban", stable_id = "test", chapter_idx = 1 }
local handle
if method == "paragraphHotspotsAsync" then
handle = source:paragraphHotspotsAsync(identity, function() calls = calls + 1 end)
+2 -2
View File
@@ -51,9 +51,9 @@ Assert.is_nil(Mapper.shelfWorks(works, groups, { "1", "missing" }))
Assert.is_nil(Mapper.shelfIds({ worksIds = { "1", false } }))
local BookDB = require("book.books_db")
Assert.is_true(BookDB.upsertRemote({ source_id = "ext.douban", stable_id = "2", title = "乙", category = "旧题材" }))
Assert.is_true(BookDB.upsertRemote({ source_id = "douban", stable_id = "2", title = "乙", category = "旧题材" }))
Assert.is_true(BookDB.upsertRemote(Mapper.shelfWorks(works, groups)[2]))
Assert.is_nil(BookDB.get("ext.douban", "2").category)
Assert.is_nil(BookDB.get("douban", "2").category)
local requests, deferred, defer_works = {}, false, false
local folder_wire, folder_error = { folderIds = { 10, 20 } }, nil
+12 -12
View File
@@ -36,22 +36,22 @@ wire.data.user.readingTimeHistory[2].readingTime.duration = -1
Assert.is_nil(Mapper.readingStats(wire, "2026-10-09", now))
wire.data.user.readingTimeHistory[2].readingTime.duration = 1200
Assert.is_true(StatsDB.removeSource("ext.douban"))
Assert.is_true(StatsDB.removeSource("douban"))
Assert.is_true(StatsDB.add({
source_id = "ext.douban", stable_id = "test-book", record_type = "page",
source_id = "douban", stable_id = "test-book", record_type = "page",
start_time = now - 600, duration = 60, page = 1, total_pages = 10,
}, StatsDB.PENDING))
Assert.is_true(StatsDB.replaceSynced("ext.douban", snapshot.replace, snapshot.rows) ~= nil)
Assert.eq(StatsDB.summaryBySource("ext.douban").total_seconds, 7260)
Assert.eq(StatsDB.dailyBySource("ext.douban")[2].seconds, 1260)
Assert.eq(#StatsDB.unsyncedBySource("ext.douban", 200), 1)
Assert.is_true(StatsDB.replaceSynced("ext.douban", snapshot.replace, snapshot.rows) ~= nil)
Assert.eq(StatsDB.summaryBySource("ext.douban").total_seconds, 7260)
Assert.is_true(StatsDB.replaceSynced("douban", snapshot.replace, snapshot.rows) ~= nil)
Assert.eq(StatsDB.summaryBySource("douban").total_seconds, 7260)
Assert.eq(StatsDB.dailyBySource("douban")[2].seconds, 1260)
Assert.eq(#StatsDB.unsyncedBySource("douban", 200), 1)
Assert.is_true(StatsDB.replaceSynced("douban", snapshot.replace, snapshot.rows) ~= nil)
Assert.eq(StatsDB.summaryBySource("douban").total_seconds, 7260)
wire.data.user.readingTimeHistory[1].readingTime.duration = 0
snapshot = Mapper.readingStats(wire, "2026-10-09", now)
Assert.is_true(StatsDB.replaceSynced("ext.douban", snapshot.replace, snapshot.rows) ~= nil)
Assert.eq(#StatsDB.dailyBySource("ext.douban"), 1)
Assert.eq(StatsDB.summaryBySource("ext.douban").total_pages, 1)
Assert.is_true(StatsDB.replaceSynced("douban", snapshot.replace, snapshot.rows) ~= nil)
Assert.eq(#StatsDB.dailyBySource("douban"), 1)
Assert.eq(StatsDB.summaryBySource("douban").total_pages, 1)
local request
package.preload["utils.settings"] = function()
@@ -79,4 +79,4 @@ Assert.eq(payload.variables.userId, "42")
Assert.is_true(payload.variables.beginDate:match("^%d%d%d%d%-%d%d%-%d%d$") ~= nil)
Assert.eq(request.headers["X-CSRF-Token"], "test")
Assert.eq(payload.extensions.persistedQuery.sha256Hash, Mapper.READING_TIME_HASH)
StatsDB.removeSource("ext.douban")
StatsDB.removeSource("douban")
+1 -1
View File
@@ -37,7 +37,7 @@ package.preload["source.toc"] = function()
}
end
local source = require("moonsource_douban.source").new()
local identity = { source_id = "ext.douban", stable_id = "test" }
local identity = { source_id = "douban", stable_id = "test" }
local result
source:loadTocAsync(identity, function(toc) result = toc end)
Stubs.flush()