♻️ 书源 id 去掉 ext. 前缀,沿用旧内置源数据
Co-authored-by: Copilot <[email protected]>
This commit is contained in:
1 parent
6379a117c2
commit
0174664163
15 files changed
+47
-47
No files matched your search
@@ -9,7 +9,7 @@
|
||||
local _ = require("l10n").get("moonsource_zhihu")
|
||||
|
||||
return {
|
||||
id = "ext.zhihu",
|
||||
id = "zhihu",
|
||||
name = _("知乎盐选"),
|
||||
type = "chapter",
|
||||
description = _("知乎盐选在线阅读"),
|
||||
|
||||
@@ -21,7 +21,7 @@ local Client = {}
|
||||
local API = "https://api.zhihu.com"
|
||||
local WEB = "https://www.zhihu.com"
|
||||
local UA = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
|
||||
local SOURCE_ID = "ext.zhihu"
|
||||
local SOURCE_ID = "zhihu"
|
||||
local CAPTCHA = "https://captcha.zhihu.com/api/v1/captcha"
|
||||
local CAPTCHA_APP = "lsxNQs26Wva2"
|
||||
|
||||
@@ -34,7 +34,7 @@ local CAPTCHA_APP = "lsxNQs26Wva2"
|
||||
|
||||
---@return string|nil
|
||||
function Client.cookie()
|
||||
local cookie = require("utils.settings").getSource("ext.zhihu").cookie
|
||||
local cookie = require("utils.settings").getSource("zhihu").cookie
|
||||
return type(cookie) == "string" and cookie ~= "" and cookie or nil
|
||||
end
|
||||
|
||||
@@ -66,7 +66,7 @@ local function get(url, headers, cb)
|
||||
local cookie = Client.cookie()
|
||||
return Request.get(url, opts(withCookie(headers)), function(body, err, res)
|
||||
if res and tonumber(res.code) == 401 and cookie and cookie == Client.cookie() then
|
||||
cb(nil, require("source.auth").expire("ext.zhihu", _("知乎登录已失效,请重新登录")))
|
||||
cb(nil, require("source.auth").expire("zhihu", _("知乎登录已失效,请重新登录")))
|
||||
return
|
||||
end
|
||||
cb(body, err)
|
||||
@@ -377,7 +377,7 @@ function Client.putProgressAsync(section_id, fraction, cb)
|
||||
["Content-Type"] = "application/json", Referer = WEB .. "/",
|
||||
})), function(raw, err, res)
|
||||
if res and tonumber(res.code) == 401 and cookie == Client.cookie() then
|
||||
cb(nil, require("source.auth").expire("ext.zhihu", _("知乎登录已失效,请重新登录")))
|
||||
cb(nil, require("source.auth").expire("zhihu", _("知乎登录已失效,请重新登录")))
|
||||
return
|
||||
end
|
||||
local wire = decode(raw)
|
||||
|
||||
@@ -12,7 +12,7 @@ local Text = require("utils.text")
|
||||
local Mapper = {}
|
||||
|
||||
Mapper.TOC_VERSION = 1
|
||||
local SOURCE_ID = "ext.zhihu"
|
||||
local SOURCE_ID = "zhihu"
|
||||
|
||||
---@param value any
|
||||
---@return string
|
||||
|
||||
@@ -15,7 +15,7 @@ end
|
||||
|
||||
---@type CookieLoginSpec
|
||||
local SPEC = {
|
||||
id = "ext.zhihu",
|
||||
id = "zhihu",
|
||||
title = _("知乎账号"),
|
||||
cookie_title = _("知乎登录 Cookie"),
|
||||
cookie_hint = _("按键盘 F12,点「网络」,刷新网页,复制请求标头里的整段 Cookie"),
|
||||
@@ -44,7 +44,7 @@ Setting.browser = {
|
||||
local function showLogin()
|
||||
require("ui/network/manager"):runWhenConnected(function()
|
||||
require("moonsource_zhihu.qrlogin"):new(function()
|
||||
require("source.auth").ok("ext.zhihu")
|
||||
require("source.auth").ok("zhihu")
|
||||
require("source.registry").reload()
|
||||
require("ui.themes.widgets.toast"):new{ text = _("登录成功"), timeout = 2 }:show()
|
||||
end):start()
|
||||
@@ -59,7 +59,7 @@ function Setting.rows(plugin)
|
||||
}),
|
||||
CookieLogin.browserRow(),
|
||||
CookieLogin.pasteRow(SPEC),
|
||||
require("source.review_setting").row("ext.zhihu", plugin),
|
||||
require("source.review_setting").row("zhihu", plugin),
|
||||
}
|
||||
if loggedIn() then rows[#rows + 1] = CookieLogin.logoutRow(SPEC) end
|
||||
return rows
|
||||
|
||||
@@ -149,7 +149,7 @@ local function fetcher(open)
|
||||
return function(identity, chapter, done)
|
||||
local function finish(html, err)
|
||||
if html then
|
||||
if chapter.vip then Toc.markPaid("ext.zhihu", identity.stable_id, chapter.uid, true) end
|
||||
if chapter.vip then Toc.markPaid("zhihu", identity.stable_id, chapter.uid, true) end
|
||||
done({ title = chapter.title, html = require("moonsource_zhihu.content").prepare(html) })
|
||||
return
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user