From 7a6751ad913e0dcfe78fe2d786ae66785c34c5bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B8=B8=E8=B6=85=E7=BE=A4?= <920480979@qq.com> Date: Fri, 19 Sep 2025 16:59:32 +0800 Subject: [PATCH] =?UTF-8?q?fix:=201.=E4=BF=AE=E5=A4=8D=E7=88=B1=E5=A5=87?= =?UTF-8?q?=E8=89=BA=E8=8E=B7=E5=8F=96=E5=BC=B9=E5=B9=95=E4=B8=8D=E5=85=A8?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=982.=E4=BF=AE=E5=A4=8D=E8=85=BE?= =?UTF-8?q?=E8=AE=AF=E8=A7=86=E9=A2=91=E8=8E=B7=E5=8F=96=E4=B8=8D=E5=88=B0?= =?UTF-8?q?=E5=BD=A9=E8=89=B2=E5=BC=B9=E5=B9=95=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- danmu_api/worker.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/danmu_api/worker.js b/danmu_api/worker.js index 7ac6785..0c242e4 100644 --- a/danmu_api/worker.js +++ b/danmu_api/worker.js @@ -783,8 +783,18 @@ async function fetchTencentVideo(inputUrl) { content: "", }; content.timepoint = item.time_offset / 1000; - if (item.content_style?.color) { - log("log", "弹幕颜色:", JSON.stringify(item.content_style.color)); + if (item.content_style && item.content_style !== "") { + try { + const content_style = JSON.parse(item.content_style); + // 优先使用渐变色的第一个颜色,否则使用基础色 + if (content_style.gradient_colors && content_style.gradient_colors.length > 0) { + content.color = parseInt(content_style.gradient_colors[0].replace("#", ""), 16); + } else if (content_style.color && content_style.color !== "ffffff") { + content.color = parseInt(content_style.color.replace("#", ""), 16); + } + } catch (e) { + // JSON 解析失败,使用默认白色 + } } content.content = item.content; contents.push(content); @@ -915,7 +925,7 @@ async function fetchIqiyi(inputUrl) { const danmaku = extract(xml, "content"); const showTime = extract(xml, "showTime"); const color = extract(xml, "color"); - const step = Math.ceil(danmaku.length * datas.length / 10000); + const step = 1; for (let i = 0; i < danmaku.length; i += step) { const content = {