diff --git a/danmu_api/worker.js b/danmu_api/worker.js index b345ef1..d9c3da3 100644 --- a/danmu_api/worker.js +++ b/danmu_api/worker.js @@ -889,8 +889,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); @@ -1021,7 +1031,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 = {