图文视频单独下载,文件名沿用视频名
This commit is contained in:
@@ -24,15 +24,6 @@ namespace dy.net.utils
|
||||
private const string IllegalCharReplacement = "";
|
||||
|
||||
|
||||
// 修正:使用 \U 前缀来表示超过 \uFFFF 的Unicode码点
|
||||
private static readonly Regex _emojiRegex = new Regex(
|
||||
@"[\u1F600-\u1F64F\u1F300-\u1F5FF\u1F680-\u1F6FF\U0001E000-\U0001EFFF\u2600-\u2B55\u200D]",
|
||||
RegexOptions.Compiled);
|
||||
|
||||
private static readonly Regex _hashtagRegex = new Regex(@"\#\S+", RegexOptions.Compiled);
|
||||
private static readonly Regex _invalidCharsRegex;
|
||||
private static readonly Regex _multipleUnderscoresRegex = new Regex(@"_+", RegexOptions.Compiled);
|
||||
|
||||
#endregion
|
||||
|
||||
#region 处理抖音视频文件名
|
||||
|
||||
@@ -55,28 +55,16 @@ namespace dy.net.utils
|
||||
return placeholderMap.TryGetValue(placeholderKey, out var value) ? value : match.Value;
|
||||
});
|
||||
|
||||
return finalTitle.Replace("--","-");
|
||||
}
|
||||
var fullName= finalTitle.Replace("--","-");
|
||||
|
||||
/// <summary>
|
||||
/// 格式化文件大小(字节→KB/MB/GB)
|
||||
/// </summary>
|
||||
private static string FormatFileSize(long fileSizeInBytes)
|
||||
{
|
||||
if (fileSizeInBytes < 0) return "无效大小";
|
||||
if (fileSizeInBytes == 0) return "0B";
|
||||
|
||||
const long kb = 1024;
|
||||
const long mb = kb * 1024;
|
||||
const long gb = mb * 1024;
|
||||
|
||||
return fileSizeInBytes switch
|
||||
if (fullName.Length > 120)
|
||||
{
|
||||
< kb => $"{fileSizeInBytes}B",
|
||||
< mb => $"{fileSizeInBytes / (double)kb:F1}KB",
|
||||
< gb => $"{fileSizeInBytes / (double)mb:F1}MB",
|
||||
_ => $"{fileSizeInBytes / (double)gb:F1}GB"
|
||||
};
|
||||
return fullName.Substring(0, 120);
|
||||
}
|
||||
else
|
||||
{
|
||||
return fullName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user