✨ 迁移到现行 Web 协议:签名请求、浏览器登录与分类书城
GetImageIndex / ImageToken 等接口走 ultra_sign 签名并解 bytesData; 登录改为浏览器授权或完整 Cookie,校验通过才保存。
This commit is contained in:
1 parent
430962a5d0
commit
455891353c
8 files changed
+1012
-143
No files matched your search
@@ -11,41 +11,60 @@ end
|
||||
-- Book 映射
|
||||
-- ============================================================
|
||||
|
||||
function Mapper.book(info)
|
||||
if not info then return nil end
|
||||
local cover = info.vcover or info.horizontal_cover or info.cover or ""
|
||||
local author = info.author
|
||||
local author_str = ""
|
||||
if author then
|
||||
if type(author) == "string" then
|
||||
author_str = author
|
||||
elseif type(author) == "table" then
|
||||
if author.name then author_str = author.name end
|
||||
local function authorOf(info)
|
||||
local author = info.author_name or info.author
|
||||
if type(author) == "string" and author ~= "" then return author end
|
||||
if type(author) ~= "table" then return "未知作者" end
|
||||
if type(author.name) == "string" and author.name ~= "" then return author.name end
|
||||
local names = {}
|
||||
for i = 1, #author do
|
||||
local item = author[i]
|
||||
if type(item) == "string" and item ~= "" then
|
||||
names[#names + 1] = item
|
||||
elseif type(item) == "table" and type(item.name) == "string" and item.name ~= "" then
|
||||
names[#names + 1] = item.name
|
||||
end
|
||||
end
|
||||
if author_str == "" then author_str = "未知作者" end
|
||||
if #names == 0 then return "未知作者" end
|
||||
return table.concat(names, " / ")
|
||||
end
|
||||
|
||||
local function plainTitle(info)
|
||||
local title = info.org_title or info.title or ""
|
||||
return tostring(title):gsub("<.->", "")
|
||||
end
|
||||
|
||||
local Mapper = {}
|
||||
|
||||
function Mapper.book(info)
|
||||
if not info then return nil end
|
||||
local comic_id = info.comic_id or info.season_id or info.id
|
||||
if comic_id == nil or comic_id == "" then return nil end
|
||||
local cover = info.vertical_cover or info.vcover or info.horizontal_cover or info.square_cover or info.cover or ""
|
||||
|
||||
local styles = info.styles
|
||||
local category = ""
|
||||
if styles and type(styles) == "table" and #styles > 0 then
|
||||
if styles and type(styles) == "table" and #styles > 0 and type(styles[1]) == "string" then
|
||||
category = table.concat(styles, " · ")
|
||||
end
|
||||
|
||||
local status_str = _("连载")
|
||||
if info.status == 2 then status_str = _("完结") end
|
||||
if info.is_finish == 1 or info.is_finish == true or info.status == 2 then
|
||||
status_str = _("完结")
|
||||
end
|
||||
|
||||
return {
|
||||
source_id = SOURCE_ID,
|
||||
stable_id = tostring(info.comic_id),
|
||||
title = clean(info.title),
|
||||
authors = author_str,
|
||||
stable_id = tostring(comic_id),
|
||||
title = clean(plainTitle(info)),
|
||||
authors = authorOf(info),
|
||||
cover = cover,
|
||||
intro = clean(info.desc),
|
||||
intro = clean(info.desc ~= "" and info.desc or info.evaluate),
|
||||
category = category,
|
||||
meta = {
|
||||
status = status_str,
|
||||
fans = info.fans or "",
|
||||
total_eps = info.ep_count or info.ord_count or 0,
|
||||
total_eps = info.ep_count or info.total or info.ord_count or 0,
|
||||
},
|
||||
}
|
||||
end
|
||||
@@ -67,7 +86,7 @@ function Mapper.chapters(comic)
|
||||
idx = i,
|
||||
uid = tostring(ep.id),
|
||||
title = clean(ep.title or ep.short_title or ("第" .. i .. "话")),
|
||||
vip = ep.pay_type == 1 or (ep.is_pay == true and true) or false,
|
||||
vip = ep.is_locked == true,
|
||||
}
|
||||
end
|
||||
return chapters
|
||||
@@ -103,9 +122,81 @@ end
|
||||
-- Search 映射
|
||||
-- ============================================================
|
||||
|
||||
function Mapper.rows(wire)
|
||||
if type(wire) ~= "table" then return nil end
|
||||
if wire[1] ~= nil or next(wire) == nil then return wire end
|
||||
if type(wire.list) == "table" then return wire.list end
|
||||
local data = wire.data
|
||||
if type(data) ~= "table" then return nil end
|
||||
if type(data.list) == "table" then return data.list end
|
||||
if data[1] ~= nil or next(data) == nil then return data end
|
||||
return nil
|
||||
end
|
||||
|
||||
local function choices(list)
|
||||
if type(list) ~= "table" then return nil end
|
||||
local out = {}
|
||||
for _idx, item in ipairs(list) do
|
||||
local id = type(item) == "table" and tonumber(item.id)
|
||||
local name = type(item) == "table" and item.name
|
||||
if not id or id ~= math.floor(id) or type(name) ~= "string" or name == "" then return nil end
|
||||
out[#out + 1] = { id = id, name = name }
|
||||
end
|
||||
return #out > 0 and out or nil
|
||||
end
|
||||
|
||||
function Mapper.labels(wire)
|
||||
local data = type(wire) == "table" and wire.data or nil
|
||||
if type(data) ~= "table" then return nil end
|
||||
local styles, orders = choices(data.styles), choices(data.orders)
|
||||
if not styles or not orders then return nil end
|
||||
return { styles = styles, orders = orders }
|
||||
end
|
||||
|
||||
function Mapper.storeChoice(node, labels)
|
||||
local order, style = tostring(node or ""):match("^(-?%d+):(-?%d+)$")
|
||||
order, style = tonumber(order), tonumber(style)
|
||||
local function has(list, id)
|
||||
for _idx, item in ipairs(list) do
|
||||
if item.id == id then return true end
|
||||
end
|
||||
end
|
||||
if not has(labels.orders, order) then order = labels.orders[1].id end
|
||||
if style ~= -1 and not has(labels.styles, style) then style = -1 end
|
||||
return order, style
|
||||
end
|
||||
|
||||
function Mapper.storeGroups(labels, order, style)
|
||||
local Browse = require("source.browse")
|
||||
local node = order .. ":" .. style
|
||||
local orders, styles = {}, { { id = order .. ":-1", title = _("全部") } }
|
||||
for _idx, item in ipairs(labels.orders) do
|
||||
orders[#orders + 1] = { id = item.id .. ":" .. style, title = item.name }
|
||||
end
|
||||
for _idx, item in ipairs(labels.styles) do
|
||||
styles[#styles + 1] = { id = order .. ":" .. item.id, title = item.name }
|
||||
end
|
||||
local sort_group = Browse.group(orders, node)
|
||||
local style_group = Browse.group(styles, node)
|
||||
sort_group.title = _("排序")
|
||||
style_group.title = _("题材")
|
||||
return { sort_group, style_group }
|
||||
end
|
||||
|
||||
function Mapper.books(wire)
|
||||
local rows = Mapper.rows(wire)
|
||||
if not rows then return nil end
|
||||
local books = {}
|
||||
for i = 1, #rows do
|
||||
local book = Mapper.book(rows[i])
|
||||
if book then books[#books + 1] = book end
|
||||
end
|
||||
if #rows > 0 and #books == 0 then return nil end
|
||||
return books
|
||||
end
|
||||
|
||||
function Mapper.searchResults(wire)
|
||||
if not wire then return {} end
|
||||
local items = wire.list or {}
|
||||
local items = Mapper.rows(wire) or {}
|
||||
local books = {}
|
||||
for i = 1, #items do
|
||||
local book = Mapper.book(items[i])
|
||||
@@ -119,8 +210,7 @@ end
|
||||
-- ============================================================
|
||||
|
||||
function Mapper.favoriteItems(wire)
|
||||
if not wire then return {} end
|
||||
return wire.list or {}
|
||||
return Mapper.rows(wire)
|
||||
end
|
||||
|
||||
-- ============================================================
|
||||
@@ -128,10 +218,10 @@ end
|
||||
-- ============================================================
|
||||
|
||||
function Mapper.historyItem(wire, comic_id)
|
||||
if not wire then return nil end
|
||||
local list = wire.list or {}
|
||||
local list = Mapper.rows(wire)
|
||||
if not list then return nil end
|
||||
for _, item in ipairs(list) do
|
||||
if tostring(item.comic_id) == tostring(comic_id) then
|
||||
if tostring(item.comic_id or item.season_id) == tostring(comic_id) then
|
||||
return item
|
||||
end
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user