Conversation
Summary of ChangesHello @zhufree32, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 此拉取请求主要聚焦于提升STRM文件处理逻辑的准确性和可靠性。通过改进STRM文件路径到网盘存储路径的映射方式,并引入一套更严格的视频文件匹配算法,解决了可能存在的误匹配和不精确删除的问题。此外,还对STRM文件删除事件的处理流程进行了加固,确保操作的精准性和安全性。 Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
| # 获取strm文件的完整主名(仅去掉.strm后缀,保留所有字符) | ||
| strm_base_name = Path(base_path).name |
There was a problem hiding this comment.
| # 转换文件名和后缀为小写,避免大小写问题 | ||
| file_name = file_item.name.lower() | ||
| file_ext = Path(file_item.name).suffix.lower() | ||
|
|
||
| # 1. 检查是否为视频文件 | ||
| if file_ext not in VIDEO_EXTENSIONS: | ||
| continue | ||
|
|
||
| # 2. 提取视频文件的基础名(去掉最后一个视频后缀) | ||
| video_base_name = Path(file_item.name).stem | ||
|
|
||
| # 3. 精准匹配逻辑: | ||
| # - 场景1:视频基础名与strm主名完全一致(如 strm: test.strm → 视频: test.mkv) | ||
| # - 场景2:视频基础名以strm主名+分隔符开头(如 strm: test-1080p.strm → 视频: test-1080p.bluray.mkv) | ||
| if (video_base_name == strm_base_name) or ( | ||
| video_base_name.startswith(f"{strm_base_name}.") | ||
| or video_base_name.startswith(f"{strm_base_name} - ") | ||
| or video_base_name.startswith(f"{strm_base_name}_") | ||
| ): |
There was a problem hiding this comment.
当前的匹配逻辑存在几个可优化点:
file_name变量在第1426行已定义但未使用,应当移除。video_base_name未转换为小写,导致与strm_base_name的比较是大小写敏感的。- 多个
startswith判断可以通过传入元组的方式简化,使代码更简洁。
建议修改以实现大小写不敏感的匹配并优化代码。
# 转换后缀为小写,避免大小写问题
file_ext = Path(file_item.name).suffix.lower()
# 1. 检查是否为视频文件
if file_ext not in VIDEO_EXTENSIONS:
continue
# 2. 提取视频文件的基础名(去掉最后一个视频后缀)并转为小写
video_base_name = Path(file_item.name).stem.lower()
# 3. 精准匹配逻辑(大小写不敏感):
# - 场景1:视频基础名与strm主名完全一致(如 strm: test.strm → 视频: test.mkv)
# - 场景2:视频基础名以strm主名+分隔符开头(如 strm: test-1080p.strm → 视频: test-1080p.bluray.mkv)
if (video_base_name == strm_base_name) or video_base_name.startswith((
f"{strm_base_name}.",
f"{strm_base_name} - ",
f"{strm_base_name}_",
)):| # 明确视频后缀列表(覆盖主流视频格式) | ||
| VIDEO_EXTENSIONS = [".mkv", ".mp4", ".ts", ".m2ts", ".avi", ".mov", ".flv", ".wmv", ".mpeg", ".mpg"] |
No description provided.