文件命名系统添加视频章节

croire 3 years ago
parent a809245e95
commit 6a3b1e96b5

@ -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<FileNamePart> 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('/');
}

@ -4,6 +4,7 @@
{
// Video
ORDER = 1,
SECTION,
MAIN_TITLE,
PAGE_TITLE,
VIDEO_ZONE,

@ -33,6 +33,8 @@ namespace DownKyi.Core.Settings
{
FileNamePart.MAIN_TITLE,
FileNamePart.SLASH,
FileNamePart.SECTION,
FileNamePart.SLASH,
FileNamePart.ORDER,
FileNamePart.HYPHEN,
FileNamePart.PAGE_TITLE,

@ -122,6 +122,7 @@
<system:String x:Key="FileName">文件名:</system:String>
<system:String x:Key="OptionalFields">可选字段:</system:String>
<system:String x:Key="DisplayOrder">序号</system:String>
<system:String x:Key="DisplaySection">视频章节</system:String>
<system:String x:Key="DisplayMainTitle">视频标题</system:String>
<system:String x:Key="DisplayPageTitle">分P标题</system:String>
<system:String x:Key="DisplayVideoZone">视频分区</system:String>

@ -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;

Loading…
Cancel
Save