Skip to content

hotfix(v2.0.3): 接通媒体反代并修复下载崩溃,恢复媒体发送#80

Merged
FlanChanXwO merged 1 commit into
masterfrom
hotfix/v2.0.3-media-relay
Jun 1, 2026
Merged

hotfix(v2.0.3): 接通媒体反代并修复下载崩溃,恢复媒体发送#80
FlanChanXwO merged 1 commit into
masterfrom
hotfix/v2.0.3-media-relay

Conversation

@FlanChanXwO

@FlanChanXwO FlanChanXwO commented Jun 1, 2026

Copy link
Copy Markdown
Owner

紧急热修:已发布的 v2.0.3(master)缺少媒体反代修复,导致所有媒体(图片/视频/音频)静默发不出去。本 PR 仅把这次修复的 10 个文件补到 master,趁插件市场远程缓存尚未更新尽快合入。

get_or_download(_prepared)unexpected keyword argument 'image_relay_base_url'#74 给 sender 加了反代管线却没给下载器加对应参数,每次媒体下载抛 TypeError 被吞、download_failed=True。该修复在 v2.0.3 发版(squash)之后才并入 dev,故 master 上的 v2.0.3 未包含。

本分支基于 master,仅包含本次净改动(10 个文件),不复列整个 v2.0.3。

Modifications / 改动点

  • src/infrastructure/media/media_downloader.pyget_or_download / get_or_download_prepared 接通 image_relay_base_url / media_relay_base_url;新增 _build_relay_url_select_relay_base,下载时「先反代再回源」,缓存键与失败展示链接保持原始 URL(修复严重回归)。

  • src/infrastructure/utils/ffmpeg_helper.py:新增 transcode_to_gif_under_limit,将无声视频转 GIF 压到平台大小限制内。

  • 测试:反代回归测试 + GIF 压缩测试;修正自 fix(db,onebot): drop legacy link_preview column and add napcat stream upload #74 起过时的 test_base_sender_ffmpeg 预期。

  • 文档:帮助图副标题改为 Everything is RSSable 并重新生成、README 命令一览、KB 命令中文别名、CHANGELOG 2.0.3 补记反代与 GIF 压缩。

  • This is NOT a breaking change. / 这不是一个破坏性变更。

Screenshots or Test Results / 运行截图或测试结果

$ pytest tests/unit/infrastructure/test_media_downloader.py tests/unit/infrastructure/test_base_sender_ffmpeg.py -q
35 passed
$ uv run ruff check / format   # All checks passed(pre-commit 钩子通过)

Checklist / 检查清单

  • 😊 If there are new features added in the PR, I have discussed them with the authors through issues/emails, etc. / 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。
  • 👀 My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above. / 我的更改经过了良好的测试,并已在上方提供了"验证步骤"和"运行截图"
  • 🤓 I have ensured that no new dependencies are introduced. / 我确保没有引入新依赖库。
  • 😮 My changes do not introduce malicious code. / 我的更改没有引入恶意代码。

Summary by CodeRabbit

版本 2.0.3 发行说明

  • 新功能

    • 新增媒体反代配置,支持图片和非图片走不同反代基地址,下载失败自动回源。
    • 新增无声视频转 GIF 体积压缩策略,通过逐步降低分辨率和帧率将 GIF 压缩至平台允许大小。
  • 文档

    • 补充命令中文别名展示。
    • 增加项目文档徽标与命令一览截图。
    • 更新插件帮助页面文案。
  • 测试

    • 扩展媒体反代和 GIF 压缩功能的单元测试覆盖。

已发布的 v2.0.3 缺少媒体反代修复,导致所有媒体(图片/视频/音频)静默发不出去
(get_or_download(_prepared) 报 unexpected keyword argument 'image_relay_base_url')。
该修复在 v2.0.3 发版 squash 之后才并入 dev,故 master 未包含,本热修补上。

- media_downloader: get_or_download(_prepared) 接通 image/media relay;新增
  _build_relay_url、_select_relay_base,先反代再回源,缓存键与失败链接保持原始 URL。
- ffmpeg_helper: 新增 transcode_to_gif_under_limit,将无声视频转 GIF 压到大小限制内。
- 测试:反代回归 + GIF 压缩;修正过时的 test_base_sender_ffmpeg 预期。
- 文档:帮助图 slogan、README 命令一览、KB 命令别名、CHANGELOG 2.0.3 补记。
Copilot AI review requested due to automatic review settings June 1, 2026 00:48

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @FlanChanXwO, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@github-actions github-actions Bot added area: docs Documentation changes area: backend Backend or core runtime changes area: tests Test changes release Release metadata or changelog changes labels Jun 1, 2026
@coderabbitai

coderabbitai Bot commented Jun 1, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

此PR为媒体下载流程新增两项核心能力:媒体反代/中继支持(区分图片与非图片走不同反代源,失败自动回源)和GIF自适应压缩(通过降低分辨率与帧率将GIF压缩到平台限制)。同步更新了发布日志、文档和测试。

Changes

媒体处理增强

Layer / File(s) Summary
媒体反代URL构建和选择
src/infrastructure/media/media_downloader.py
新增 _build_relay_url()_select_relay_base() 工具函数,实现反代URL的多格式拼接(支持 = 后缀直拼、 ?url= 参数、 /?url= 路径)与媒体类型驱动的反代源选择(图片优先反代、否则通用反代)。
反代下载流程集成
src/infrastructure/media/media_downloader.py
get_or_downloadget_or_download_prepared 方法新增 image_relay_base_urlmedia_relay_base_url 参数;下载流程先根据媒体类型选择反代源构建 fetch_url,优先反代抓取失败时自动回退原始URL直连,缓存键与显示URL保持使用原始地址。
GIF压缩到字节上限
src/infrastructure/utils/ffmpeg_helper.py
新增 transcode_to_gif_under_limit() 异步方法,通过组合缩放因子 (0.75、0.5、0.35、0.25) 与帧率 (原始/15fps) 进行阶梯式转码尝试;每次尝试缓存结果并在超时、异常或返回码非零时清理重试;返回首个满足字节限制的GIF路径或 None
测试、导入整理与发布日志
tests/unit/infrastructure/test_base_sender_ffmpeg.pytests/unit/infrastructure/test_media_downloader.pyCHANGELOG.mdREADME.mddocs/usage/commands.mdscripts/template/rsshelp_template.html
集中导入关联模块;新增反代URL拼接规则、回源重试成功、缓存键与原始URL保持的单元测试;CHANGELOG与README记录两项新能力;补全命令文档的中文别名;HTML模板更新副标题文案。

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Suggested labels

area: backend, area: tests, area: docs, release

Poem

🐰 新增反代走通幽,
回源重试展身手,
GIF 压缩步步降,
大小受控不再愁,
媒体处理更流畅~ 🎬

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题清晰地总结了本次变更的主要内容:接通媒体反代功能并修复下载问题以恢复媒体发送,与提交的所有文件变更高度相关。
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@FlanChanXwO FlanChanXwO merged commit 9718fbe into master Jun 1, 2026
3 of 6 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in astrbot_plugin_rsshub Jun 1, 2026
@FlanChanXwO FlanChanXwO deleted the hotfix/v2.0.3-media-relay branch June 1, 2026 00:49

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: backend Backend or core runtime changes area: docs Documentation changes area: tests Test changes release Release metadata or changelog changes

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants