forked from moon-source/moonsource-fanqie
✨ 初始提交:月读第三方书源插件集合
每个书源一个独立插件目录,含微信读书公众号订阅、书架导入等完整功能。 Co-authored-by: Copilot <[email protected]>
This commit is contained in:
commit
9190db9019
38 files changed
+5783
No files matched your search
@@ -0,0 +1,50 @@
|
||||
--[[--
|
||||
番茄源配置:落在 utils.settings.getSource("ext.fanqie")。
|
||||
|
||||
@module koplugin.book.moonsource_fanqie.settings
|
||||
--]]
|
||||
|
||||
local SOURCE_ID = "ext.fanqie"
|
||||
|
||||
---@class FanqieSettings
|
||||
---@field cfg table
|
||||
---@field get fun(self: FanqieSettings, key: string, default: any): any
|
||||
---@field set fun(self: FanqieSettings, key: string, value: any)
|
||||
---@field flush fun(self: FanqieSettings)
|
||||
---@field is_cookie_configured fun(self: FanqieSettings): boolean
|
||||
|
||||
local Settings = {}
|
||||
Settings.__index = Settings
|
||||
|
||||
---@return FanqieSettings
|
||||
function Settings:new()
|
||||
local cfg = require("utils.settings").getSource(SOURCE_ID)
|
||||
return setmetatable({ cfg = cfg }, self)
|
||||
end
|
||||
|
||||
---@param key string
|
||||
function Settings:get(key, default)
|
||||
local value = self.cfg[key]
|
||||
if value == nil then return default end
|
||||
return value
|
||||
end
|
||||
|
||||
---@param key string
|
||||
function Settings:set(key, value)
|
||||
self.cfg[key] = value
|
||||
end
|
||||
|
||||
function Settings:flush()
|
||||
require("utils.settings").saveSource(SOURCE_ID, self.cfg)
|
||||
end
|
||||
|
||||
---@return boolean
|
||||
function Settings:is_cookie_configured()
|
||||
-- 书架接口要 HttpOnly 会话 cookie;只有 novel_web_id 等可见 cookie 会返回 101119。
|
||||
local cookies = self.cfg.cookies
|
||||
return type(cookies) == "table"
|
||||
and type(cookies.sessionid) == "string"
|
||||
and cookies.sessionid ~= ""
|
||||
end
|
||||
|
||||
return Settings
|
||||
Reference in new issue
Block a user