Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

增加视频字幕一对多功能 #54

Merged
merged 15 commits into from
Sep 23, 2024
Merged

Conversation

zqzqoooo
Copy link
Contributor

修改了MergeSameKeysItems中的匹配规则,筛选出字幕文件并与视频文件配对后删除已配对的视频item,实现视频和字幕一对多匹配。同时在选择全部保留时自动勾选保留语言后缀选项防止重命名失败。

@zqzqoooo
Copy link
Contributor Author

image
image

- Detect if multiple subtitles exist for a single video
- Retain language suffix if one-to-many mapping is found
- Improve merging of items with same keys
  - Group items by non-empty keys and merge them
  - Ensure the first non-empty video and all non-empty subtitles are kept
  - Keep items with empty keys unchanged
  - Update method signature to accept IReadOnlyList
@qwqcode
Copy link
Owner

qwqcode commented Sep 23, 2024

谢谢你提交 PR!你的修改思路非常好

为了方便测试,我改了下代码:不再做引用类型的函数输入值修改(in-place 修改),而是创建一个新 List 然后输出。其次,输入值的数据类型改成了 IReadOnlyList,防止修改传入的数据(去掉函数的副作用)。

还有保留语言后缀的开关,逻辑我改成了:检查是否存在视频字幕一对多的情况,若存在则保留语言后缀。(之前是用户点了「保留全部文件」才自动打开)。

这个「选择保留语言」的对话框其实有点烦,以后可以增加一个新的选项,可以选择禁用掉这个功能。


我写了许多新的测试用例,在这里,本 PR 已通过测试,看看还有没有其他需要的补充。

然后文件列表匹配整个执行流程也有测试用例了,在这个地方,有需要可以补充。

在命令行运行 dotnet test SubRenamer.Tests --verbosity normal 就可以执行测试啦,相较于之前开发更方便,无需运行软件人工手动测试。Rider 里面也挺方便的:

SCR-20240923-tobz

@qwqcode qwqcode merged commit f5c096b into qwqcode:main Sep 23, 2024
3 checks passed
@qwqcode qwqcode linked an issue Sep 23, 2024 that may be closed by this pull request
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