fix: 修复手动链接搜索与直连接口未剥离 @偏移 后缀导致请求失败 - #455
Merged
Merged
Conversation
|
@wan0ge is attempting to deploy a commit to the huangxd's projects Team on Vercel. A member of the Team first needs to authorize it. |
搜索阶段取标题前剥离 @偏移 后缀:此前带 @偏移 的链接直接传入源请求(如 bilibili 返回 404)并产生脏标题,现统一用 stripLinkOffset 取洁净链接后再取标题。 直连接口 getCommentByUrl 此前完全忽略 @偏移,现与 getComment 对齐:解析 @秒数/@%百分比 偏移、用洁净链接取弹幕、取回后应用偏移;百分比偏移按弹幕最大时间缩放,逻辑与 getComment 一致。 将散落各处的 @偏移 解析统一收口到 offset-util.js 的 stripLinkOffset(消除 7 处重复内联正则),getComment / fetchMergedComments / resolveSourceAndRealId / getCommentByUrl 均复用之。 顺带修复:animeko/bahamut 此前用仅匹配 @秒数 的正则,会静默丢弃 @% 百分比偏移,现经 stripLinkOffset 统一解析后予以保留。偏移为 0(如 @0)时不再回写 @0 后缀(原会保留,属无操作偏移,无实际影响)。
合并链接(含 $$$ 分隔的多个子链接)的弹幕在 fetchMergedComments 中已按各子链接来源分别施加偏移,而 getComment 顶层又对整段合并弹幕再次施加单链接偏移,导致所有弹幕时间被叠加偏移一次(首个子链接无偏移标记时其弹幕被整体抬走)。 改为顶层单链接偏移仅在非合并链接时施加,与既有 danmuOffsetRules 守卫(dandan-api.js:2699)一致——合并链接的偏移完全由 fetchMergedComments 按来源处理。单链接偏移行为与直连接口 getCommentByUrl 不受影响。
合并链接(含 $$$ 分隔的多个子链接)此前在 resolveMergedDuration 中对各子链接时长取最大值,导致返回的 videoDuration 为单个视频的时长(如 3266s),而非合并后时间轴的实际长度(约 6463s),前端进度条与时长显示偏短。 改为:合并链接的时长取各子链接按 @偏移 平移后时间轴末端的最大值——即 max(子链接时长 + 应用的偏移)。偏移量直接复用 applyOffset 的语义(绝对与百分比模式下均将时间轴末端平移 offset 秒),确保返回的合并时长与弹幕实际落点完全一致,且不再手算偏移公式。单链接路径保持不变,正常场景行为不受影响。
wan0ge
force-pushed
the
feat-manual-search-link
branch
from
August 22, 2026 02:18
077e0c2 to
041c725
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
搜索阶段 searchAnimeBody 取标题时直接传入带 @偏移 后缀的原始链接,源对带偏移的 URL 请求失败(如 bilibili 返回 404)并产生脏标题;现取标题前剥离 @偏移 后缀。
直连接口 getCommentByUrl 此前未解析 @偏移,现与 getComment 对齐:解析 @秒数/@%百分比 偏移、取弹幕前剥离 @偏移 后缀、取回后应用偏移。
将散落各处的 @偏移 解析统一提取为 offset-util.js 的 stripLinkOffset,消除重复;animeko/bahamut 经此顺带支持 @% 百分比偏移。
https://www.bilibili.com/video/BV16P4y167Wz/ https://www.bilibili.com/video/BV1Nd4y157pE/@3197