♻️ 书源 id 去掉 ext. 前缀,沿用旧内置源数据
Co-authored-by: Copilot <[email protected]>
This commit is contained in:
1 parent
01e572a5ee
commit
f8ad3f73a6
29 files changed
+173
-173
No files matched your search
@@ -7,7 +7,7 @@
|
||||
local _ = require("l10n").get("moonsource_weread")
|
||||
|
||||
return {
|
||||
id = "ext.weread",
|
||||
id = "weread",
|
||||
name = _("微信读书"),
|
||||
type = "chapter",
|
||||
description = _("微信读书书架与在线阅读"),
|
||||
|
||||
@@ -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"
|
||||
|
||||
--- 图片落地后再补样式表;已取消则丢弃。
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 = "<h1>" .. Text.xmlEscape(title) .. "</h1>" .. 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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {}
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 = {}
|
||||
|
||||
|
||||
@@ -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 = {}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user