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