♻️ 书源 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 bea9eee670
commit 9e45e29d83
9 files changed
+21 -21

No files matched your search

@@ -11,7 +11,7 @@
local _ = require("l10n").get("moonsource_netease")
return {
id = "ext.netease",
id = "netease",
name = _("网易云阅读"),
type = "chapter",
description = _("网易云阅读在线阅读"),
@@ -76,10 +76,10 @@ function Login:confirm(cb)
return
end
local settings = require("utils.settings")
local cfg = settings.getSource("ext.netease")
local cfg = settings.getSource("netease")
cfg.cookie, cfg.logged_in, cfg.csrf = self:cookie(), true, nil
settings.saveSource("ext.netease")
require("source.auth").ok("ext.netease")
settings.saveSource("netease")
require("source.auth").ok("netease")
cb(true)
end)
end
@@ -15,7 +15,7 @@ local Client = {}
local ORIGIN = "https://yuedu.163.com"
local SHELF_ORIGIN = "https://guofeng.yuedu.163.com"
local PUBLIC = "https://yuedu.3g.163.com"
local SOURCE_ID = "ext.netease"
local SOURCE_ID = "netease"
function Client.loggedIn()
local cfg = require("utils.settings").getSource(SOURCE_ID)
@@ -17,7 +17,7 @@ local _ = require("l10n").get("moonsource_netease")
local Mapper = {}
Mapper.TOC_VERSION = 2
local SOURCE_ID = "ext.netease"
local SOURCE_ID = "netease"
function Mapper.authorized(html)
return type(html) == "string" and html:find("<title[^>]*>个人资料[^<]*</title>") ~= nil
@@ -7,7 +7,7 @@
local _ = require("l10n").get("moonsource_netease")
local CookieLogin = require("source.cookie_login")
local SOURCE_ID = "ext.netease"
local SOURCE_ID = "netease"
local Setting = {}
local LOGIN_URL = "https://yuedu.163.com/loginForm.do?targetUrl=https%3A%2F%2Fyuedu.163.com%2Fmyinfor.do"
@@ -164,7 +164,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.netease", identity.stable_id, chapter.uid, true) end
if chapter.vip then Toc.markPaid("netease", identity.stable_id, chapter.uid, true) end
done({ title = chapter.title, html = html })
return
end
+2 -2
View File
@@ -25,14 +25,14 @@ package.loaded["source.chapter"] = {
}
package.loaded["source.toc"] = {
markPaid = function(id, stable_id, uid, value)
Assert.eq(id, "ext.netease")
Assert.eq(id, "netease")
Assert.eq(stable_id, "fixture")
Assert.eq(uid, "c1")
paid = value
end,
}
local source = require("moonsource_netease.source").new()
local identity = { source_id = "ext.netease", stable_id = "fixture" }
local identity = { source_id = "netease", stable_id = "fixture" }
local chapter = { idx = 1, uid = "c1", title = "第一章", vip = true }
source:openBookAsync(identity, { chapter_idx = 1 }, function() end)
local result, failure
+6 -6
View File
@@ -121,7 +121,7 @@ Client:removeFromShelfAsync("book_4", function(value, reason) result, err = valu
Assert.is_nil(result)
Assert.eq(err, "网易云阅读登录已失效")
Assert.is_false(Client.loggedIn())
require("source.auth").ok("ext.netease")
require("source.auth").ok("netease")
local fields = Mapper.readlog("book_4", toc, 3, 0.25, 1000)
Assert.eq(fields.articleUuid, "c2")
@@ -149,15 +149,15 @@ Assert.is_nil(result, "匿名接口也回 1,登录过期不能算同步成功"
Assert.not_nil(err)
Assert.eq(#requests, before + 1, "失效会话不发进度写请求")
Assert.is_false(Client.loggedIn())
Assert.is_true(require("source.auth").expired("ext.netease"))
require("source.auth").ok("ext.netease")
Assert.is_true(require("source.auth").expired("netease"))
require("source.auth").ok("netease")
response_meta = { code = 302, location = "https://yuedu.163.com/loginForm.do?targetUrl=myinfor.do" }
failure = "HTTP 302"
Client.putProgressAsync("book_4", toc, 3, 0, function(value, reason) result, err = value, reason end)
Assert.is_nil(result)
Assert.eq(err, "网易云阅读登录已失效")
Assert.is_false(Client.loggedIn(), "HTTP 层把 302 作为错误时仍要识别真正的登录重定向")
require("source.auth").ok("ext.netease")
require("source.auth").ok("netease")
response_meta = nil
failure = "network down"
Client.putProgressAsync("book_4", toc, 3, 0, function(value, reason) result, err = value, reason end)
@@ -200,14 +200,14 @@ request_api.get = get
local stored_toc
package.loaded["source.toc"] = {
put = function(id, stable_id, chapters)
Assert.eq(id, "ext.netease")
Assert.eq(id, "netease")
Assert.eq(stable_id, "book_4")
stored_toc = chapters
return true
end,
}
local source = require("moonsource_netease.source").new()
local identity = { source_id = "ext.netease", stable_id = "book_4" }
local identity = { source_id = "netease", stable_id = "book_4" }
response = JSON.encode(info)
source:getProgressAsync(identity, function(value, reason) result, err = value, reason end)
Assert.eq(result.chapter_idx, 3)
+5 -5
View File
@@ -26,7 +26,7 @@ local function page(content, next_page)
end
local books, next_page, err = Mapper.shelfPage(page(row("first_4", "甲 & 乙"), 2), 1)
Assert.eq(books[1].source_id, "ext.netease")
Assert.eq(books[1].source_id, "netease")
Assert.eq(books[1].stable_id, "first_4")
Assert.eq(books[1].title, "甲 & 乙")
Assert.eq(books[1].authors, "作者甲")
@@ -87,7 +87,7 @@ package.loaded["book.books_db"] = {
pendingDeleteIds = function() return deleted end,
pendingShelfAddIds = function() return added end,
remove = function(id, stable_id)
Assert.eq(id, "ext.netease")
Assert.eq(id, "netease")
Assert.eq(stable_id, "deleted_4")
deleted = {}
return true
@@ -120,7 +120,7 @@ Assert.len(posts, 2, "拉完书架后推本地独有成员")
Assert.matches(posts[2].body, "id=added_4")
posts[2].cb(JSON.encode({ resultCode = 0 }))
pending[#pending].cb(page(row("first_4", "第一本") .. row("added_4", "新增")))
Assert.eq(reconciled.id, "ext.netease")
Assert.eq(reconciled.id, "netease")
Assert.is_true(reconciled.force)
Assert.eq(result.pulled, 2)
Assert.eq(result.pushed, 2)
@@ -162,14 +162,14 @@ Assert.len(added, 1)
package.loaded["ui/network/manager"] = { isConnected = function() return false end }
package.loaded["book.store"] = {
markDeleted = function(id, stable_id)
Assert.eq(id, "ext.netease")
Assert.eq(id, "netease")
Assert.eq(stable_id, "deleted_4")
deleted = { stable_id }
return true
end,
}
before = #posts
source:deleteBookAsync({ source_id = "ext.netease", stable_id = "deleted_4" }, done)
source:deleteBookAsync({ source_id = "netease", stable_id = "deleted_4" }, done)
require("support.stubs").flush()
Assert.is_true(result)
Assert.len(deleted, 1, "离线删除立即隐藏,墓碑等联网后再推")