diff --git a/DownKyi.Core/FileName/FileName.cs b/DownKyi.Core/FileName/FileName.cs index ea411d9..23d9c1d 100644 --- a/DownKyi.Core/FileName/FileName.cs +++ b/DownKyi.Core/FileName/FileName.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Text.RegularExpressions; namespace DownKyi.Core.FileName { @@ -6,6 +7,7 @@ namespace DownKyi.Core.FileName { private readonly List nameParts; private int order = -1; + private string section = "SECTION"; private string mainTitle = "MAIN_TITLE"; private string pageTitle = "PAGE_TITLE"; private string videoZone = "VIDEO_ZONE"; @@ -29,6 +31,12 @@ namespace DownKyi.Core.FileName return this; } + public FileName SetSection(string section) + { + this.section = section; + return this; + } + public FileName SetMainTitle(string mainTitle) { this.mainTitle = mainTitle; @@ -83,6 +91,9 @@ namespace DownKyi.Core.FileName path += "ORDER"; } break; + case FileNamePart.SECTION: + path += section; + break; case FileNamePart.MAIN_TITLE: path += mainTitle; break; @@ -109,6 +120,8 @@ namespace DownKyi.Core.FileName } } + // 避免连续多个斜杠 + path = Regex.Replace(path, @"//+", "/"); // 避免以斜杠开头和结尾的情况 return path.TrimEnd('/').TrimStart('/'); } diff --git a/DownKyi.Core/FileName/FileNamePart.cs b/DownKyi.Core/FileName/FileNamePart.cs index 515377e..551829c 100644 --- a/DownKyi.Core/FileName/FileNamePart.cs +++ b/DownKyi.Core/FileName/FileNamePart.cs @@ -4,6 +4,7 @@ { // Video ORDER = 1, + SECTION, MAIN_TITLE, PAGE_TITLE, VIDEO_ZONE, diff --git a/DownKyi.Core/Settings/SettingsManager.Video.cs b/DownKyi.Core/Settings/SettingsManager.Video.cs index 039f7a8..4c307a0 100644 --- a/DownKyi.Core/Settings/SettingsManager.Video.cs +++ b/DownKyi.Core/Settings/SettingsManager.Video.cs @@ -33,6 +33,8 @@ namespace DownKyi.Core.Settings { FileNamePart.MAIN_TITLE, FileNamePart.SLASH, + FileNamePart.SECTION, + FileNamePart.SLASH, FileNamePart.ORDER, FileNamePart.HYPHEN, FileNamePart.PAGE_TITLE, diff --git a/DownKyi/Languages/Default.xaml b/DownKyi/Languages/Default.xaml index 45d6b33..e74787a 100644 --- a/DownKyi/Languages/Default.xaml +++ b/DownKyi/Languages/Default.xaml @@ -122,6 +122,7 @@ 文件名: 可选字段: 序号 + 视频章节 视频标题 分P标题 视频分区 diff --git a/DownKyi/ViewModels/Settings/ViewVideoViewModel.cs b/DownKyi/ViewModels/Settings/ViewVideoViewModel.cs index b5cf47d..9dbb9e9 100644 --- a/DownKyi/ViewModels/Settings/ViewVideoViewModel.cs +++ b/DownKyi/ViewModels/Settings/ViewVideoViewModel.cs @@ -374,6 +374,9 @@ namespace DownKyi.ViewModels.Settings case FileNamePart.ORDER: display = DictionaryResource.GetString("DisplayOrder"); break; + case FileNamePart.SECTION: + display = DictionaryResource.GetString("DisplaySection"); + break; case FileNamePart.MAIN_TITLE: display = DictionaryResource.GetString("DisplayMainTitle"); break;