bilibili解析器增加回退机制#113
Open
qihang518887 wants to merge 1 commit intoZhalslar:mainfrom
Open
Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Contributor
评审者指南(在小型 PR 上默认折叠)评审者指南为哔哩哔哩(Bilibili)直播流选择实现编解码器回退优先级列表:当用户偏好的编解码器不可用时,解析器会自动按 AV1、HEVC、AVC 的顺序回退,并在此过程中去重偏好选项。
|
| 变更 | 详情 | 文件 |
|---|---|---|
| 在从 Bilibili 检测最佳流时,添加带自动回退和去重功能的编解码器优先级列表。 |
|
core/parsers/bilibili/__init__.py |
使用提示与命令
与 Sourcery 交互
- 触发新的评审: 在 pull request 下评论
@sourcery-ai review。 - 继续讨论: 直接回复 Sourcery 的评审评论。
- 从评审评论生成 GitHub issue: 通过回复某条评审评论,请求 Sourcery 从该评论创建一个 issue。你也可以直接回复该评论
@sourcery-ai issue来创建对应的 issue。 - 生成 pull request 标题: 在 pull request 标题的任意位置写上
@sourcery-ai,即可在任意时间生成标题。你也可以在 pull request 中评论@sourcery-ai title来(重新)生成标题。 - 生成 pull request 摘要: 在 pull request 正文任意位置写上
@sourcery-ai summary,即可在你想要的位置生成 PR 摘要。你也可以在 pull request 中评论@sourcery-ai summary来在任意时间(重新)生成摘要。 - 生成评审者指南: 在 pull request 中评论
@sourcery-ai guide,即可在任意时间(重新)生成评审者指南。 - 解决所有 Sourcery 评论: 在 pull request 中评论
@sourcery-ai resolve,即可标记所有 Sourcery 评论为已解决。如果你已经处理完所有评论且不想再看到它们,这将会很有用。 - 忽略所有 Sourcery 评审: 在 pull request 中评论
@sourcery-ai dismiss,即可忽略所有现有的 Sourcery 评审。特别适用于你想从头开始新的评审时——别忘了再评论@sourcery-ai review以触发新的评审!
自定义你的使用体验
访问你的 控制台 以:
- 启用或禁用评审功能,例如 Sourcery 自动生成的 pull request 摘要、评审者指南等。
- 更改评审语言。
- 添加、删除或编辑自定义的评审说明。
- 调整其他评审设置。
获取帮助
Original review guide in English
Reviewer's guide (collapsed on small PRs)
Reviewer's Guide
Implements a codec fallback priority list for Bilibili stream selection so that if the user-preferred codec is unavailable, the parser automatically falls back to AV1, HEVC, then AVC while de-duplicating preferences.
Sequence diagram for Bilibili codec fallback in extract_download_urls
sequenceDiagram
participant Parser as BilibiliParser
participant BVideo as BilibiliVideo
participant Detecter as VideoDownloadURLDataDetecter
Parser->>BVideo: get_download_url(page_index)
BVideo-->>Parser: download_url_data
Parser->>Detecter: new VideoDownloadURLDataDetecter(download_url_data)
Parser->>Parser: build codec_candidates [user_codec, AV1, HEV, AVC]
Parser->>Parser: deduplicate into codec_priority
Parser->>Detecter: detect_best_streams(video_max_quality,
Parser->>Detecter: codecs=codec_priority,
Parser->>Detecter: no_dolby_video=True, no_hdr=True)
Detecter-->>Parser: streams
Class diagram for Bilibili parser codec selection changes
classDiagram
class BilibiliParser {
+VideoCodecs video_codecs
+int video_quality
+extract_download_urls(page_index)
}
class VideoDownloadURLDataDetecter {
+VideoDownloadURLDataDetecter(download_url_data)
+detect_best_streams(video_max_quality, codecs, no_dolby_video, no_hdr)
}
class VideoCodecs {
<<enumeration>>
AV1
HEV
AVC
}
class BilibiliVideo {
+get_download_url(page_index)
}
BilibiliParser --> BilibiliVideo : uses
BilibiliParser --> VideoDownloadURLDataDetecter : creates
BilibiliParser --> VideoCodecs : uses
VideoDownloadURLDataDetecter --> VideoCodecs : uses
VideoDownloadURLDataDetecter ..> BilibiliVideo : analyzes URLs from
Flow diagram for codec priority list with fallback
flowchart TD
A[start] --> B[Read user preferred codec self.video_codecs]
B --> C[Initialize codec_candidates with self.video_codecs, AV1, HEV, AVC]
C --> D[Initialize empty codec_priority]
D --> E[For each codec c in codec_candidates]
E --> F{c already in codec_priority?}
F -- yes --> G[Skip c]
F -- no --> H[Append c to codec_priority]
G --> I{More codecs?}
H --> I{More codecs?}
I -- yes --> E
I -- no --> J[Call detect_best_streams with codecs=codec_priority]
J --> K[end]
File-Level Changes
| Change | Details | Files |
|---|---|---|
| Add codec priority list with automatic fallback and de-duplication when detecting best streams from Bilibili. |
|
core/parsers/bilibili/__init__.py |
Tips and commands
Interacting with Sourcery
- Trigger a new review: Comment
@sourcery-ai reviewon the pull request. - Continue discussions: Reply directly to Sourcery's review comments.
- Generate a GitHub issue from a review comment: Ask Sourcery to create an
issue from a review comment by replying to it. You can also reply to a
review comment with@sourcery-ai issueto create an issue from it. - Generate a pull request title: Write
@sourcery-aianywhere in the pull
request title to generate a title at any time. You can also comment
@sourcery-ai titleon the pull request to (re-)generate the title at any time. - Generate a pull request summary: Write
@sourcery-ai summaryanywhere in
the pull request body to generate a PR summary at any time exactly where you
want it. You can also comment@sourcery-ai summaryon the pull request to
(re-)generate the summary at any time. - Generate reviewer's guide: Comment
@sourcery-ai guideon the pull
request to (re-)generate the reviewer's guide at any time. - Resolve all Sourcery comments: Comment
@sourcery-ai resolveon the
pull request to resolve all Sourcery comments. Useful if you've already
addressed all the comments and don't want to see them anymore. - Dismiss all Sourcery reviews: Comment
@sourcery-ai dismisson the pull
request to dismiss all existing Sourcery reviews. Especially useful if you
want to start fresh with a new review - don't forget to comment
@sourcery-ai reviewto trigger a new review!
Customizing Your Experience
Access your dashboard to:
- Enable or disable review features such as the Sourcery-generated pull request
summary, the reviewer's guide, and others. - Change the review language.
- Add, remove or edit custom review instructions.
- Adjust other review settings.
Getting Help
- Contact our support team for questions or feedback.
- Visit our documentation for detailed guides and information.
- Keep in touch with the Sourcery team by following us on X/Twitter, LinkedIn or GitHub.
Contributor
There was a problem hiding this comment.
Hey - 我在这里给出了一些整体性的反馈:
- 请考虑处理
self.video_codecs可能为None或其他无效值的情况,这样可以避免codec_priority把一个不可用的值作为首选项。 - 请再次确认枚举/常量名
VideoCodecs.HEV—— 描述中提到的是hevc,如果枚举实际是HEVC,这里在运行时会报错,需要更新为正确的枚举成员。
给 AI 代理的提示
Please address the comments from this code review:
## Overall Comments
- Consider handling the case where `self.video_codecs` may be `None` or otherwise invalid, so that `codec_priority` does not end up containing an unusable value as the first choice.
- Double-check the enum/constant name `VideoCodecs.HEV` – the description mentions `hevc`, so if the enum is actually `HEVC` this will raise at runtime and should be updated to the correct member.帮我变得更有用!请对每条评论点 👍 或 👎,我会根据你的反馈改进之后的评审。
Original comment in English
Hey - I've left some high level feedback:
- Consider handling the case where
self.video_codecsmay beNoneor otherwise invalid, so thatcodec_prioritydoes not end up containing an unusable value as the first choice. - Double-check the enum/constant name
VideoCodecs.HEV– the description mentionshevc, so if the enum is actuallyHEVCthis will raise at runtime and should be updated to the correct member.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider handling the case where `self.video_codecs` may be `None` or otherwise invalid, so that `codec_priority` does not end up containing an unusable value as the first choice.
- Double-check the enum/constant name `VideoCodecs.HEV` – the description mentions `hevc`, so if the enum is actually `HEVC` this will raise at runtime and should be updated to the correct member.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
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.
加了一个优先级列表,最先的是自选的编码格式,然后按照av1-hevc-avc的顺序进行一次去重
这样首选的编码格式没有的话,会自动回退到其他的编码
由 Sourcery 提供的摘要
新功能:
Original summary in English
Summary by Sourcery
New Features: