From 6a3b1e96b5949f7d7c04f3dfed66e10c25c562cb Mon Sep 17 00:00:00 2001 From: croire <1432593898@qq.com> Date: Sun, 19 Dec 2021 00:00:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=91=BD=E5=90=8D=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E6=B7=BB=E5=8A=A0=E8=A7=86=E9=A2=91=E7=AB=A0=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DownKyi.Core/FileName/FileName.cs | 13 +++++++++++++ DownKyi.Core/FileName/FileNamePart.cs | 1 + DownKyi.Core/Settings/SettingsManager.Video.cs | 2 ++ DownKyi/Languages/Default.xaml | 1 + DownKyi/ViewModels/Settings/ViewVideoViewModel.cs | 3 +++ 5 files changed, 20 insertions(+) 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;