Skip to content

统一集数 URL 归一化#2264

Merged
Predidit merged 1 commit into
Predidit:mainfrom
liangyuR:codex/pr1-url-normalize
Jun 24, 2026
Merged

统一集数 URL 归一化#2264
Predidit merged 1 commit into
Predidit:mainfrom
liangyuR:codex/pr1-url-normalize

Conversation

@liangyuR

@liangyuR liangyuR commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Cause

同一集的源站 URL 在播放、下载、历史回填等入口可能表现为相对路径、缺协议、http/https 不一致、尾斜杠不一致,或在端口、protocol-relative URL 形态上存在差异。后续以 URL 作为 pageUrl 主键匹配时,这些形态差异会导致同一集失配。

Fix

  • 新增 normalizeEpisodeUrl,统一集数源站 URL 归一化口径。
  • 在线路生产端 Plugin.querychapterRoads 写入 Road.data 前归一化 URL。
  • 在播放消费端解析视频源前复用同一归一化函数。
  • 增加 URL 归一化单元测试,覆盖相对路径、绝对 URL、http -> https、显式端口保留、protocol-relative URL、尾斜杠、空白、空输入、query 保留和幂等性。

Risk

当前归一化会把 http 统一为 https,并且归一化结果同时作为 pageUrl 身份 key 和实际请求 URL。项目既有章节页请求逻辑已经倾向将源站 URL 升级为 https,因此本 PR 暂不拆分 key URL 与请求 URL。如果回归发现存在只支持 http 的源站,需要再调整设计。

Tests

  • flutter test test/episode_url_test.dart
  • flutter analyze --no-pub --no-fatal-infos --fatal-warnings(退出码 0;仓库现有 32 条 info 级提示)
  • Windows 人工验证在线播放能进入并解析视频源
  • Windows 人工验证同一插件/番剧可触发下载解析或进入下载流程

- 新增集数源站 URL 归一化工具

- 在线路生产端和播放消费端统一 URL 口径

- 增加 URL 归一化单元测试
@liangyuR liangyuR force-pushed the codex/pr1-url-normalize branch from 6c18ea7 to b407a43 Compare June 24, 2026 16:31
@liangyuR liangyuR marked this pull request as ready for review June 24, 2026 16:33
@kilo-code-bot

kilo-code-bot Bot commented Jun 24, 2026

Copy link
Copy Markdown

Code Review Summary

Status: No Issues Found | Recommendation: Merge

The URL normalization logic is sound and well-tested. normalizeEpisodeUrl correctly handles relative/absolute resolution, http→https unification, trailing-slash stripping, empty input, port/query/fragment preservation, and is idempotent. The consumer (video_controller.dart) and producer (plugins.dart) call sites use the helper consistently. The http→https tradeoff is explicitly documented in the PR description.

Files Reviewed (4 files)
  • lib/utils/episode_url.dart
  • lib/pages/video/video_controller.dart
  • lib/plugins/plugins.dart
  • test/episode_url_test.dart

Reviewed by claude-4.8-opus-20260528 · Input: 4.1K · Output: 6.6K · Cached: 215.8K

@Predidit Predidit merged commit 65304d8 into Predidit:main Jun 24, 2026
17 checks passed
@liangyuR liangyuR deleted the codex/pr1-url-normalize branch June 25, 2026 04:25
ErBWs pushed a commit to ErBWs/Kazumi that referenced this pull request Jun 25, 2026
- 新增集数源站 URL 归一化工具

- 在线路生产端和播放消费端统一 URL 口径

- 增加 URL 归一化单元测试

(cherry picked from commit 65304d8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants