♻️ 书源 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 ff11bb481a
commit 35383a2451
11 files changed
+18 -18

No files matched your search

@@ -9,7 +9,7 @@
local _ = require("l10n").get("moonsource_ireader") local _ = require("l10n").get("moonsource_ireader")
return { return {
id = "ext.ireader", id = "ireader",
name = _("掌阅书城"), name = _("掌阅书城"),
type = "chapter", type = "chapter",
description = _("掌阅书架与在线阅读"), description = _("掌阅书架与在线阅读"),
@@ -18,7 +18,7 @@ local _ = require("l10n").get("moonsource_ireader")
local Client = {} local Client = {}
local SOURCE_ID = "ext.ireader" local SOURCE_ID = "ireader"
local API = "https://api-pc.zhangyue.com" local API = "https://api-pc.zhangyue.com"
local WEB = "https://pc.ireader.com" local WEB = "https://pc.ireader.com"
local STORE = "https://m.zhangyue.com" local STORE = "https://m.zhangyue.com"
@@ -8,7 +8,7 @@ local Text = require("utils.text")
local Mapper = {} local Mapper = {}
local SOURCE_ID = "ext.ireader" local SOURCE_ID = "ireader"
-- 官网 FZYouH_509R_V1.10.ttf 的二十个私用字形;两个连续区间,中间 A–F 没有字形。 -- 官网 FZYouH_509R_V1.10.ttf 的二十个私用字形;两个连续区间,中间 A–F 没有字形。
local CONTENT_CHARS = {} local CONTENT_CHARS = {}
@@ -7,7 +7,7 @@
local _ = require("l10n").get("moonsource_ireader") local _ = require("l10n").get("moonsource_ireader")
local CookieLogin = require("source.cookie_login") local CookieLogin = require("source.cookie_login")
local SOURCE_ID = "ext.ireader" local SOURCE_ID = "ireader"
local Setting = {} local Setting = {}
local LOGIN_URL = "https://pc.ireader.com/login" local LOGIN_URL = "https://pc.ireader.com/login"
@@ -52,7 +52,7 @@ function Remote:shelfSyncAsync(cb) return Client.shelfAsync(cb) end
---@param stable_id string ---@param stable_id string
---@param cb fun(ok: boolean|nil, err: string|nil) ---@param cb fun(ok: boolean|nil, err: string|nil)
function Remote:addToShelfAsync(stable_id, cb) function Remote:addToShelfAsync(stable_id, cb)
local row = require("book.books_db").get("ext.ireader", stable_id) local row = require("book.books_db").get("ireader", stable_id)
return Client.addAsync(stable_id, row and row.title or stable_id, cb) return Client.addAsync(stable_id, row and row.title or stable_id, cb)
end end
@@ -213,7 +213,7 @@ local function fetcher(open)
if cancelled then return end if cancelled then return end
if html then if html then
active = Assets.localizeAsync(html, active = Assets.localizeAsync(html,
Paths.bookWorkDir(identity.stable_id, "ext.ireader") .. "/images", Paths.bookWorkDir(identity.stable_id, "ireader") .. "/images",
function(url, cb) function(url, cb)
return require("http.request").get(url, { return require("http.request").get(url, {
accept = "image/*", accept = "image/*",
+5 -5
View File
@@ -64,16 +64,16 @@ Client.get("/old-response", nil, done)
pending = requests[#requests] pending = requests[#requests]
cfg.zysid = "renewed" cfg.zysid = "renewed"
pending.cb(JSON.encode({ code = 600001 })) pending.cb(JSON.encode({ code = 600001 }))
Assert.is_true(not Auth.expired("ext.ireader")) Assert.is_true(not Auth.expired("ireader"))
Assert.is_nil(result) Assert.is_nil(result)
Client.get("/expired", nil, done) Client.get("/expired", nil, done)
requests[#requests].cb(JSON.encode({ code = 600001 })) requests[#requests].cb(JSON.encode({ code = 600001 }))
Assert.is_true(Auth.expired("ext.ireader")) Assert.is_true(Auth.expired("ireader"))
Client.get("/stale-success", nil, done) Client.get("/stale-success", nil, done)
pending = requests[#requests] pending = requests[#requests]
cfg.zysid = "latest" cfg.zysid = "latest"
pending.cb(JSON.encode({ code = 0, body = {} })) pending.cb(JSON.encode({ code = 0, body = {} }))
Assert.is_true(Auth.expired("ext.ireader"), "旧会话成功不能清新会话的失效标记") Assert.is_true(Auth.expired("ireader"), "旧会话成功不能清新会话的失效标记")
mode = "sync-toc" mode = "sync-toc"
handle = Client.chaptersAsync("42", done) handle = Client.chaptersAsync("42", done)
@@ -101,12 +101,12 @@ Client.shelfAsync(done)
requests[#requests].cb(JSON.encode({ code = 0, body = {} })) requests[#requests].cb(JSON.encode({ code = 0, body = {} }))
Assert.is_nil(result) Assert.is_nil(result)
Assert.eq(reason, "响应无效") Assert.eq(reason, "响应无效")
Auth.expire("ext.ireader", "测试失效状态") Auth.expire("ireader", "测试失效状态")
Client.checkSessionAsync({ usr = "candidate", zysid = "candidate-session" }, done) Client.checkSessionAsync({ usr = "candidate", zysid = "candidate-session" }, done)
Assert.is_true(requests[#requests].url:find("usr=candidate", 1, true) ~= nil) Assert.is_true(requests[#requests].url:find("usr=candidate", 1, true) ~= nil)
requests[#requests].cb(JSON.encode({ code = 0, body = { data = {} } })) requests[#requests].cb(JSON.encode({ code = 0, body = { data = {} } }))
Assert.is_true(result) Assert.is_true(result)
Assert.is_true(Auth.expired("ext.ireader"), "候选登录校验不改变现有账号的认证状态") Assert.is_true(Auth.expired("ireader"), "候选登录校验不改变现有账号的认证状态")
local catalog_opts = { parent = "10", category = "11", order = "score", status = "0" } local catalog_opts = { parent = "10", category = "11", order = "score", status = "0" }
Client.catalogAsync(catalog_opts, 2, done) Client.catalogAsync(catalog_opts, 2, done)
+2 -2
View File
@@ -58,8 +58,8 @@ package.loaded["moonsource_ireader.client"] = {
end end
if mode == "failed" and index == 2 then cb(nil, "network failed"); return end if mode == "failed" and index == 2 then cb(nil, "network failed"); return end
cb({ cb({
{ source_id = "ext.ireader", stable_id = tostring(index), title = "书" }, { source_id = "ireader", stable_id = tostring(index), title = "书" },
{ source_id = "ext.ireader", stable_id = "duplicate", title = "重复" }, { source_id = "ireader", stable_id = "duplicate", title = "重复" },
}, nil, index < 3) }, nil, index < 3)
return { cancel = function() request.cancelled = true end } return { cancel = function() request.cancelled = true end }
end, end,
+1 -1
View File
@@ -35,7 +35,7 @@ local shelf = Mapper.shelf({
}) })
Assert.eq(#shelf, 1) Assert.eq(#shelf, 1)
Assert.eq(shelf[1].stable_id, "1") Assert.eq(shelf[1].stable_id, "1")
Assert.eq(shelf[1].source_id, "ext.ireader") Assert.eq(shelf[1].source_id, "ireader")
local found = Mapper.search([[ local found = Mapper.search([[
<div data-id="42" data-src="https://img/a.jpg"><span class="name">三体</span> <div data-id="42" data-src="https://img/a.jpg"><span class="name">三体</span>
+2 -2
View File
@@ -44,7 +44,7 @@ package.loaded["http.request"] = {
} }
local captured_ops, captured_reuse local captured_ops, captured_reuse
local identity = { source_id = "ext.ireader", stable_id = "content-fixture" } local identity = { source_id = "ireader", stable_id = "content-fixture" }
local chapter = { idx = 1, uid = "1", title = "正文" } local chapter = { idx = 1, uid = "1", title = "正文" }
package.loaded["source.chapter"] = { package.loaded["source.chapter"] = {
openAsync = function(_source, ref, _book, _opts, ops, cb) openAsync = function(_source, ref, _book, _opts, ops, cb)
@@ -93,7 +93,7 @@ Assert.is_false(Text.hasRemoteImageSrc(payload.html))
Assert.eq(#requests, 2, "同一图片只下载一次") Assert.eq(#requests, 2, "同一图片只下载一次")
local href = payload.html:match('src="([^"]+)"') local href = payload.html:match('src="([^"]+)"')
Assert.matches(href, "^images/[a-f0-9]+%.png$") Assert.matches(href, "^images/[a-f0-9]+%.png$")
Assert.eq(Fs.read(require("utils.paths").bookWorkDir(identity.stable_id, "ext.ireader") .. "/" .. href), png) Assert.eq(Fs.read(require("utils.paths").bookWorkDir(identity.stable_id, "ireader") .. "/" .. href), png)
reset() reset()
local handle = open() local handle = open()
+1 -1
View File
@@ -33,7 +33,7 @@ package.loaded["moonsource_ireader.client"] = {
local source = require("moonsource_ireader.source").new() local source = require("moonsource_ireader.source").new()
local result, reason, calls = nil, nil, 0 local result, reason, calls = nil, nil, 0
local function done(value, err) result, reason, calls = value, err, calls + 1 end local function done(value, err) result, reason, calls = value, err, calls + 1 end
local identity = { source_id = "ext.ireader", stable_id = "test", chapter_idx = 2 } local identity = { source_id = "ireader", stable_id = "test", chapter_idx = 2 }
source:loadTocAsync(identity, done) source:loadTocAsync(identity, done)
require("support.stubs").flush() require("support.stubs").flush()
Assert.eq(result, toc, "离线不强制刷新旧目录") Assert.eq(result, toc, "离线不强制刷新旧目录")
+1 -1
View File
@@ -40,7 +40,7 @@ local source = require("moonsource_ireader.source").new()
---@type IReaderReviewPage|nil ---@type IReaderReviewPage|nil
local result local result
local reason, calls = nil, 0 local reason, calls = nil, 0
local identity = { source_id = "ext.ireader", stable_id = "42" } local identity = { source_id = "ireader", stable_id = "42" }
local function done(page, err) result, reason, calls = page, err, calls + 1 end local function done(page, err) result, reason, calls = page, err, calls + 1 end
source:bookReviewsAsync(identity, done) source:bookReviewsAsync(identity, done)
local request = requests[#requests] local request = requests[#requests]