bug修复

This commit is contained in:
jianzhichu
2025-11-30 21:33:18 +08:00
parent e42a004765
commit 50149a280b
57 changed files with 766 additions and 317 deletions
+2 -2
View File
@@ -96,7 +96,7 @@ namespace dy.net.utils
// 步骤6:移除首尾无效字符(分隔符、点号)
title = title.Replace(" ","").Trim(Separator, '.');
title = title.Replace("--", "-");//避免多个连续----
// 容错:如果净化后为空,返回默认值
return string.IsNullOrWhiteSpace(title) ? id : title;
}
@@ -151,7 +151,7 @@ namespace dy.net.utils
//string emojiPattern = @"[\u1F600-\u1F64F\u1F300-\u1F5FF\u1F680-\u1F6FF\u1E000-\u1EFFF\u2600-\u2B55\u200D]";
//path = Regex.Replace(path, emojiPattern, "", RegexOptions.Compiled);
path = Regex.Replace(path, @"[^a-zA-Z0-9\u4e00-\u9fa5]", "-");
path = path.Replace("--", "-");//避免重复---
foreach (var c in Path.GetInvalidFileNameChars())
{
path = path.Replace(c, '_');
+3 -2
View File
@@ -20,7 +20,7 @@ namespace dy.net.utils
public static string Generate(
string template,
VideoTitleDataTemplate data,
string timeFormat = "yyyyMMddHHmmss",
string timeFormat = "yyyyMMdd",
string emptyPlaceholder = "")
{
// 校验入参
@@ -36,6 +36,7 @@ namespace dy.net.utils
["VideoTitle"] = string.IsNullOrWhiteSpace(data.VideoTitle) ? emptyPlaceholder : data.VideoTitle,
["FileHash"] = string.IsNullOrWhiteSpace(data.FileHash) ? emptyPlaceholder : data.FileHash,
["Resolution"] = string.IsNullOrWhiteSpace(data.Resolution) ? emptyPlaceholder : data.Resolution,
["Author"] = string.IsNullOrWhiteSpace(data.Author) ? emptyPlaceholder : data.Author,
// 时间字段(支持空值处理)
//["SyncTime"] = data.SyncTime.HasValue ? data.SyncTime.Value.ToString(timeFormat) : emptyPlaceholder,
@@ -54,7 +55,7 @@ namespace dy.net.utils
return placeholderMap.TryGetValue(placeholderKey, out var value) ? value : match.Value;
});
return finalTitle;
return finalTitle.Replace("--","-");
}
/// <summary>