This commit is contained in:
jianzhichu
2026-02-02 23:35:07 +08:00
parent 46bec7a0d4
commit c1d5db18a9
13 changed files with 1076 additions and 215 deletions
+29
View File
@@ -1,5 +1,6 @@
using ClockSnowFlake;
using dy.net.model.entity;
using dy.net.utils;
using SqlSugar;
//using static Org.BouncyCastle.Math.EC.ECCurve;
@@ -189,6 +190,34 @@ namespace dy.net.service
//}
/// <summary>
/// 将所有关注博主的保存路径统一刷成博主姓名,防止博主名字改变后出现多个文件夹
/// </summary>
/// <returns></returns>
public async Task UpdateFollowedSavePathAsync()
{
var existNoSavePath =await sqlSugarClient.Queryable<DouyinFollowed>().Where(x => string.IsNullOrWhiteSpace(x.SavePath)).AnyAsync();
if (existNoSavePath)
{
var list = await sqlSugarClient.Queryable<DouyinFollowed>().ToListAsync();
var noSavePathList = list.Where(x => string.IsNullOrWhiteSpace(x.SavePath));
foreach (var item in noSavePathList)
{
var path = DouyinFileNameHelper.SanitizeLinuxFileName(item.UperName, "抖音号" + item.UperId, true);
path = DouyinFileNameHelper.LimitUnifiedCount(path, 20);
var existFollow = list.Where(x => x.UperId != item.UperId && x.SavePath == path).Any();
if (existFollow)
{
item.SavePath = path + "_" + item.UperId;
}
else
{
item.SavePath = path;
}
}
await sqlSugarClient.Updateable(list).UpdateColumns(x => new { x.SavePath }).ExecuteCommandAsync();
}
}
#region
///// <summary>
+2 -2
View File
@@ -304,12 +304,12 @@ namespace dy.net.service
if (File.Exists(video.path))
{
File.Delete(video.path); // 异步删除,提升并发性能
Serilog.Log.Debug("视频文件删除成功:Path={0}", video);
Serilog.Log.Debug("视频文件删除成功:Path={0}", video.path);
if (!video.onlyImgOrMp3)//如果是纯图片或纯音频文件,则不删除所在文件夹
{
//检查这个路径所在文件夹是否还有其他视频文件,如果没有则删除这个文件夹
var dir = Path.GetDirectoryName(video.Item1);
var dir = Path.GetDirectoryName(video.path);
bool hasMp4File = Directory.EnumerateFiles(dir, "*.mp4", SearchOption.TopDirectoryOnly).Any(); // 只要存在一个MP4文件就返回true;
if (!hasMp4File)