fix(youtube): 支持 Shorts 链接#381
Open
Loker-Choi wants to merge 1 commit into
Open
Conversation
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.
改动概述
支持后端识别 YouTube Shorts 链接,并从 Shorts URL 中提取视频 ID。
为什么
BiliNote 已支持 YouTube 视频链接,但后端当前只识别
watch?v=和youtu.be/两种链接形态。现在 YouTube Shorts 链接非常常见,例如https://www.youtube.com/shorts/<id>,这类链接可能会在 URL 校验阶段被拒绝,或在后续字幕 / 视频处理链路中无法提取 video id。做了什么
is_supported_video_url中允许youtube.com/shorts/<id>链接extract_video_id中支持从 Shorts URL 提取 YouTube video idwatch?v=、youtu.be/、shorts/三种 YouTube URL 形态测试方式
python -m py_compile backend/app/utils/url_parser.py backend/app/validators/video_url_validator.py backend/tests/test_video_url_support.pypython -m unittest backend.tests.test_video_url_supportpython -m unittest backend.tests.test_video_url_support backend.tests.test_note_helper手动验证过以下输入会通过后端 URL 校验,并提取出正确的 video id:
补充说明:本地执行
python -m unittest discover backend/tests时,当前有一个与本次改动无关的既有失败:test_task_serial_executor。本次没有完成完整「生成笔记」端到端验证,因为本地缺少完整后端运行依赖 / 模型与供应商配置。回归风险
风险较低。本次改动只扩展 YouTube URL 的接受范围和 video id 提取正则;已有的
watch?v=和youtu.be/链接形态已通过测试覆盖。