Skip to content

Commit 3b158d8

Browse files
authored
Merge pull request #7 from qwqcode/dev
Version 0.3.0.0
2 parents 39b031f + 64e2673 commit 3b158d8

29 files changed

Lines changed: 2171 additions & 465 deletions

README.md

3.31 KB

Rename Subtitle Filenames Automatically to Match Videos Easily through the Sight Tool.

待续

目的:重命名番剧外挂的字幕文件名,使之与视频文件名相对应

如何拥有 SubRenamer ?

获取最新版程序,可到 Releases 页 查看

速度慢?请: https://www.lanzous.com/iak59ji (密码:huaji)

P.S. 程序依赖 NET >= 4.5 的运行环境,请先下载安装:https://dotnet.microsoft.com/download (若为 Win10 用户,请无视此操作)

特性

  • 体积小 (~1MB)
  • 比较简单的操作
  • 支持自动匹配
  • 支持手动匹配
  • 支持正则表达式匹配
  • 一键改名 (支持备份)
  • 可直接拖拽文件导入
  • 可导出为命令行命令

使用场景

请听 ABCDE 的故事:

(缩减版) 小A下载了一部新更的生肉番,又从字幕网站下载到了一套字幕文件,生肉番的 视频文件名 常常和 字幕文件名 不一致,看番时需要手动选定字幕,下次打开又得重新选定。小A拥有了 SubRenamer,从此改名交给他来做,终于可以安安心心看番啦。

(探究版) 小B今天下载了一部番剧,小B因不会他国语言从而需要找寻一套字幕。小B下载到了字幕,但因 字幕文件名 与 视频文件名 不相对应,播放器无法自动载入字幕文件,小B因每次都要手动选择字幕文件而烦恼万分。最终,小B实在受不鸟了,毅然决然决定修改文件名...... 所以问题来了,小B如何才能快速地修改字幕文件名,而不是一个一个慢慢地手动修改呢???

(激情版) 小C热爱学习,小C下载了一套100000000集的学习视频,提升自我人生价值的大好机会到了,准备今天晚上就开淦(darkbubi),可到了晚上,小C打开下载好的视频时却突然想起,自己什么也(bing)听(bu)不(xiang)懂(xue)(此刻的小C对于学习的热情瞬间熄灭)。可是突然!小C发现了 SubRenamer,下载一套字幕后,修改按键一点,100000000集的学习视频字幕文件顺利加载,小C对于学习的热情死(bu)灰(ke)复(neng)燃(di)

(慵懒版) 小D拥有了 SubRenamer 后,字幕文件改名的操作全交给 SubRenamer,省去了大量时间可以留给睡觉。

(蜜汁版) 小E . .o. 0。.O . 。o.

截图

待续...

有 BUG?

可在 issues 页 进行反馈,或发 Email 到 qwqcode@qq.com 联系我,欢迎反馈~~

FAQ

待续...

捐助

如果您觉得我的项目对您有帮助,并且您愿意给予我一点小小的支持,您可以通过以下方式向我捐助,这样可以维持项目的持续发展,非常感谢!(/ω\)

Alipay Wechat

捐助者的名字将保存于 捐助者名单

最后,我再次对您致以最最最诚挚的感谢!

SubRenamer/Action.cs

Lines changed: 199 additions & 53 deletions
Large diffs are not rendered by default.

SubRenamer/AppSettings.cs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using SubRenamer.Lib;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Runtime.CompilerServices;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
9+
namespace SubRenamer
10+
{
11+
public class AppSettings
12+
{
13+
public static bool RawSubtitleBuckup
14+
{
15+
get { return GetBoolVal(defaultVal: true); }
16+
set { WriteBoolVal(value); }
17+
}
18+
19+
public static bool ListItemRemovePrompt
20+
{
21+
get { return GetBoolVal(defaultVal: true); }
22+
set { WriteBoolVal(value); }
23+
}
24+
25+
public static bool ListShowFileFullName
26+
{
27+
get { return GetBoolVal(defaultVal: false); }
28+
set { WriteBoolVal(value); }
29+
}
30+
31+
#region Utils
32+
public static IniFile IniFile = new IniFile();
33+
34+
private static bool GetBoolVal(bool defaultVal = false, [CallerMemberName]string key = null)
35+
{
36+
if (string.IsNullOrWhiteSpace(key)) return defaultVal;
37+
string defaultValStr = defaultVal ? "1" : "0";
38+
return IniFile.Read(key, defaultValStr).Equals("1");
39+
}
40+
41+
private static void WriteBoolVal(bool val, [CallerMemberName]string key = null)
42+
{
43+
if (string.IsNullOrWhiteSpace(key)) return;
44+
IniFile.Write(key, val ? "1" : "0");
45+
}
46+
#endregion
47+
}
48+
}

SubRenamer/Global.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.IO;
34
using System.Linq;
45
using System.Text;
56
using System.Threading.Tasks;
7+
using System.Windows.Forms;
68

79
namespace SubRenamer
810
{
911
public class Global
1012
{
1113
#region 常量
14+
public static readonly string LOG_FILENAME = Path.Combine(Application.StartupPath, $"{Program.GetAppName()}.log");
15+
public static readonly List<string> VideoExts = new List<string> { ".mkv", ".mp4", "flv", ".avi", ".mov", ".rmvb", ".wmv", ".mpg", ".avs" };
16+
public static readonly List<string> SubExts = new List<string> { ".srt", ".ass", ".ssa", ".sub", ".idx" };
1217
#endregion
1318

1419
/// <summary>

SubRenamer/Lib/IniFile.cs

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Reflection;
6+
using System.Runtime.InteropServices;
7+
using System.Text;
8+
using System.Threading.Tasks;
9+
10+
namespace SubRenamer.Lib
11+
{
12+
public class IniFile
13+
{
14+
string Path;
15+
public static string APP_NAME = Assembly.GetExecutingAssembly().GetName().Name;
16+
17+
[DllImport("kernel32", CharSet = CharSet.Ansi)]
18+
static extern long WritePrivateProfileString(string Section, string Key, string Value, string FilePath);
19+
20+
[DllImport("kernel32", CharSet = CharSet.Ansi)]
21+
static extern int GetPrivateProfileString(string Section, string Key, string Default, StringBuilder RetVal, int Size, string FilePath);
22+
23+
public IniFile(string IniPath = null)
24+
{
25+
Path = new FileInfo(IniPath ?? APP_NAME + ".ini").FullName.ToString();
26+
}
27+
28+
public string Read(string Key, string DefaultVal = "", string Section = null)
29+
{
30+
var RetVal = new StringBuilder(255);
31+
GetPrivateProfileString(Section ?? APP_NAME, Key, DefaultVal, RetVal, 255, Path);
32+
return RetVal.ToString();
33+
}
34+
35+
public void Write(string Key, string Value, string Section = null)
36+
{
37+
WritePrivateProfileString(Section ?? APP_NAME, Key, Value, Path);
38+
}
39+
40+
public void DeleteKey(string Key, string Section = null)
41+
{
42+
Write(Key, null, Section ?? APP_NAME);
43+
}
44+
45+
public void DeleteSection(string Section = null)
46+
{
47+
Write(null, null, Section ?? APP_NAME);
48+
}
49+
50+
public bool KeyExists(string Key, string Section = null)
51+
{
52+
return Read(Key, Section).Length > 0;
53+
}
54+
}
55+
}

SubRenamer/Lib/Ui.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using System.Windows.Forms;
7+
8+
namespace SubRenamer.Lib
9+
{
10+
public static class Ui
11+
{
12+
13+
}
14+
}
Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
using System;
1+
using Microsoft.WindowsAPICodePack.Dialogs;
2+
using System;
23
using System.Collections.Generic;
4+
using System.IO;
35
using System.Linq;
46
using System.Text;
57
using System.Threading.Tasks;
68
using System.Windows.Forms;
9+
using static SubRenamer.Global;
710

8-
namespace SubRenamer
11+
namespace SubRenamer.Lib
912
{
10-
public static class Utils
13+
class Utils
1114
{
1215
/// <summary>
1316
/// 输入对话框
@@ -37,5 +40,26 @@ public static string InputDialog(string text, string caption)
3740

3841
return prompt.ShowDialog() == DialogResult.OK ? textBox.Text : "";
3942
}
43+
44+
public static void OpenFile(AppFileType FileType, Action<string, AppFileType> opened)
45+
{
46+
using (var fbd = new CommonOpenFileDialog())
47+
{
48+
if (FileType == AppFileType.Video)
49+
fbd.Filters.Add(new CommonFileDialogFilter("视频文件", string.Join(";", VideoExts.ToList())));
50+
else if (FileType == AppFileType.Sub)
51+
fbd.Filters.Add(new CommonFileDialogFilter("字幕文件", string.Join(";", SubExts.ToList())));
52+
53+
fbd.Filters.Add(new CommonFileDialogFilter("视频或字幕文件", string.Join(";", VideoExts.Concat(SubExts).ToList())));
54+
fbd.Filters.Add(new CommonFileDialogFilter("任何类型", "*.*"));
55+
var result = fbd.ShowDialog();
56+
57+
if (result == CommonFileDialogResult.Ok && !string.IsNullOrWhiteSpace(fbd.FileName))
58+
{
59+
var fileName = Path.GetFileName(fbd.FileName.Trim());
60+
opened(fileName, FileType);
61+
}
62+
}
63+
}
4064
}
4165
}

SubRenamer/MainForm.Designer.cs

Lines changed: 40 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)